diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-11-22 08:56:40 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-11-22 08:56:40 +0300 |
commit | 81ca3923a29ea9b67f7291be23b210019546aa5f (patch) | |
tree | fcebf0d426665b4f06e01168f27cd8f9ab8c50d8 /accel-pppd/ppp | |
parent | 830c399cf126f6bf1e8dfa1ad919a3ce8e346c5d (diff) | |
download | accel-ppp-81ca3923a29ea9b67f7291be23b210019546aa5f.tar.gz accel-ppp-81ca3923a29ea9b67f7291be23b210019546aa5f.zip |
remove trailing whitespaces
Diffstat (limited to 'accel-pppd/ppp')
-rw-r--r-- | accel-pppd/ppp/ccp_mppe.c | 16 | ||||
-rw-r--r-- | accel-pppd/ppp/ipcp_opt_dns.c | 12 | ||||
-rw-r--r-- | accel-pppd/ppp/ipcp_opt_ipaddr.c | 20 | ||||
-rw-r--r-- | accel-pppd/ppp/ipcp_opt_wins.c | 12 | ||||
-rw-r--r-- | accel-pppd/ppp/ipv6cp_opt_intfid.c | 22 | ||||
-rw-r--r-- | accel-pppd/ppp/lcp_opt_accomp.c | 2 | ||||
-rw-r--r-- | accel-pppd/ppp/lcp_opt_magic.c | 2 | ||||
-rw-r--r-- | accel-pppd/ppp/lcp_opt_mru.c | 8 | ||||
-rw-r--r-- | accel-pppd/ppp/lcp_opt_pcomp.c | 2 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_auth.c | 32 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_auth.h | 2 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_ccp.c | 68 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_ccp.h | 2 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_fsm.c | 4 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_fsm.h | 2 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_ifcfg.c | 20 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_ipcp.c | 58 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_ipcp.h | 2 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_ipv6cp.c | 60 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_ipv6cp.h | 2 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_lcp.c | 48 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_lcp.h | 2 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_pd.c | 2 |
23 files changed, 200 insertions, 200 deletions
diff --git a/accel-pppd/ppp/ccp_mppe.c b/accel-pppd/ppp/ccp_mppe.c index 68b95a6..31bbad4 100644 --- a/accel-pppd/ppp/ccp_mppe.c +++ b/accel-pppd/ppp/ccp_mppe.c @@ -75,10 +75,10 @@ static struct ccp_option_t *mppe_init(struct ppp_ccp_t *ccp) mppe_opt->mppe = 1; else mppe_opt->mppe = -1; - + if (mppe == MPPE_REQUIRE || mppe == MPPE_PREFER) ccp->ld.passive = 0; - + if (mppe == MPPE_REQUIRE) ccp->ld.optional = 0; @@ -153,7 +153,7 @@ static int __mppe_send_conf_req(struct ppp_ccp_t *ccp, struct ccp_option_t *opt, opt32->hdr.id = CI_MPPE; opt32->hdr.len = 6; opt32->val = mppe_opt->mppe ? htonl(MPPE_S | MPPE_H) : 0; - + if (setup_key && mppe_opt->mppe && setup_mppe_key(ccp->ppp->unit_fd, 0, mppe_opt->recv_key)) return 0; @@ -189,7 +189,7 @@ static int mppe_recv_conf_req(struct ppp_ccp_t *ccp, struct ccp_option_t *opt, u return CCP_OPT_NAK; return CCP_OPT_ACK; } - + if (opt32->hdr.len != 6) return CCP_OPT_REJ; @@ -209,7 +209,7 @@ static int mppe_recv_conf_req(struct ppp_ccp_t *ccp, struct ccp_option_t *opt, u mppe_opt->mppe = 0; } else return CCP_OPT_REJ; - + if (mppe_opt->mppe) { if (setup_mppe_key(ccp->ppp->unit_fd, 1, mppe_opt->send_key)) return CCP_OPT_REJ; @@ -283,7 +283,7 @@ static void mppe_print(void (*print)(const char *fmt,...),struct ccp_option_t *o bits & MPPE_S ? "+" : "-", bits & MPPE_L ? "+" : "-", bits & MPPE_D ? "+" : "-", - bits & MPPE_C ? "+" : "-" + bits & MPPE_C ? "+" : "-" ); } @@ -304,7 +304,7 @@ static void ev_mppe_keys(struct ev_mppe_keys_t *ev) mppe_opt->mppe = 0; return; } - + if (ccp->ppp->ses.ctrl->mppe == MPPE_UNSET) mppe = conf_mppe; else @@ -348,7 +348,7 @@ static void mppe_opt_init() { ccp_option_register(&mppe_opt_hnd); triton_event_register_handler(EV_MPPE_KEYS, (triton_event_func)ev_mppe_keys); - + load_config(); triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config); } diff --git a/accel-pppd/ppp/ipcp_opt_dns.c b/accel-pppd/ppp/ipcp_opt_dns.c index bd5114a..f402844 100644 --- a/accel-pppd/ppp/ipcp_opt_dns.c +++ b/accel-pppd/ppp/ipcp_opt_dns.c @@ -109,7 +109,7 @@ static int dns_recv_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, if (dns_opt->addr == opt32->val) return IPCP_OPT_ACK; - + return IPCP_OPT_NAK; } @@ -123,7 +123,7 @@ static void dns1_print(void (*print)(const char *fmt, ...), struct ipcp_option_t in.s_addr = opt32->val; else in.s_addr = dns_opt->addr; - + print("<dns1 %s>", inet_ntoa(in)); } @@ -137,7 +137,7 @@ static void dns2_print(void (*print)(const char *fmt, ...), struct ipcp_option_t in.s_addr = opt32->val; else in.s_addr = dns_opt->addr; - + print("<dns2 %s>", inet_ntoa(in)); } @@ -148,7 +148,7 @@ static void ev_dns(struct ev_dns_t *ev) if (!ev->ses->ctrl->ppp) return; - + ppp = container_of(ev->ses, typeof(*ppp), ses); dns_opt = container_of(ipcp_find_option(ppp, &dns1_opt_hnd), typeof(*dns_opt), opt); @@ -161,11 +161,11 @@ static void ev_dns(struct ev_dns_t *ev) static void load_config(void) { char *opt; - + opt = conf_get_opt("dns", "dns1"); if (opt) conf_dns1 = inet_addr(opt); - + opt = conf_get_opt("dns", "dns2"); if (opt) conf_dns2 = inet_addr(opt); diff --git a/accel-pppd/ppp/ipcp_opt_ipaddr.c b/accel-pppd/ppp/ipcp_opt_ipaddr.c index 8a77848..7bac55b 100644 --- a/accel-pppd/ppp/ipcp_opt_ipaddr.c +++ b/accel-pppd/ppp/ipcp_opt_ipaddr.c @@ -86,19 +86,19 @@ static int alloc_ip(struct ppp_t *ppp) log_ppp_warn("ppp: no free IPv4 address\n"); return IPCP_OPT_CLOSE; } - + if (iprange_tunnel_check(ppp->ses.ipv4->peer_addr)) { log_ppp_warn("ppp:ipcp: to avoid kernel soft lockup requested IP cannot be assigned (%i.%i.%i.%i)\n", - ppp->ses.ipv4->peer_addr&0xff, - (ppp->ses.ipv4->peer_addr >> 8)&0xff, - (ppp->ses.ipv4->peer_addr >> 16)&0xff, + ppp->ses.ipv4->peer_addr&0xff, + (ppp->ses.ipv4->peer_addr >> 8)&0xff, + (ppp->ses.ipv4->peer_addr >> 16)&0xff, (ppp->ses.ipv4->peer_addr >> 24)&0xff); return IPCP_OPT_FAIL; } - + if (conf_check_exists && check_exists(ppp, ppp->ses.ipv4->peer_addr)) return IPCP_OPT_FAIL; - + return 0; } @@ -107,13 +107,13 @@ static int ipaddr_send_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *o struct ipaddr_option_t *ipaddr_opt = container_of(opt, typeof(*ipaddr_opt), opt); struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t *)ptr; int r; - + if (!ipcp->ppp->ses.ipv4) { r = alloc_ip(ipcp->ppp); if (r) return r; } - + opt32->hdr.id = CI_ADDR; opt32->hdr.len = 6; opt32->val = ipcp->ppp->ses.ipv4->addr; @@ -149,7 +149,7 @@ static int ipaddr_recv_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *o ipcp->delay_ack = ccp_ipcp_started(ipcp->ppp); return IPCP_OPT_ACK; } - + return IPCP_OPT_NAK; } @@ -163,7 +163,7 @@ static void ipaddr_print(void (*print)(const char *fmt,...),struct ipcp_option_t in.s_addr = opt32->val; else if (ipaddr_opt->ppp->ses.ipv4) in.s_addr = ipaddr_opt->ppp->ses.ipv4->addr; - + print("<addr %s>",inet_ntoa(in)); } diff --git a/accel-pppd/ppp/ipcp_opt_wins.c b/accel-pppd/ppp/ipcp_opt_wins.c index fd69a8c..c9a3bb5 100644 --- a/accel-pppd/ppp/ipcp_opt_wins.c +++ b/accel-pppd/ppp/ipcp_opt_wins.c @@ -109,7 +109,7 @@ static int wins_recv_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt if (wins_opt->addr == opt32->val) return IPCP_OPT_ACK; - + return IPCP_OPT_NAK; } @@ -123,7 +123,7 @@ static void wins1_print(void (*print)(const char *fmt, ...), struct ipcp_option_ in.s_addr = opt32->val; else in.s_addr = wins_opt->addr; - + print("<wins1 %s>", inet_ntoa(in)); } @@ -137,7 +137,7 @@ static void wins2_print(void (*print)(const char *fmt, ...), struct ipcp_option_ in.s_addr = opt32->val; else in.s_addr = wins_opt->addr; - + print("<wins2 %s>", inet_ntoa(in)); } @@ -145,7 +145,7 @@ static void ev_wins(struct ev_wins_t *ev) { struct wins_option_t *wins_opt; struct ppp_t *ppp; - + if (!ev->ses->ctrl->ppp) return; @@ -161,11 +161,11 @@ static void ev_wins(struct ev_wins_t *ev) static void load_config(void) { char *opt; - + opt = conf_get_opt("wins", "wins1"); if (opt) conf_wins1 = inet_addr(opt); - + opt = conf_get_opt("wins", "wins2"); if (opt) conf_wins2 = inet_addr(opt); diff --git a/accel-pppd/ppp/ipv6cp_opt_intfid.c b/accel-pppd/ppp/ipv6cp_opt_intfid.c index d2b8127..aa7afb6 100644 --- a/accel-pppd/ppp/ipv6cp_opt_intfid.c +++ b/accel-pppd/ppp/ipv6cp_opt_intfid.c @@ -159,7 +159,7 @@ static uint64_t generate_intf_id(struct ppp_t *ppp) return id; } - + static uint64_t generate_peer_intf_id(struct ppp_t *ppp) { char str[4]; @@ -168,7 +168,7 @@ static uint64_t generate_peer_intf_id(struct ppp_t *ppp) uint64_t intf_id; uint16_t addr16[4]; } u; - + switch (conf_peer_intf_id) { case INTF_ID_FIXED: return conf_peer_intf_id_val; @@ -204,10 +204,10 @@ static int alloc_ip(struct ppp_t *ppp) if (!ppp->ses.ipv6->intf_id) ppp->ses.ipv6->intf_id = generate_intf_id(ppp); - + if (conf_check_exists && check_exists(ppp)) return IPV6CP_OPT_FAIL; - + return 0; } @@ -216,13 +216,13 @@ static int ipaddr_send_conf_req(struct ppp_ipv6cp_t *ipv6cp, struct ipv6cp_optio struct ipaddr_option_t *ipaddr_opt = container_of(opt, typeof(*ipaddr_opt), opt); struct ipv6cp_opt64_t *opt64 = (struct ipv6cp_opt64_t *)ptr; int r; - + if (!ipv6cp->ppp->ses.ipv6) { r = alloc_ip(ipv6cp->ppp); if (r) return r; } - + opt64->hdr.id = CI_INTFID; opt64->hdr.len = 10; opt64->val = ipv6cp->ppp->ses.ipv6->intf_id; @@ -267,7 +267,7 @@ static int ipaddr_recv_conf_req(struct ppp_ipv6cp_t *ipv6cp, struct ipv6cp_optio ipaddr_opt->started = 1; return IPV6CP_OPT_ACK; } - + return IPV6CP_OPT_NAK; } @@ -281,7 +281,7 @@ static void ipaddr_print(void (*print)(const char *fmt,...), struct ipv6cp_optio *(uint64_t *)(a.s6_addr + 8) = opt64->val; else *(uint64_t *)(a.s6_addr + 8) = ipaddr_opt->ppp->ses.ipv6->intf_id; - + print("<addr %x:%x:%x:%x>", ntohs(a.s6_addr16[4]), ntohs(a.s6_addr16[5]), ntohs(a.s6_addr16[6]), ntohs(a.s6_addr16[7])); } @@ -297,7 +297,7 @@ static uint64_t parse_intfid(const char *opt) if (sscanf(opt, "%x:%x:%x:%x", &n[0], &n[1], &n[2], &n[3]) != 4) goto err; - + for (i = 0; i < 4; i++) { if (n[i] < 0 || n[i] > 0xffff) goto err; @@ -329,7 +329,7 @@ static void load_config(void) conf_intf_id_val = parse_intfid(opt); } } - + opt = conf_get_opt("ppp", "ipv6-peer-intf-id"); if (opt) { if (!strcmp(opt, "random")) @@ -343,7 +343,7 @@ static void load_config(void) conf_peer_intf_id_val = parse_intfid(opt); } } - + opt = conf_get_opt("ppp", "ipv6-accept-peer-intf-id"); if (opt) conf_accept_peer_intf_id = atoi(opt); diff --git a/accel-pppd/ppp/lcp_opt_accomp.c b/accel-pppd/ppp/lcp_opt_accomp.c index 7e60582..f55ed3c 100644 --- a/accel-pppd/ppp/lcp_opt_accomp.c +++ b/accel-pppd/ppp/lcp_opt_accomp.c @@ -138,7 +138,7 @@ static void accomp_print(void (*print)(const char *fmt, ...), struct lcp_option_ static void load_config(void) { char *opt; - + opt = conf_get_opt("ppp", "accomp"); if (opt) { if (!strcmp(opt, "deny")) diff --git a/accel-pppd/ppp/lcp_opt_magic.c b/accel-pppd/ppp/lcp_opt_magic.c index e2d9bad..52ed26e 100644 --- a/accel-pppd/ppp/lcp_opt_magic.c +++ b/accel-pppd/ppp/lcp_opt_magic.c @@ -71,7 +71,7 @@ static int magic_send_conf_req(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, { struct magic_option_t *magic_opt = container_of(opt, typeof(*magic_opt), opt); struct lcp_opt32_t *opt32 = (struct lcp_opt32_t *)ptr; - + if (!magic_opt->magic) return 0; diff --git a/accel-pppd/ppp/lcp_opt_mru.c b/accel-pppd/ppp/lcp_opt_mru.c index 1cd04f8..c944331 100644 --- a/accel-pppd/ppp/lcp_opt_mru.c +++ b/accel-pppd/ppp/lcp_opt_mru.c @@ -103,7 +103,7 @@ static int mru_recv_conf_req(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, ui /*if (!ptr) return LCP_OPT_NAK;*/ - + if (opt16->hdr.len != 4) return LCP_OPT_REJ; @@ -132,7 +132,7 @@ static int mru_recv_conf_ack(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, ui if (ioctl(sock_fd, SIOCSIFMTU, &ifr)) log_ppp_error("lcp:mru: failed to set MTU: %s\n", strerror(errno)); - + return 0; } @@ -169,11 +169,11 @@ static void load_config(void) opt = conf_get_opt("ppp", "min-mtu"); if (opt && atoi(opt) > 0) conf_min_mtu = atoi(opt); - + opt = conf_get_opt("ppp", "max-mtu"); if (opt && atoi(opt) > 0) conf_max_mtu = atoi(opt); - + if (conf_min_mtu > conf_mru) { log_emerg("min-mtu cann't be greater then mtu/mru\n"); conf_min_mtu = conf_mru; diff --git a/accel-pppd/ppp/lcp_opt_pcomp.c b/accel-pppd/ppp/lcp_opt_pcomp.c index e034622..28ca98f 100644 --- a/accel-pppd/ppp/lcp_opt_pcomp.c +++ b/accel-pppd/ppp/lcp_opt_pcomp.c @@ -138,7 +138,7 @@ static void pcomp_print(void (*print)(const char *fmt, ...), struct lcp_option_t static void load_config(void) { char *opt; - + opt = conf_get_opt("ppp", "pcomp"); if (opt) { if (!strcmp(opt, "deny")) diff --git a/accel-pppd/ppp/ppp_auth.c b/accel-pppd/ppp/ppp_auth.c index 442db7e..a387ba2 100644 --- a/accel-pppd/ppp/ppp_auth.c +++ b/accel-pppd/ppp/ppp_auth.c @@ -50,7 +50,7 @@ struct auth_layer_data_t struct ppp_t *ppp; }; -static struct lcp_option_handler_t auth_opt_hnd = +static struct lcp_option_handler_t auth_opt_hnd = { .init = auth_init, .send_conf_req = auth_send_conf_req, @@ -63,7 +63,7 @@ static struct lcp_option_handler_t auth_opt_hnd = .print = auth_print, }; -static struct ppp_layer_t auth_layer = +static struct ppp_layer_t auth_layer = { .init = auth_layer_init, .start = auth_layer_start, @@ -156,7 +156,7 @@ static int auth_recv_conf_req(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, u if (list_empty(&auth_opt->auth_list)) return LCP_OPT_REJ; - + if (!ptr) return LCP_OPT_ACK; @@ -172,7 +172,7 @@ static int auth_recv_conf_req(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, u return r; } } - + list_for_each_entry(d, &auth_opt->auth_list, entry) { if (d->state != LCP_OPT_NAK) { auth_opt->peer_auth = d; @@ -205,7 +205,7 @@ static int auth_recv_conf_nak(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, u auth_opt->auth->state = LCP_OPT_NAK; if (auth_opt->peer_auth) auth_opt->auth = auth_opt->peer_auth; - + list_for_each_entry(d, &auth_opt->auth_list, entry) { if (d->state != LCP_OPT_NAK) return 0; @@ -224,11 +224,11 @@ static int auth_recv_conf_rej(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, u log_ppp_error("auth: unexcepcted configure-reject\n"); return -1; } - + auth_opt->auth->state = LCP_OPT_NAK; if (auth_opt->peer_auth) auth_opt->auth = auth_opt->peer_auth; - + list_for_each_entry(d, &auth_opt->auth_list, entry) { if (d->state != LCP_OPT_NAK) return 0; @@ -266,7 +266,7 @@ static struct ppp_layer_data_t *auth_layer_init(struct ppp_t *ppp) struct auth_layer_data_t *ad = _malloc(sizeof(*ad)); log_ppp_debug("auth_layer_init\n"); - + memset(ad, 0, sizeof(*ad)); ad->ppp = ppp; @@ -277,9 +277,9 @@ static struct ppp_layer_data_t *auth_layer_init(struct ppp_t *ppp) static int auth_layer_start(struct ppp_layer_data_t *ld) { struct auth_layer_data_t *ad = container_of(ld,typeof(*ad),ld); - + log_ppp_debug("auth_layer_start\n"); - + if (ad->auth_opt.auth) { ad->auth_opt.started = 1; ad->auth_opt.auth->h->start(ad->ppp, ad->auth_opt.auth); @@ -287,19 +287,19 @@ static int auth_layer_start(struct ppp_layer_data_t *ld) log_ppp_debug("auth_layer_started\n"); ppp_layer_started(ad->ppp, ld); } - + return 0; } static void auth_layer_finish(struct ppp_layer_data_t *ld) { struct auth_layer_data_t *ad = container_of(ld, typeof(*ad), ld); - + log_ppp_debug("auth_layer_finish\n"); - + if (ad->auth_opt.auth) ad->auth_opt.auth->h->finish(ad->ppp, ad->auth_opt.auth); - + ad->auth_opt.started = 0; log_ppp_debug("auth_layer_finished\n"); @@ -375,10 +375,10 @@ int __export ppp_auth_restart(struct ppp_t *ppp) if (!ad->auth_opt.auth->h->restart) return -1; - + if (ad->auth_opt.auth->h->restart(ppp, ad->auth_opt.auth)) return -1; - + return 0; } diff --git a/accel-pppd/ppp/ppp_auth.h b/accel-pppd/ppp/ppp_auth.h index af98262..5049fd5 100644 --- a/accel-pppd/ppp/ppp_auth.h +++ b/accel-pppd/ppp/ppp_auth.h @@ -9,7 +9,7 @@ struct auth_data_t { struct list_head entry; int proto; - int state; + int state; struct ppp_auth_handler_t *h; }; diff --git a/accel-pppd/ppp/ppp_ccp.c b/accel-pppd/ppp/ppp_ccp.c index ad6e37e..ceaccee 100644 --- a/accel-pppd/ppp/ppp_ccp.c +++ b/accel-pppd/ppp/ppp_ccp.c @@ -79,7 +79,7 @@ static int ccp_set_flags(int fd, int isopen, int isup) log_ppp_error("ccp: failed to get flags: %s\n", strerror(errno)); return -1; } - + flags &= ~(SC_CCP_OPEN | SC_CCP_UP); flags |= (isopen ? SC_CCP_OPEN : 0) | (isup ? SC_CCP_UP : 0); @@ -87,7 +87,7 @@ static int ccp_set_flags(int fd, int isopen, int isup) log_ppp_error("ccp: failed to set flags: %s\n", strerror(errno)); return -1; } - + return 0; } @@ -95,24 +95,24 @@ static struct ppp_layer_data_t *ccp_layer_init(struct ppp_t *ppp) { struct ppp_ccp_t *ccp = _malloc(sizeof(*ccp)); memset(ccp, 0, sizeof(*ccp)); - + log_ppp_debug("ccp_layer_init\n"); ccp->ppp = ppp; ccp->fsm.ppp = ppp; - + ccp->hnd.proto = PPP_CCP; ccp->hnd.recv = ccp_recv; ccp->hnd.recv_proto_rej = ccp_recv_proto_rej; - + ppp_register_unit_handler(ppp, &ccp->hnd); - + ccp->ld.passive = 1; ccp->ld.optional = 1; INIT_LIST_HEAD(&ccp->options); ccp_options_init(ccp); - + ccp->fsm.proto = PPP_CCP; ppp_fsm_init(&ccp->fsm); @@ -136,7 +136,7 @@ static struct ppp_layer_data_t *ccp_layer_init(struct ppp_t *ppp) int ccp_layer_start(struct ppp_layer_data_t *ld) { struct ppp_ccp_t *ccp = container_of(ld, typeof(*ccp), ld); - + log_ppp_debug("ccp_layer_start\n"); ccp_set_flags(ccp->ppp->unit_fd, 0, 0); @@ -154,21 +154,21 @@ int ccp_layer_start(struct ppp_layer_data_t *ld) if (ppp_fsm_open(&ccp->fsm)) return -1; } - + if (ccp_set_flags(ccp->ppp->unit_fd, 1, 0)) { ppp_fsm_close(&ccp->fsm); return -1; } - + return 0; } void ccp_layer_finish(struct ppp_layer_data_t *ld) { struct ppp_ccp_t *ccp = container_of(ld, typeof(*ccp), ld); - + log_ppp_debug("ccp_layer_finish\n"); - + ccp_set_flags(ccp->ppp->unit_fd, 0, 0); ccp->fsm.fsm_state = FSM_Closed; @@ -180,7 +180,7 @@ void ccp_layer_finish(struct ppp_layer_data_t *ld) void ccp_layer_free(struct ppp_layer_data_t *ld) { struct ppp_ccp_t *ccp = container_of(ld, typeof(*ccp), ld); - + log_ppp_debug("ccp_layer_free\n"); ppp_unregister_handler(ccp->ppp, &ccp->hnd); @@ -215,7 +215,7 @@ static void ccp_layer_finished(struct ppp_fsm_t *fsm) ppp_layer_passive(ccp->ppp, &ccp->ld); else if (!ccp->ppp->ses.terminating) ap_session_terminate(&ccp->ppp->ses, TERM_USER_ERROR, 0); - + fsm->fsm_state = FSM_Closed; } @@ -258,12 +258,12 @@ static int send_conf_req(struct ppp_fsm_t *fsm) ccp_hdr->code = CONFREQ; ccp_hdr->id = ccp->fsm.id; ccp_hdr->len = 0; - + ptr = (uint8_t*)(ccp_hdr + 1); if (conf_ppp_verbose) log_ppp_info2("send [CCP ConfReq id=%x", ccp_hdr->id); - + list_for_each_entry(lopt, &ccp->options, entry) { n = lopt->h->send_conf_req(ccp, lopt, ptr); if (n < 0) @@ -276,10 +276,10 @@ static int send_conf_req(struct ppp_fsm_t *fsm) } ptr += n; } - + if (conf_ppp_verbose) log_ppp_info2("]\n"); - + ccp_hdr->len = htons(ptr - buf - 2); ppp_unit_send(ccp->ppp, ccp_hdr, ptr - buf); @@ -315,7 +315,7 @@ static void send_conf_nak(struct ppp_fsm_t *fsm) ccp_hdr->code = CONFNAK; ccp_hdr->id = ccp->fsm.recv_id; ccp_hdr->len = 0; - + ptr += sizeof(*ccp_hdr); list_for_each_entry(lopt, &ccp->options, entry) { @@ -327,7 +327,7 @@ static void send_conf_nak(struct ppp_fsm_t *fsm) ptr += lopt->h->send_conf_nak(ccp, lopt, ptr); } } - + if (conf_ppp_verbose) log_ppp_info2("]\n"); @@ -394,7 +394,7 @@ static int ccp_recv_conf_req(struct ppp_ccp_t *ccp, uint8_t *data, int size) ropt = _malloc(sizeof(*ropt)); memset(ropt, 0, sizeof(*ropt)); - + ropt->hdr = hdr; ropt->len = hdr->len; ropt->state = CCP_OPT_NONE; @@ -403,7 +403,7 @@ static int ccp_recv_conf_req(struct ppp_ccp_t *ccp, uint8_t *data, int size) data += hdr->len; size -= hdr->len; } - + if (conf_ppp_verbose) log_ppp_info2("recv [CCP ConfReq id=%x", ccp->fsm.recv_id); @@ -483,7 +483,7 @@ static int ccp_recv_conf_rej(struct ppp_ccp_t *ccp, uint8_t *data, int size) while (size > 0) { hdr = (struct ccp_opt_hdr_t *)data; - + if (!hdr->len || hdr->len > size) break; @@ -524,7 +524,7 @@ static int ccp_recv_conf_nak(struct ppp_ccp_t *ccp, uint8_t *data, int size) while (size > 0) { hdr = (struct ccp_opt_hdr_t *)data; - + if (!hdr->len || hdr->len > size) break; @@ -567,7 +567,7 @@ static int ccp_recv_conf_ack(struct ppp_ccp_t *ccp, uint8_t *data, int size) while (size > 0) { hdr = (struct ccp_opt_hdr_t *)data; - + if (!hdr->len || hdr->len > size) break; @@ -656,9 +656,9 @@ static void ccp_recv(struct ppp_handler_t*h) return; ccp->fsm.recv_id = hdr->id; - + switch(hdr->code) { - case CONFREQ: + case CONFREQ: r = ccp_recv_conf_req(ccp, (uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN); if (ccp->ld.passive) { ccp->ld.passive = 0; @@ -684,7 +684,7 @@ static void ccp_recv(struct ppp_handler_t*h) } } ccp_free_conf_req(ccp); - + if (r == CCP_OPT_FAIL) ap_session_terminate(&ccp->ppp->ses, TERM_USER_ERROR, 0); break; @@ -738,7 +738,7 @@ static void ccp_recv_proto_rej(struct ppp_handler_t *h) if (ccp->fsm.fsm_state == FSM_Initial || ccp->fsm.fsm_state == FSM_Closed) return; - + ppp_fsm_lower_down(&ccp->fsm); ppp_fsm_close(&ccp->fsm); } @@ -748,9 +748,9 @@ int ccp_option_register(struct ccp_option_handler_t *h) /*struct ccp_option_drv_t *p; list_for_each_entry(p,option_drv_list,entry) - if (p->id==h->id) + if (p->id==h->id) return -1;*/ - + list_add_tail(&h->entry,&option_handlers); return 0; @@ -764,11 +764,11 @@ struct ccp_option_t *ccp_find_option(struct ppp_t *ppp, struct ccp_option_handle { struct ppp_ccp_t *ccp = container_of(ppp_find_layer_data(ppp, &ccp_layer), typeof(*ccp), ld); struct ccp_option_t *opt; - + list_for_each_entry(opt, &ccp->options, entry) if (opt->h == h) return opt; - + log_emerg("ccp: BUG: option not found\n"); abort(); } @@ -795,7 +795,7 @@ static void load_config(void) opt = conf_get_opt("ppp", "ccp"); if (opt && atoi(opt) >= 0) conf_ccp = atoi(opt); - + opt = conf_get_opt("ppp", "ccp-max-configure"); if (opt && atoi(opt) > 0) conf_ccp_max_configure = atoi(opt); diff --git a/accel-pppd/ppp/ppp_ccp.h b/accel-pppd/ppp/ppp_ccp.h index acc56ff..cb5b164 100644 --- a/accel-pppd/ppp/ppp_ccp.h +++ b/accel-pppd/ppp/ppp_ccp.h @@ -82,7 +82,7 @@ struct ppp_ccp_t struct list_head ropt_list; // last received ConfReq int ropt_len; - + int conf_req_len; int starting:1; int started:1; diff --git a/accel-pppd/ppp/ppp_fsm.c b/accel-pppd/ppp/ppp_fsm.c index b0331d9..bb45d5c 100644 --- a/accel-pppd/ppp/ppp_fsm.c +++ b/accel-pppd/ppp/ppp_fsm.c @@ -54,7 +54,7 @@ int ppp_fsm_lower_up(struct ppp_fsm_t *layer) //if (layer->init_req_cnt) layer->init_req_cnt(layer); init_req_counter(layer,layer->max_configure); --layer->restart_counter; - if (layer->send_conf_req) + if (layer->send_conf_req) if (layer->send_conf_req(layer)) return -1; layer->fsm_state=FSM_Req_Sent; @@ -509,7 +509,7 @@ static void init_req_counter(struct ppp_fsm_t *layer,int timeout) static void zero_req_counter(struct ppp_fsm_t *layer) { layer->restart_counter=0; - + if (!layer->restart_timer.tpd) triton_timer_add(layer->ppp->ses.ctrl->ctx, &layer->restart_timer, 0); } diff --git a/accel-pppd/ppp/ppp_fsm.h b/accel-pppd/ppp/ppp_fsm.h index 95da7b6..57abb86 100644 --- a/accel-pppd/ppp/ppp_fsm.h +++ b/accel-pppd/ppp/ppp_fsm.h @@ -25,7 +25,7 @@ struct ppp_fsm_t struct ppp_t *ppp; FSM_STATE fsm_state; uint16_t proto; - + struct triton_timer_t restart_timer; int restart_counter; int max_terminate; diff --git a/accel-pppd/ppp/ppp_ifcfg.c b/accel-pppd/ppp/ppp_ifcfg.c index aa2aff7..f6eba06 100644 --- a/accel-pppd/ppp/ppp_ifcfg.c +++ b/accel-pppd/ppp/ppp_ifcfg.c @@ -21,7 +21,7 @@ struct in6_ifreq { struct in6_addr ifr6_addr; __u32 ifr6_prefixlen; - int ifr6_ifindex; + int ifr6_ifindex; }; static void devconf(struct ppp_t *ppp, const char *attr, const char *val) @@ -58,7 +58,7 @@ void ppp_ifup(struct ppp_t *ppp) struct in6_ifreq ifr6; struct npioctl np; struct sockaddr_in addr; - + triton_event_fire(EV_SES_ACCT_START, ppp); if (ppp->stop_time) return; @@ -69,19 +69,19 @@ void ppp_ifup(struct ppp_t *ppp) memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, ppp->ifname); - + if (ppp->ses.ipv4) { memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_addr.s_addr = ppp->ses.ipv4->addr; memcpy(&ifr.ifr_addr,&addr,sizeof(addr)); - + if (ioctl(sock_fd, SIOCSIFADDR, &ifr)) log_ppp_error("ppp: failed to set IPv4 address: %s\n", strerror(errno)); - + addr.sin_addr.s_addr = ppp->ses.ipv4->peer_addr; memcpy(&ifr.ifr_dstaddr,&addr,sizeof(addr)); - + if (ioctl(sock_fd, SIOCSIFDSTADDR, &ifr)) log_ppp_error("ppp: failed to set peer IPv4 address: %s\n", strerror(errno)); } @@ -99,7 +99,7 @@ void ppp_ifup(struct ppp_t *ppp) if (ioctl(sock6_fd, SIOCSIFADDR, &ifr6)) log_ppp_error("ppp: failed to set LL IPv6 address: %s\n", strerror(errno)); - + list_for_each_entry(a, &ppp->ses.ipv6->addr_list, entry) { if (a->prefix_len == 128) continue; @@ -127,7 +127,7 @@ void ppp_ifup(struct ppp_t *ppp) if (ioctl(ppp->unit_fd, PPPIOCSNPMODE, &np)) log_ppp_error("ppp: failed to set NP (IPv4) mode: %s\n", strerror(errno)); } - + if (ppp->ses.ipv6) { np.protocol = PPP_IPV6; np.mode = NPMODE_PASS; @@ -135,7 +135,7 @@ void ppp_ifup(struct ppp_t *ppp) if (ioctl(ppp->unit_fd, PPPIOCSNPMODE, &np)) log_ppp_error("ppp: failed to set NP (IPv6) mode: %s\n", strerror(errno)); } - + ppp->ses.ctrl->started(ppp); triton_event_fire(EV_SES_STARTED, ppp); @@ -167,7 +167,7 @@ void __export ppp_ifdown(struct ppp_t *ppp) ifr6.ifr6_ifindex = ppp->ifindex; ioctl(sock6_fd, SIOCDIFADDR, &ifr6); - + list_for_each_entry(a, &ppp->ses.ipv6->addr_list, entry) { if (a->prefix_len == 128) continue; diff --git a/accel-pppd/ppp/ppp_ipcp.c b/accel-pppd/ppp/ppp_ipcp.c index 6cb86a4..416fba9 100644 --- a/accel-pppd/ppp/ppp_ipcp.c +++ b/accel-pppd/ppp/ppp_ipcp.c @@ -54,7 +54,7 @@ static void ipcp_options_init(struct ppp_ipcp_t *ipcp) struct ipcp_option_handler_t *h; ipcp->conf_req_len = sizeof(struct ipcp_hdr_t); - + list_for_each_entry(h,&option_handlers,entry) { lopt = h->init(ipcp); if (lopt) { @@ -80,16 +80,16 @@ static struct ppp_layer_data_t *ipcp_layer_init(struct ppp_t *ppp) { struct ppp_ipcp_t *ipcp = _malloc(sizeof(*ipcp)); memset(ipcp, 0, sizeof(*ipcp)); - + log_ppp_debug("ipcp_layer_init\n"); ipcp->ppp = ppp; ipcp->fsm.ppp = ppp; - + ipcp->hnd.proto = PPP_IPCP; ipcp->hnd.recv = ipcp_recv; ipcp->hnd.recv_proto_rej = ipcp_recv_proto_rej; - + ppp_register_unit_handler(ppp, &ipcp->hnd); INIT_LIST_HEAD(&ipcp->options); @@ -111,7 +111,7 @@ static struct ppp_layer_data_t *ipcp_layer_init(struct ppp_t *ppp) INIT_LIST_HEAD(&ipcp->ropt_list); ipcp->ld.passive = conf_ipv4 == IPV4_ALLOW || conf_ipv4 == IPV4_DENY; - + return &ipcp->ld; } @@ -128,7 +128,7 @@ static void ipcp_start_timeout(struct triton_timer_t *t) int ipcp_layer_start(struct ppp_layer_data_t *ld) { struct ppp_ipcp_t *ipcp = container_of(ld, typeof(*ipcp), ld); - + log_ppp_debug("ipcp_layer_start\n"); ipcp->starting = 1; @@ -144,18 +144,18 @@ int ipcp_layer_start(struct ppp_layer_data_t *ld) return -1; } } - + return 0; } void ipcp_layer_finish(struct ppp_layer_data_t *ld) { struct ppp_ipcp_t *ipcp = container_of(ld, typeof(*ipcp), ld); - + log_ppp_debug("ipcp_layer_finish\n"); ipcp->fsm.fsm_state = FSM_Closed; - + log_ppp_debug("ipcp_layer_finished\n"); ppp_layer_finished(ipcp->ppp, &ipcp->ld); } @@ -163,9 +163,9 @@ void ipcp_layer_finish(struct ppp_layer_data_t *ld) void ipcp_layer_free(struct ppp_layer_data_t *ld) { struct ppp_ipcp_t *ipcp = container_of(ld, typeof(*ipcp), ld); - + log_ppp_debug("ipcp_layer_free\n"); - + ppp_unregister_handler(ipcp->ppp, &ipcp->hnd); ipcp_options_free(ipcp); ppp_fsm_free(&ipcp->fsm); @@ -189,7 +189,7 @@ static void __ipcp_layer_up(struct ppp_ipcp_t *ipcp) static void ipcp_layer_up(struct ppp_fsm_t *fsm) { struct ppp_ipcp_t *ipcp = container_of(fsm, typeof(*ipcp), fsm); - + if (!ipcp->delay_ack) __ipcp_layer_up(ipcp); } @@ -207,7 +207,7 @@ static void ipcp_layer_finished(struct ppp_fsm_t *fsm) ppp_layer_passive(ipcp->ppp, &ipcp->ld); } else if (!ipcp->ppp->ses.terminating) ap_session_terminate(&ipcp->ppp->ses, TERM_USER_ERROR, 0); - + fsm->fsm_state = FSM_Closed; } @@ -244,7 +244,7 @@ static int send_conf_req(struct ppp_fsm_t *fsm) ipcp_hdr->code = CONFREQ; ipcp_hdr->id = ipcp->fsm.id; ipcp_hdr->len = 0; - + ptr += sizeof(*ipcp_hdr); list_for_each_entry(lopt, &ipcp->options, entry) { @@ -318,7 +318,7 @@ static void send_conf_nak(struct ppp_fsm_t *fsm) ipcp_hdr->code = CONFNAK; ipcp_hdr->id = ipcp->fsm.recv_id; ipcp_hdr->len = 0; - + ptr += sizeof(*ipcp_hdr); list_for_each_entry(ropt, &ipcp->ropt_list, entry) { @@ -331,7 +331,7 @@ static void send_conf_nak(struct ppp_fsm_t *fsm) } } } - + if (conf_ppp_verbose) log_ppp_info2("]\n"); @@ -407,7 +407,7 @@ static int ipcp_recv_conf_req(struct ppp_ipcp_t *ipcp, uint8_t *data, int size) data += hdr->len; size -= hdr->len; } - + list_for_each_entry(lopt, &ipcp->options, entry) lopt->state=IPCP_OPT_NONE; @@ -454,7 +454,7 @@ static int ipcp_recv_conf_req(struct ppp_ipcp_t *ipcp, uint8_t *data, int size) if (r < ret) ret = r; break; - } + } } if (!ropt->lopt) { ropt->state = IPCP_OPT_REJ; @@ -504,7 +504,7 @@ static int ipcp_recv_conf_rej(struct ppp_ipcp_t *ipcp, uint8_t *data, int size) while (size > 0) { hdr = (struct ipcp_opt_hdr_t *)data; - + if (!hdr->len || hdr->len > size) break; @@ -545,7 +545,7 @@ static int ipcp_recv_conf_nak(struct ppp_ipcp_t *ipcp, uint8_t *data, int size) while (size > 0) { hdr = (struct ipcp_opt_hdr_t *)data; - + if (!hdr->len || hdr->len > size) break; @@ -588,7 +588,7 @@ static int ipcp_recv_conf_ack(struct ppp_ipcp_t *ipcp, uint8_t *data, int size) while (size > 0) { hdr = (struct ipcp_opt_hdr_t *)data; - + if (!hdr->len || hdr->len > size) break; @@ -644,7 +644,7 @@ static void send_term_ack(struct ppp_fsm_t *fsm) if (conf_ppp_verbose) log_ppp_info2("send [IPCP TermAck id=%x]\n", hdr.id); - + ppp_unit_send(ipcp->ppp, &hdr, 6); } @@ -675,12 +675,12 @@ static void ipcp_recv(struct ppp_handler_t*h) log_ppp_warn("IPCP: short packet received\n"); return; } - + if ((hdr->code == CONFACK || hdr->code == CONFNAK || hdr->code == CONFREJ) && hdr->id != ipcp->fsm.id) return; ipcp->fsm.recv_id = hdr->id; - + switch(hdr->code) { case CONFREQ: r = ipcp_recv_conf_req(ipcp,(uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN); @@ -763,7 +763,7 @@ static void ipcp_recv_proto_rej(struct ppp_handler_t*h) if (ipcp->fsm.fsm_state == FSM_Initial || ipcp->fsm.fsm_state == FSM_Closed) return; - + ppp_fsm_lower_down(&ipcp->fsm); ppp_fsm_close(&ipcp->fsm); } @@ -773,9 +773,9 @@ int ipcp_option_register(struct ipcp_option_handler_t *h) /*struct ipcp_option_drv_t *p; list_for_each_entry(p,option_drv_list,entry) - if (p->id==h->id) + if (p->id==h->id) return -1;*/ - + list_add_tail(&h->entry, &option_handlers); return 0; @@ -785,11 +785,11 @@ struct ipcp_option_t *ipcp_find_option(struct ppp_t *ppp, struct ipcp_option_han { struct ppp_ipcp_t *ipcp = container_of(ppp_find_layer_data(ppp, &ipcp_layer), typeof(*ipcp), ld); struct ipcp_option_t *opt; - + list_for_each_entry(opt, &ipcp->options, entry) if (opt->h == h) return opt; - + log_emerg("ipcp: BUG: option not found\n"); abort(); } diff --git a/accel-pppd/ppp/ppp_ipcp.h b/accel-pppd/ppp/ppp_ipcp.h index 7412702..a46d9b6 100644 --- a/accel-pppd/ppp/ppp_ipcp.h +++ b/accel-pppd/ppp/ppp_ipcp.h @@ -91,7 +91,7 @@ struct ppp_ipcp_t struct list_head ropt_list; // last received ConfReq int ropt_len; - + int conf_req_len; int starting:1; int started:1; diff --git a/accel-pppd/ppp/ppp_ipv6cp.c b/accel-pppd/ppp/ppp_ipv6cp.c index 9a87922..1194b31 100644 --- a/accel-pppd/ppp/ppp_ipv6cp.c +++ b/accel-pppd/ppp/ppp_ipv6cp.c @@ -54,7 +54,7 @@ static void ipv6cp_options_init(struct ppp_ipv6cp_t *ipv6cp) struct ipv6cp_option_handler_t *h; ipv6cp->conf_req_len = sizeof(struct ipv6cp_hdr_t); - + list_for_each_entry(h,&option_handlers,entry) { lopt = h->init(ipv6cp); if (lopt) { @@ -80,16 +80,16 @@ static struct ppp_layer_data_t *ipv6cp_layer_init(struct ppp_t *ppp) { struct ppp_ipv6cp_t *ipv6cp = _malloc(sizeof(*ipv6cp)); memset(ipv6cp, 0, sizeof(*ipv6cp)); - + log_ppp_debug("ipv6cp_layer_init\n"); ipv6cp->ppp = ppp; ipv6cp->fsm.ppp = ppp; - + ipv6cp->hnd.proto = PPP_IPV6CP; ipv6cp->hnd.recv = ipv6cp_recv; ipv6cp->hnd.recv_proto_rej = ipv6cp_recv_proto_rej; - + ppp_register_unit_handler(ppp, &ipv6cp->hnd); ipv6cp->fsm.proto = PPP_IPV6CP; @@ -109,7 +109,7 @@ static struct ppp_layer_data_t *ipv6cp_layer_init(struct ppp_t *ppp) INIT_LIST_HEAD(&ipv6cp->ropt_list); ipv6cp->ld.passive = conf_ipv6 == IPV6_ALLOW || conf_ipv6 == IPV6_DENY; - + return &ipv6cp->ld; } @@ -118,7 +118,7 @@ static void ipv6cp_start_timeout(struct triton_timer_t *t) struct ppp_ipv6cp_t *ipv6cp = container_of(t, typeof(*ipv6cp), timeout); triton_timer_del(t); - + if (ipv6cp->ppp->ses.state == AP_STATE_STARTING) ap_session_terminate(&ipv6cp->ppp->ses, TERM_USER_ERROR, 0); } @@ -126,7 +126,7 @@ static void ipv6cp_start_timeout(struct triton_timer_t *t) int ipv6cp_layer_start(struct ppp_layer_data_t *ld) { struct ppp_ipv6cp_t *ipv6cp = container_of(ld, typeof(*ipv6cp), ld); - + log_ppp_debug("ipv6cp_layer_start\n"); ipv6cp_options_init(ipv6cp); @@ -144,18 +144,18 @@ int ipv6cp_layer_start(struct ppp_layer_data_t *ld) return -1; } } - + return 0; } void ipv6cp_layer_finish(struct ppp_layer_data_t *ld) { struct ppp_ipv6cp_t *ipv6cp = container_of(ld, typeof(*ipv6cp), ld); - + log_ppp_debug("ipv6cp_layer_finish\n"); ipv6cp->fsm.fsm_state = FSM_Closed; - + log_ppp_debug("ipv6cp_layer_finished\n"); ppp_layer_finished(ipv6cp->ppp, &ipv6cp->ld); } @@ -163,9 +163,9 @@ void ipv6cp_layer_finish(struct ppp_layer_data_t *ld) void ipv6cp_layer_free(struct ppp_layer_data_t *ld) { struct ppp_ipv6cp_t *ipv6cp = container_of(ld, typeof(*ipv6cp), ld); - + log_ppp_debug("ipv6cp_layer_free\n"); - + ppp_unregister_handler(ipv6cp->ppp, &ipv6cp->hnd); ipv6cp_options_free(ipv6cp); ppp_fsm_free(&ipv6cp->fsm); @@ -189,7 +189,7 @@ static void __ipv6cp_layer_up(struct ppp_ipv6cp_t *ipv6cp) static void ipv6cp_layer_up(struct ppp_fsm_t *fsm) { struct ppp_ipv6cp_t *ipv6cp = container_of(fsm, typeof(*ipv6cp), fsm); - + if (!ipv6cp->delay_ack) __ipv6cp_layer_up(ipv6cp); } @@ -207,7 +207,7 @@ static void ipv6cp_layer_finished(struct ppp_fsm_t *fsm) ppp_layer_passive(ipv6cp->ppp, &ipv6cp->ld); } else if (!ipv6cp->ppp->ses.terminating) ap_session_terminate(&ipv6cp->ppp->ses, TERM_USER_ERROR, 0); - + fsm->fsm_state = FSM_Closed; } @@ -244,7 +244,7 @@ static int send_conf_req(struct ppp_fsm_t *fsm) ipv6cp_hdr->code = CONFREQ; ipv6cp_hdr->id = ipv6cp->fsm.id; ipv6cp_hdr->len = 0; - + ptr += sizeof(*ipv6cp_hdr); list_for_each_entry(lopt, &ipv6cp->options, entry) { @@ -318,7 +318,7 @@ static void send_conf_nak(struct ppp_fsm_t *fsm) ipv6cp_hdr->code = CONFNAK; ipv6cp_hdr->id = ipv6cp->fsm.recv_id; ipv6cp_hdr->len = 0; - + ptr += sizeof(*ipv6cp_hdr); list_for_each_entry(ropt, &ipv6cp->ropt_list, entry) { @@ -331,7 +331,7 @@ static void send_conf_nak(struct ppp_fsm_t *fsm) } } } - + if (conf_ppp_verbose) log_ppp_info2("]\n"); @@ -407,7 +407,7 @@ static int ipv6cp_recv_conf_req(struct ppp_ipv6cp_t *ipv6cp, uint8_t *data, int data += hdr->len; size -= hdr->len; } - + list_for_each_entry(lopt, &ipv6cp->options, entry) lopt->state=IPV6CP_OPT_NONE; @@ -454,7 +454,7 @@ static int ipv6cp_recv_conf_req(struct ppp_ipv6cp_t *ipv6cp, uint8_t *data, int if (r < ret) ret = r; break; - } + } } if (!ropt->lopt) { ropt->state = IPV6CP_OPT_REJ; @@ -504,7 +504,7 @@ static int ipv6cp_recv_conf_rej(struct ppp_ipv6cp_t *ipv6cp, uint8_t *data, int while (size > 0) { hdr = (struct ipv6cp_opt_hdr_t *)data; - + if (!hdr->len || hdr->len > size) break; @@ -545,7 +545,7 @@ static int ipv6cp_recv_conf_nak(struct ppp_ipv6cp_t *ipv6cp, uint8_t *data, int while (size > 0) { hdr = (struct ipv6cp_opt_hdr_t *)data; - + if (!hdr->len || hdr->len > size) break; @@ -588,7 +588,7 @@ static int ipv6cp_recv_conf_ack(struct ppp_ipv6cp_t *ipv6cp, uint8_t *data, int while (size > 0) { hdr = (struct ipv6cp_opt_hdr_t *)data; - + if (!hdr->len || hdr->len > size) break; @@ -644,7 +644,7 @@ static void send_term_ack(struct ppp_fsm_t *fsm) if (conf_ppp_verbose) log_ppp_info2("send [IPV6CP TermAck id=%x]\n", hdr.id); - + ppp_unit_send(ipv6cp->ppp, &hdr, 6); } @@ -675,12 +675,12 @@ static void ipv6cp_recv(struct ppp_handler_t*h) log_ppp_warn("IPV6CP: short packet received\n"); return; } - + if ((hdr->code == CONFACK || hdr->code == CONFNAK || hdr->code == CONFREJ) && hdr->id != ipv6cp->fsm.id) return; ipv6cp->fsm.recv_id = hdr->id; - + switch(hdr->code) { case CONFREQ: r = ipv6cp_recv_conf_req(ipv6cp,(uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN); @@ -763,7 +763,7 @@ static void ipv6cp_recv_proto_rej(struct ppp_handler_t*h) if (ipv6cp->fsm.fsm_state == FSM_Initial || ipv6cp->fsm.fsm_state == FSM_Closed) return; - + ppp_fsm_lower_down(&ipv6cp->fsm); ppp_fsm_close(&ipv6cp->fsm); } @@ -773,9 +773,9 @@ int ipv6cp_option_register(struct ipv6cp_option_handler_t *h) /*struct ipv6cp_option_drv_t *p; list_for_each_entry(p,option_drv_list,entry) - if (p->id==h->id) + if (p->id==h->id) return -1;*/ - + list_add_tail(&h->entry, &option_handlers); return 0; @@ -785,11 +785,11 @@ struct ipv6cp_option_t *ipv6cp_find_option(struct ppp_t *ppp, struct ipv6cp_opti { struct ppp_ipv6cp_t *ipv6cp = container_of(ppp_find_layer_data(ppp, &ipv6cp_layer), typeof(*ipv6cp), ld); struct ipv6cp_option_t *opt; - + list_for_each_entry(opt, &ipv6cp->options, entry) if (opt->h == h) return opt; - + log_emerg("ipv6cp: BUG: option not found\n"); abort(); } diff --git a/accel-pppd/ppp/ppp_ipv6cp.h b/accel-pppd/ppp/ppp_ipv6cp.h index 6f67605..57bb73b 100644 --- a/accel-pppd/ppp/ppp_ipv6cp.h +++ b/accel-pppd/ppp/ppp_ipv6cp.h @@ -97,7 +97,7 @@ struct ppp_ipv6cp_t struct list_head ropt_list; // last received ConfReq int ropt_len; - + int conf_req_len; int starting:1; int started:1; diff --git a/accel-pppd/ppp/ppp_lcp.c b/accel-pppd/ppp/ppp_lcp.c index 3dd8708..2641cf3 100644 --- a/accel-pppd/ppp/ppp_lcp.c +++ b/accel-pppd/ppp/ppp_lcp.c @@ -80,15 +80,15 @@ static struct ppp_layer_data_t *lcp_layer_init(struct ppp_t *ppp) { struct ppp_lcp_t *lcp = _malloc(sizeof(*lcp)); memset(lcp, 0, sizeof(*lcp)); - + log_ppp_debug("lcp_layer_init\n"); lcp->ppp = ppp; lcp->fsm.ppp = ppp; - + lcp->hnd.proto = PPP_LCP; lcp->hnd.recv = lcp_recv; - + ppp_register_chan_handler(ppp, &lcp->hnd); lcp->fsm.proto = PPP_LCP; @@ -113,14 +113,14 @@ static struct ppp_layer_data_t *lcp_layer_init(struct ppp_t *ppp) int lcp_layer_start(struct ppp_layer_data_t *ld) { struct ppp_lcp_t *lcp = container_of(ld, typeof(*lcp), ld); - + log_ppp_debug("lcp_layer_start\n"); lcp_options_init(lcp); ppp_fsm_lower_up(&lcp->fsm); if (ppp_fsm_open(&lcp->fsm)) return -1; - + return 0; } @@ -132,7 +132,7 @@ static void _lcp_layer_finished(struct ppp_lcp_t *lcp) void lcp_layer_finish(struct ppp_layer_data_t *ld) { struct ppp_lcp_t *lcp = container_of(ld,typeof(*lcp),ld); - + log_ppp_debug("lcp_layer_finish\n"); if (lcp->started) { @@ -145,7 +145,7 @@ void lcp_layer_finish(struct ppp_layer_data_t *ld) void lcp_layer_free(struct ppp_layer_data_t *ld) { struct ppp_lcp_t *lcp = container_of(ld, typeof(*lcp), ld); - + log_ppp_debug("lcp_layer_free\n"); stop_echo(lcp); @@ -153,7 +153,7 @@ void lcp_layer_free(struct ppp_layer_data_t *ld) lcp_options_free(lcp); ppp_fsm_free(&lcp->fsm); triton_cancel_call(lcp->ppp->ses.ctrl->ctx, (triton_event_func)_lcp_layer_finished); - + _free(lcp); } @@ -219,7 +219,7 @@ static int send_conf_req(struct ppp_fsm_t *fsm) lcp_hdr->code = CONFREQ; lcp_hdr->id = lcp->fsm.id; lcp_hdr->len = 0; - + ptr += sizeof(*lcp_hdr); list_for_each_entry(lopt, &lcp->options, entry) { @@ -232,7 +232,7 @@ static int send_conf_req(struct ppp_fsm_t *fsm) } else lopt->print = 0; } - + if (conf_ppp_verbose) { log_ppp_info2("send [LCP ConfReq id=%x", lcp_hdr->id); list_for_each_entry(lopt,&lcp->options,entry) { @@ -293,13 +293,13 @@ static void send_conf_nak(struct ppp_fsm_t *fsm) lcp_hdr->code = CONFNAK; lcp_hdr->id = lcp->fsm.recv_id; lcp_hdr->len = 0; - + ptr += sizeof(*lcp_hdr); list_for_each_entry(lopt, &lcp->options, entry) { if (lopt->state == LCP_OPT_NAK) { n = lopt->h->send_conf_nak(lcp, lopt, ptr); - + if (conf_ppp_verbose && n) { log_ppp_info2(" "); lopt->h->print(log_ppp_info2, lopt, ptr); @@ -308,7 +308,7 @@ static void send_conf_nak(struct ppp_fsm_t *fsm) ptr += n; } } - + if (conf_ppp_verbose) log_ppp_info2("]\n"); @@ -385,7 +385,7 @@ static int lcp_recv_conf_req(struct ppp_lcp_t *lcp, uint8_t *data, int size) data += hdr->len; size -= hdr->len; } - + list_for_each_entry(lopt, &lcp->options, entry) lopt->state = LCP_OPT_NONE; @@ -465,7 +465,7 @@ static int lcp_recv_conf_rej(struct ppp_lcp_t *lcp, uint8_t *data, int size) if (!hdr->len || hdr->len > size) break; - + list_for_each_entry(lopt, &lcp->options, entry) { if (lopt->id == hdr->id) { if (conf_ppp_verbose) { @@ -510,7 +510,7 @@ static int lcp_recv_conf_nak(struct ppp_lcp_t *lcp, uint8_t *data, int size) if (!hdr->len || hdr->len > size) break; - + list_for_each_entry(lopt,&lcp->options,entry) { if (lopt->id == hdr->id) { if (conf_ppp_verbose) { @@ -553,7 +553,7 @@ static int lcp_recv_conf_ack(struct ppp_lcp_t *lcp, uint8_t *data, int size) if (!hdr->len || hdr->len > size) break; - + list_for_each_entry(lopt, &lcp->options, entry) { if (lopt->id == hdr->id) { if (conf_ppp_verbose) { @@ -730,7 +730,7 @@ static void send_term_ack(struct ppp_fsm_t *fsm) if (conf_ppp_verbose) log_ppp_info2("send [LCP TermAck id=%i]\n", hdr.id); - + ppp_chan_send(lcp->ppp, &hdr, 6); } @@ -761,13 +761,13 @@ static void lcp_recv(struct ppp_handler_t*h) struct ppp_lcp_t *lcp = container_of(h, typeof(*lcp), hnd); int r; char *term_msg; - + if (lcp->ppp->buf_size < PPP_HEADERLEN + 2) { log_ppp_warn("LCP: short packet received\n"); return; } - hdr = (struct lcp_hdr_t *)lcp->ppp->buf; + hdr = (struct lcp_hdr_t *)lcp->ppp->buf; if (ntohs(hdr->len) < PPP_HEADERLEN) { log_ppp_warn("LCP: short packet received\n"); return; @@ -775,7 +775,7 @@ static void lcp_recv(struct ppp_handler_t*h) if ((hdr->code == CONFACK || hdr->code == CONFNAK || hdr->code == CONFREJ) && hdr->id != lcp->fsm.id) return; - + if ((hdr->code == CONFACK || hdr->code == CONFNAK || hdr->code == CONFREJ) && lcp->started) return; @@ -887,9 +887,9 @@ int lcp_option_register(struct lcp_option_handler_t *h) /*struct lcp_option_drv_t *p; list_for_each_entry(p,option_drv_list,entry) - if (p->id==h->id) + if (p->id==h->id) return -1;*/ - + list_add_tail(&h->entry, &option_handlers); return 0; @@ -922,7 +922,7 @@ static void load_config(void) opt = conf_get_opt("ppp", "lcp-echo-failure"); if (opt && atoi(opt) >= 0) conf_echo_failure = atoi(opt); - + opt = conf_get_opt("ppp", "lcp-echo-timeout"); if (opt && atoi(opt) >= 0) conf_echo_timeout = atoi(opt); diff --git a/accel-pppd/ppp/ppp_lcp.h b/accel-pppd/ppp/ppp_lcp.h index 465f0e9..cfc8122 100644 --- a/accel-pppd/ppp/ppp_lcp.h +++ b/accel-pppd/ppp/ppp_lcp.h @@ -125,7 +125,7 @@ struct ppp_lcp_t struct list_head ropt_list; // last received ConfReq int ropt_len; - + int conf_req_len; int started:1; }; diff --git a/accel-pppd/ppp/ppp_pd.c b/accel-pppd/ppp/ppp_pd.c index f770208..c33ae96 100644 --- a/accel-pppd/ppp/ppp_pd.c +++ b/accel-pppd/ppp/ppp_pd.c @@ -9,6 +9,6 @@ int ppp_store_pd(struct ppp_t *ppp, pd_key_t key, void *data) list_for_each_entry(pd, &ppp->pd_list, entry) if (pd->key == key) return -1; - + } |