Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
tbblgm119
lede
提交
adf2b227
L
lede
项目概览
tbblgm119
/
lede
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
lede
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
adf2b227
编写于
1月 10, 2018
作者:
C
coolsnowwolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add ppp-sync and shellsync
上级
b0f643aa
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
393 addition
and
49 deletion
+393
-49
package/network/services/ppp/Makefile
package/network/services/ppp/Makefile
+1
-1
package/network/services/ppp/files/ppp.sh
package/network/services/ppp/files/ppp.sh
+9
-0
package/network/services/ppp/patches/140-pppoe_compile_fix.patch
.../network/services/ppp/patches/140-pppoe_compile_fix.patch
+22
-40
package/network/services/ppp/patches/500-add-pptp-plugin.patch
...ge/network/services/ppp/patches/500-add-pptp-plugin.patch
+1
-2
package/network/services/ppp/patches/511-syncppp.patch
package/network/services/ppp/patches/511-syncppp.patch
+214
-0
package/network/services/ppp/patches/520-uniq.patch
package/network/services/ppp/patches/520-uniq.patch
+6
-6
package/network/services/shellsync/Makefile
package/network/services/shellsync/Makefile
+34
-0
package/network/services/shellsync/src/shellsync.c
package/network/services/shellsync/src/shellsync.c
+106
-0
未找到文件。
package/network/services/ppp/Makefile
浏览文件 @
adf2b227
...
...
@@ -35,7 +35,7 @@ endef
define
Package/ppp
$(call
Package/ppp/Default)
DEPENDS
:=
+kmod-ppp
DEPENDS
:=
+kmod-ppp
+libpthread +shellsync
TITLE
:=
PPP daemon
VARIANT
:=
default
endef
...
...
package/network/services/ppp/files/ppp.sh
浏览文件 @
adf2b227
...
...
@@ -223,7 +223,16 @@ proto_pppoe_setup() {
json_get_var service service
json_get_var host_uniq host_uniq
#By 蝈蝈:并发拨号同步的前期准备
syncppp_option
=
""
[
"
$(
uci get syncdial.config.enabled
)
"
==
"1"
]
&&
{
ppp_if_cnt
=
$(
cat
/etc/config/network |
grep
-c
"proto 'pppoe'"
)
syncppp_option
=
"syncppp
$ppp_if_cnt
"
shellsync
$ppp_if_cnt
10
}
ppp_generic_setup
"
$config
"
\
$syncppp_option
\
plugin rp-pppoe.so
\
${
ac
:+rp_pppoe_ac
"
$ac
"
}
\
${
service
:+rp_pppoe_service
"
$service
"
}
\
...
...
package/network/services/ppp/patches/140-pppoe_compile_fix.patch
浏览文件 @
adf2b227
--- a/pppd/plugins/rp-pppoe/plugin.c
+++ b/pppd/plugins/rp-pppoe/plugin.c
@@ -46,10 +46,10 @@
static char const RCSID[] =
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
-#include <net/ethernet.h>
#include <net/if_arp.h>
#include <linux/ppp_defs.h>
#include <linux/if_pppox.h>
+#include <linux/if_ether.h>
#ifndef _ROOT_PATH
#define _ROOT_PATH ""
--- a/pppd/plugins/rp-pppoe/pppoe.h
+++ b/pppd/plugins/rp-pppoe/pppoe.h
@@ -86,17 +86,6 @@
typedef unsigned long UINT32_t;
@@ -48,11 +48,7 @@
#endif
#include <netinet/in.h>
/* Ugly header files on some Linux boxes... */
-#if defined(HAVE_LINUX_IF_H)
-#include <linux/if.h>
-#elif defined(HAVE_NET_IF_H)
#include <net/if.h>
-#endif
#ifdef HAVE_NET_IF_TYPES_H
#include <net/if_types.h>
@@ -80,22 +76,8 @@
typedef unsigned long UINT32_t;
#error Could not find a 32-bit integer type
#endif
-#ifdef HAVE_LINUX_IF_ETHER_H
-#include <linux/if_ether.h>
-#endif
-
#include <netinet/in.h>
-
-#ifdef HAVE_NETINET_IF_ETHER_H
-#include <sys/types.h>
-
...
...
@@ -28,21 +32,10 @@
-#include <netinet/if_ether.h>
-#endif
-#endif
-
+#include <net/ethernet.h>
/* Ethernet frame types according to RFC 2516 */
--- a/pppd/plugins/rp-pppoe/if.c
+++ b/pppd/plugins/rp-pppoe/if.c
@@ -31,7 +31,7 @@
static char const RCSID[] =
#endif
#ifdef HAVE_NET_ETHERNET_H
-#include <net/ethernet.h>
+#include <linux/if_ether.h>
#endif
#ifdef HAVE_ASM_TYPES_H
--- a/pppd/plugins/rp-pppoe/pppoe-discovery.c
+++ b/pppd/plugins/rp-pppoe/pppoe-discovery.c
@@ -16,6 +16,7 @@
...
...
@@ -53,18 +46,7 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -27,10 +28,6 @@
#include <linux/if_packet.h>
#endif
-#ifdef HAVE_NET_ETHERNET_H
-#include <net/ethernet.h>
-#endif
-
#ifdef HAVE_ASM_TYPES_H
#include <asm/types.h>
#endif
@@ -717,6 +714,23 @@
char *xstrdup(const char *s)
@@ -717,6 +718,23 @@
char *xstrdup(const char *s)
return ret;
}
...
...
package/network/services/ppp/patches/500-add-pptp-plugin.patch
浏览文件 @
adf2b227
...
...
@@ -1064,7 +1064,7 @@
+ struct in_addr localbind);
--- /dev/null
+++ b/pppd/plugins/pptp/pptp_ctrl.c
@@ -0,0 +1,107
8
@@
@@ -0,0 +1,107
7
@@
+/* pptp_ctrl.c ... handle PPTP control connection.
+ * C. Scott Ananian <cananian@alumni.princeton.edu>
+ *
...
...
@@ -1083,7 +1083,6 @@
+#include <string.h>
+#include <ctype.h>
+#include <fcntl.h>
+#include "pppd.h"
+#include "pptp_msg.h"
+#include "pptp_ctrl.h"
+#include "pptp_options.h"
...
...
package/network/services/ppp/patches/511-syncppp.patch
0 → 100644
浏览文件 @
adf2b227
diff -Naur ppp-2.4.5.0/pppd/chap-new.c ppp-2.4.5/pppd/chap-new.c
--- ppp-2.4.5.0/pppd/chap-new.c 2012-04-18 15:44:46.000000000 +0800
+++ ppp-2.4.5/pppd/chap-new.c 2012-04-19 20:24:28.000000000 +0800
@@ -37,6 +37,8 @@
#include "chap-new.h"
#include "chap-md5.h"
+#include "syncppp.h"
+
#ifdef CHAPMS
#include "chap_ms.h"
#define MDTYPE_ALL (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5)
@@ -481,6 +483,19 @@
p[2] = len >> 8;
p[3] = len;
+ if (npppd > 1) {
+ if (syncppp(npppd) < 0) {
+ error("syncppp sync fail");
+ sem_unlink(SEM_COUNT_NAME);
+ sem_unlink(SEM_BLOCK_NAME);
+ } else {
+ info("syncppp sync succeeded");
+ }
+ } else {
+ info("syncppp not active");
+ }
+
+
output(0, response, PPP_HDRLEN + len);
}
diff -Naur ppp-2.4.5.0/pppd/Makefile.linux ppp-2.4.5/pppd/Makefile.linux
--- ppp-2.4.5.0/pppd/Makefile.linux 2012-04-18 15:44:46.000000000 +0800
+++ ppp-2.4.5/pppd/Makefile.linux 2012-04-19 20:01:05.000000000 +0800
@@ -13,16 +13,16 @@
PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap-new.c md5.c ccp.c \
ecp.c ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c \
- demand.c utils.c tty.c eap.c chap-md5.c session.c
+ demand.c utils.c tty.c eap.c chap-md5.c session.c syncppp.c
HEADERS = ccp.h session.h chap-new.h ecp.h fsm.h ipcp.h \
ipxcp.h lcp.h magic.h md5.h patchlevel.h pathnames.h pppd.h \
- upap.h eap.h
+ upap.h eap.h syncppp.h
MANPAGES = pppd.8
PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap-new.o md5.o ccp.o \
ecp.o auth.o options.o demand.o utils.o sys-linux.o ipxcp.o tty.o \
- eap.o chap-md5.o session.o
+ eap.o chap-md5.o session.o syncppp.o
#
# include dependencies if present
@@ -33,7 +33,7 @@
# CC = gcc
#
COPTS = -O2 -pipe -Wall -g
-LIBS =
+LIBS = -lpthread
# Uncomment the next 2 lines to include support for Microsoft's
# MS-CHAP authentication protocol. Also, edit plugins/radius/Makefile.linux.
diff -Naur ppp-2.4.5.0/pppd/options.c ppp-2.4.5/pppd/options.c
--- ppp-2.4.5.0/pppd/options.c 2012-04-18 15:44:46.000000000 +0800
+++ ppp-2.4.5/pppd/options.c 2012-04-19 20:24:49.000000000 +0800
@@ -126,6 +126,7 @@
bool dryrun; /* print out option values and exit */
char *domain; /* domain name set by domain option */
int child_wait = 5; /* # seconds to wait for children at exit */
+int npppd = 0; /* synchronize between multiple pppd */
struct userenv *userenv_list; /* user environment variables */
#ifdef MAXOCTETS
@@ -311,6 +312,10 @@
"Set pathname of ipv6-down script",
OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
+ { "syncppp", o_int, &npppd,
+ "sync among multiple pppd when sending chap/pap respond", OPT_PRIO },
+
+
#ifdef HAVE_MULTILINK
{ "multilink", o_bool, &multilink,
"Enable multilink operation", OPT_PRIO | 1 },
diff -Naur ppp-2.4.5.0/pppd/pppd.h ppp-2.4.5/pppd/pppd.h
--- ppp-2.4.5.0/pppd/pppd.h 2012-04-18 15:44:46.000000000 +0800
+++ ppp-2.4.5/pppd/pppd.h 2012-04-19 20:25:02.000000000 +0800
@@ -327,6 +327,7 @@
extern bool dump_options; /* print out option values */
extern bool dryrun; /* check everything, print options, exit */
extern int child_wait; /* # seconds to wait for children at end */
+extern int npppd; /* synchronize between multiple pppd */
#ifdef MAXOCTETS
extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */
diff -Naur ppp-2.4.5.0/pppd/syncppp.c ppp-2.4.5/pppd/syncppp.c
--- ppp-2.4.5.0/pppd/syncppp.c 1970-01-01 08:00:00.000000000 +0800
+++ ppp-2.4.5/pppd/syncppp.c 2012-04-18 15:46:59.000000000 +0800
@@ -0,0 +1,75 @@
+#include<stdio.h>
+#include<semaphore.h>
+#include<fcntl.h>
+#include<stdlib.h>
+#include<time.h>
+#include<errno.h>
+#include "pppd.h"
+#include "syncppp.h"
+
+int syncppp(int nproc)
+{
+ int flags;
+ int value;
+ sem_t *block;
+ sem_t *count;
+ struct timespec ts;
+
+ if (nproc <= 1) {
+ error("syncppp: number of pppd should be larger than 1");
+ return -1;
+ }
+
+ if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
+ error("clock_gettime error");
+ return -1;
+ }
+ ts.tv_sec += SYNCPPP_TIMEOUT;
+
+
+ flags = O_RDWR | O_CREAT;
+ block = sem_open(SEM_BLOCK_NAME, flags, 0644, 0);
+ count = sem_open(SEM_COUNT_NAME, flags, 0644, 0);
+ if (block == SEM_FAILED || count == SEM_FAILED) {
+ error("syncppp: sem_open failed");
+ return -1;
+ }
+
+ if (sem_post(count) < 0) {
+ error("syncppp: sem_post failed");
+ return -1;
+ }
+ if (sem_getvalue(count, &value) < 0) {
+ error("syncppp: sem_getvalue failed");
+ return -1;
+ }
+ info("%d pppd have arrived, waiting for the left %d", value, nproc-value);
+ if (value >= nproc) {
+ while (nproc-1 > 0) {
+ if (sem_post(block) < 0) {
+ error("syncppp: sem_post failed");
+ return -1;
+ }
+ nproc--;
+ }
+ } else {
+ if (sem_timedwait(block, &ts) < 0) {
+ if (errno == ETIMEDOUT) {
+ error("syncppp: sem_timewait time out");
+ } else {
+ error("syncppp: sem_timewait error");
+ }
+ return -1;
+ }
+
+ }
+
+ sem_close(count);
+ sem_close(block);
+
+ sem_unlink(SEM_COUNT_NAME);
+ sem_unlink(SEM_BLOCK_NAME);
+
+ return 0;
+}
+
diff -Naur ppp-2.4.5.0/pppd/syncppp.h ppp-2.4.5/pppd/syncppp.h
--- ppp-2.4.5.0/pppd/syncppp.h 1970-01-01 08:00:00.000000000 +0800
+++ ppp-2.4.5/pppd/syncppp.h 2012-04-18 15:46:59.000000000 +0800
@@ -0,0 +1,3 @@
+#define SEM_BLOCK_NAME "block"
+#define SEM_COUNT_NAME "count"
+#define SYNCPPP_TIMEOUT 5
diff -Naur ppp-2.4.5.0/pppd/upap.c ppp-2.4.5/pppd/upap.c
--- ppp-2.4.5.0/pppd/upap.c 2012-04-18 15:44:46.000000000 +0800
+++ ppp-2.4.5/pppd/upap.c 2012-04-19 20:26:22.000000000 +0800
@@ -52,6 +52,8 @@
#include "pppd.h"
#include "upap.h"
+#include "syncppp.h"
+
static const char rcsid[] = RCSID;
static bool hide_password = 1;
@@ -568,6 +570,18 @@
PUTCHAR(u->us_passwdlen, outp);
BCOPY(u->us_passwd, outp, u->us_passwdlen);
+ if (npppd > 1) {
+ if (syncppp(npppd) < 0) {
+ error("syncppp sync fail");
+ sem_unlink(SEM_COUNT_NAME);
+ sem_unlink(SEM_BLOCK_NAME);
+ } else {
+ info("syncppp sync succeeded");
+ }
+ } else {
+ info("syncppp not active");
+ }
+
output(u->us_unit, outpacket_buf, outlen + PPP_HDRLEN);
TIMEOUT(upap_timeout, u, u->us_timeouttime);
package/network/services/ppp/patches/520-uniq.patch
浏览文件 @
adf2b227
...
...
@@ -147,7 +147,7 @@
strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam));
--- a/pppd/plugins/rp-pppoe/pppoe-discovery.c
+++ b/pppd/plugins/rp-pppoe/pppoe-discovery.c
@@ -34
4,7 +344
,7 @@
packetIsForMe(PPPoEConnection *conn, PPP
@@ -34
8,7 +348
,7 @@
packetIsForMe(PPPoEConnection *conn, PPP
if (memcmp(packet->ethHdr.h_dest, conn->myEth, ETH_ALEN)) return 0;
/* If we're not using the Host-Unique tag, then accept the packet */
...
...
@@ -156,7 +156,7 @@
parsePacket(packet, parseForHostUniq, &forMe);
return forMe;
@@ -47
0,16 +470
,12 @@
sendPADI(PPPoEConnection *conn)
@@ -47
4,16 +474
,12 @@
sendPADI(PPPoEConnection *conn)
cursor += namelen + TAG_HDR_SIZE;
/* If we're using Host-Uniq, copy it over */
...
...
@@ -179,7 +179,7 @@
}
packet.length = htons(plen);
@@ -64
1,7 +637
,7 @@
int main(int argc, char *argv[])
@@ -64
5,7 +641
,7 @@
int main(int argc, char *argv[])
memset(conn, 0, sizeof(PPPoEConnection));
...
...
@@ -188,7 +188,7 @@
switch(opt) {
case 'S':
conn->serviceName = xstrdup(optarg);
@@ -65
0,7 +646
,23 @@
int main(int argc, char *argv[])
@@ -65
4,7 +650
,23 @@
int main(int argc, char *argv[])
conn->acName = xstrdup(optarg);
break;
case 'U':
...
...
@@ -224,7 +224,7 @@
/* How do we access raw Ethernet devices? */
#undef USE_LINUX_PACKET
@@ -2
24,7 +226
,7 @@
typedef struct PPPoEConnectionStruct {
@@ -2
17,7 +219
,7 @@
typedef struct PPPoEConnectionStruct {
char *serviceName; /* Desired service name, if any */
char *acName; /* Desired AC name, if any */
int synchronous; /* Use synchronous PPP */
...
...
@@ -233,7 +233,7 @@
int printACNames; /* Just print AC names */
FILE *debugFile; /* Debug file for dumping packets */
int numPADOs; /* Number of PADO packets received */
@@ -2
80,6 +282
,33 @@
void pppoe_printpkt(PPPoEPacket *packet,
@@ -2
73,6 +275
,33 @@
void pppoe_printpkt(PPPoEPacket *packet,
void (*printer)(void *, char *, ...), void *arg);
void pppoe_log_packet(const char *prefix, PPPoEPacket *packet);
...
...
package/network/services/shellsync/Makefile
0 → 100644
浏览文件 @
adf2b227
include
$(TOPDIR)/rules.mk
PKG_NAME
:=
shellsync
PKG_VERSION
:=
0.2
PKG_RELEASE
:=
1
include
$(INCLUDE_DIR)/package.mk
define
Package/shellsync
CATEGORY
:=
Utilities
TITLE
:=
shellsync
DEPENDS
:=
+libpthread
endef
define
Build/Prepare
mkdir
-p
$(PKG_BUILD_DIR)
$(CP)
./src/*
$(PKG_BUILD_DIR)/
endef
define
Package/shellsync/description
A
tool
to
sync
different
shell
scripts.Based
on
syncppp
patch
by
morfast.
endef
define
Build/Compile
$(TARGET_CROSS)gcc
-pthread
-o
$(PKG_BUILD_DIR)/shellsync
$(PKG_BUILD_DIR)/shellsync.c
endef
define
Package/shellsync/install
$(INSTALL_DIR)
$(1)/usr/bin
$(INSTALL_BIN)
$(PKG_BUILD_DIR)/shellsync
$(1)/usr/bin
endef
$(eval
$(call
BuildPackage,shellsync))
package/network/services/shellsync/src/shellsync.c
0 → 100644
浏览文件 @
adf2b227
/*************************************************************************
> File Name: shellsync.c
> Author: GuoGuo
> Mail: gch981213@gmail.com
> Created Time: 2014年11月06日 星期四 19时15分30秒
************************************************************************/
#include<stdio.h>
#include<semaphore.h>
#include<fcntl.h>
#include<stdlib.h>
#include<time.h>
#include<errno.h>
#define SEM_BLOCK_NAME "SYNCSHELL_block"
#define SEM_COUNT_NAME "SYNCSHELL_count"
int
wait_timeout
;
int
sync_wait
(
int
nproc
)
{
int
flags
;
int
value
;
sem_t
*
block
;
sem_t
*
count
;
struct
timespec
ts
;
if
(
nproc
<=
1
)
{
printf
(
"sync_wait: number of processes should be larger than 1
\n
"
);
return
-
1
;
}
if
(
clock_gettime
(
CLOCK_REALTIME
,
&
ts
)
==
-
1
)
{
printf
(
"clock_gettime error
\n
"
);
return
-
1
;
}
ts
.
tv_sec
+=
wait_timeout
;
flags
=
O_RDWR
|
O_CREAT
;
block
=
sem_open
(
SEM_BLOCK_NAME
,
flags
,
0644
,
0
);
count
=
sem_open
(
SEM_COUNT_NAME
,
flags
,
0644
,
0
);
if
(
block
==
SEM_FAILED
||
count
==
SEM_FAILED
)
{
printf
(
"sync_wait: sem_open failed
\n
"
);
return
-
1
;
}
if
(
sem_post
(
count
)
<
0
)
{
printf
(
"sync_wait: sem_post failed
\n
"
);
return
-
1
;
}
if
(
sem_getvalue
(
count
,
&
value
)
<
0
)
{
printf
(
"sync_wait: sem_getvalue failed
\n
"
);
return
-
1
;
}
printf
(
"%d processes have arrived, waiting for the left %d
\n
"
,
value
,
nproc
-
value
);
if
(
value
>=
nproc
)
{
while
(
nproc
-
1
>
0
)
{
if
(
sem_post
(
block
)
<
0
)
{
printf
(
"sync_wait: sem_post failed
\n
"
);
return
-
1
;
}
nproc
--
;
}
}
else
{
if
(
sem_timedwait
(
block
,
&
ts
)
<
0
)
{
if
(
errno
==
ETIMEDOUT
)
{
printf
(
"sync_wait: sem_timewait time out
\n
"
);
}
else
{
printf
(
"sync_wait: sem_timewait error
\n
"
);
}
return
-
1
;
}
}
sem_close
(
count
);
sem_close
(
block
);
sem_unlink
(
SEM_COUNT_NAME
);
sem_unlink
(
SEM_BLOCK_NAME
);
return
0
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
3
)
{
printf
(
"Usage: shellsync <process num> <wait_timeout>
\n
"
);
}
else
{
int
proc_num
;
sscanf
(
argv
[
1
],
"%d"
,
&
proc_num
);
sscanf
(
argv
[
2
],
"%d"
,
&
wait_timeout
);
if
(
sync_wait
(
proc_num
)
<
0
)
{
printf
(
"Processes sync failed.
\n
"
);
sem_unlink
(
SEM_COUNT_NAME
);
sem_unlink
(
SEM_BLOCK_NAME
);
return
1
;
}
else
{
printf
(
"Processes sync succeed.
\n
"
);
return
0
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录