diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2013-01-24 23:58:56 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2013-01-24 23:58:56 +0400 |
commit | cf3de06a3346854d770ba147f081e3b22e93c1bc (patch) | |
tree | 0c1a138d292c140c2547361615bf556ff2b98f9f /accel-pppd/ppp | |
parent | 35b55103979145284d63bc1db4ebd6e9d6666b34 (diff) | |
download | accel-ppp-cf3de06a3346854d770ba147f081e3b22e93c1bc.tar.gz accel-ppp-cf3de06a3346854d770ba147f081e3b22e93c1bc.zip |
backport 1.7
* l2tp: Fix allocation checking when adding octets AVP
* cli, tcp: Fix non-NULL terminated string reception
* Fix va_end() missing calls
* chap-secrets: implemented encryption
* auth_pap: make messages like other auth modules
* cli: check xmit_buf is not null at enter to write function
* pppoe: implemented regular expression support
* chap-secrets: implemented encryption
* ippool: fixed initialization order
* optional shaper compiling
* ppp: dns/wins code cleanup
Diffstat (limited to 'accel-pppd/ppp')
-rw-r--r-- | accel-pppd/ppp/CMakeLists.txt | 1 | ||||
-rw-r--r-- | accel-pppd/ppp/ipcp_opt_dns.c | 111 | ||||
-rw-r--r-- | accel-pppd/ppp/ipcp_opt_wins.c | 60 |
3 files changed, 75 insertions, 97 deletions
diff --git a/accel-pppd/ppp/CMakeLists.txt b/accel-pppd/ppp/CMakeLists.txt index f4c0f04a..560f7759 100644 --- a/accel-pppd/ppp/CMakeLists.txt +++ b/accel-pppd/ppp/CMakeLists.txt @@ -11,6 +11,7 @@ SET(sources_c ppp_ipcp.c ipcp_opt_ipaddr.c ipcp_opt_dns.c + ipcp_opt_wins.c ppp_ccp.c ) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/accel-pppd/ppp/ipcp_opt_dns.c b/accel-pppd/ppp/ipcp_opt_dns.c index 245960c7..bd5114ac 100644 --- a/accel-pppd/ppp/ipcp_opt_dns.c +++ b/accel-pppd/ppp/ipcp_opt_dns.c @@ -19,8 +19,8 @@ static void dns_free(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt); static int dns_send_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, uint8_t *ptr); static int dns_send_conf_nak(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, uint8_t *ptr); static int dns_recv_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, uint8_t *ptr); -static void dns1_print(void (*print)(const char *fmt,...),struct ipcp_option_t*, uint8_t *ptr); -static void dns2_print(void (*print)(const char *fmt,...),struct ipcp_option_t*, uint8_t *ptr); +static void dns1_print(void (*print)(const char *fmt, ...), struct ipcp_option_t *, uint8_t *ptr); +static void dns2_print(void (*print)(const char *fmt, ...), struct ipcp_option_t *, uint8_t *ptr); struct dns_option_t { @@ -28,49 +28,53 @@ struct dns_option_t in_addr_t addr; }; -static struct ipcp_option_handler_t dns1_opt_hnd= +static struct ipcp_option_handler_t dns1_opt_hnd = { - .init=dns1_init, - .send_conf_req=dns_send_conf_req, - .send_conf_nak=dns_send_conf_nak, - .recv_conf_req=dns_recv_conf_req, - .free=dns_free, - .print=dns1_print, + .init = dns1_init, + .send_conf_req = dns_send_conf_req, + .send_conf_nak = dns_send_conf_nak, + .recv_conf_req = dns_recv_conf_req, + .free = dns_free, + .print = dns1_print, }; -static struct ipcp_option_handler_t dns2_opt_hnd= +static struct ipcp_option_handler_t dns2_opt_hnd = { - .init=dns2_init, - .send_conf_req=dns_send_conf_req, - .send_conf_nak=dns_send_conf_nak, - .recv_conf_req=dns_recv_conf_req, - .free=dns_free, - .print=dns2_print, + .init = dns2_init, + .send_conf_req = dns_send_conf_req, + .send_conf_nak = dns_send_conf_nak, + .recv_conf_req = dns_recv_conf_req, + .free = dns_free, + .print = dns2_print, }; static struct ipcp_option_t *dns1_init(struct ppp_ipcp_t *ipcp) { - struct dns_option_t *dns_opt=_malloc(sizeof(*dns_opt)); - memset(dns_opt,0,sizeof(*dns_opt)); - dns_opt->opt.id=CI_DNS1; - dns_opt->opt.len=6; + struct dns_option_t *dns_opt = _malloc(sizeof(*dns_opt)); + + memset(dns_opt, 0, sizeof(*dns_opt)); + dns_opt->opt.id = CI_DNS1; + dns_opt->opt.len = 6; + dns_opt->addr = conf_dns1; return &dns_opt->opt; } static struct ipcp_option_t *dns2_init(struct ppp_ipcp_t *ipcp) { - struct dns_option_t *dns_opt=_malloc(sizeof(*dns_opt)); - memset(dns_opt,0,sizeof(*dns_opt)); - dns_opt->opt.id=CI_DNS2; - dns_opt->opt.len=6; + struct dns_option_t *dns_opt = _malloc(sizeof(*dns_opt)); + + memset(dns_opt, 0, sizeof(*dns_opt)); + dns_opt->opt.id = CI_DNS2; + dns_opt->opt.len = 6; + dns_opt->addr = conf_dns2; return &dns_opt->opt; } static void dns_free(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt) { - struct dns_option_t *dns_opt=container_of(opt,typeof(*dns_opt),opt); + struct dns_option_t *dns_opt = container_of(opt, typeof(*dns_opt), opt); _free(dns_opt); } @@ -82,62 +86,59 @@ static int dns_send_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, static int dns_send_conf_nak(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, uint8_t *ptr) { - struct dns_option_t *dns_opt=container_of(opt,typeof(*dns_opt),opt); - struct ipcp_opt32_t *opt32=(struct ipcp_opt32_t*)ptr; - opt32->hdr.id=dns_opt->opt.id; - opt32->hdr.len=6; - opt32->val=dns_opt->addr; + struct dns_option_t *dns_opt = container_of(opt, typeof(*dns_opt), opt); + struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t *)ptr; + opt32->hdr.id = dns_opt->opt.id; + opt32->hdr.len = 6; + opt32->val = dns_opt->addr; return 6; } static int dns_recv_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, uint8_t *ptr) { - struct dns_option_t *dns_opt=container_of(opt,typeof(*dns_opt),opt); - struct ipcp_opt32_t *opt32=(struct ipcp_opt32_t*)ptr; + struct dns_option_t *dns_opt = container_of(opt, typeof(*dns_opt), opt); + struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t *)ptr; if (opt32->hdr.len != 6) return IPCP_OPT_REJ; - if (!dns_opt->addr) - { - if (dns_opt->opt.id == CI_DNS1 && conf_dns1) dns_opt->addr=conf_dns1; - else if (dns_opt->opt.id == CI_DNS2 && conf_dns2) dns_opt->addr=conf_dns2; - - if (!dns_opt->addr) - { - dns_opt->addr=opt32->val; - return IPCP_OPT_ACK; - } + if (!dns_opt->addr) { + dns_opt->addr = opt32->val; + return IPCP_OPT_ACK; } - if (dns_opt->addr==opt32->val) + if (dns_opt->addr == opt32->val) return IPCP_OPT_ACK; return IPCP_OPT_NAK; } -static void dns1_print(void (*print)(const char *fmt,...),struct ipcp_option_t *opt, uint8_t *ptr) +static void dns1_print(void (*print)(const char *fmt, ...), struct ipcp_option_t *opt, uint8_t *ptr) { - struct dns_option_t *dns_opt=container_of(opt,typeof(*dns_opt),opt); - struct ipcp_opt32_t *opt32=(struct ipcp_opt32_t*)ptr; + struct dns_option_t *dns_opt = container_of(opt, typeof(*dns_opt), opt); + struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t *)ptr; struct in_addr in; - if (ptr) in.s_addr=opt32->val; - else in.s_addr=dns_opt->addr; + if (ptr) + in.s_addr = opt32->val; + else + in.s_addr = dns_opt->addr; - print("<dns1 %s>",inet_ntoa(in)); + print("<dns1 %s>", inet_ntoa(in)); } -static void dns2_print(void (*print)(const char *fmt,...),struct ipcp_option_t *opt, uint8_t *ptr) +static void dns2_print(void (*print)(const char *fmt, ...), struct ipcp_option_t *opt, uint8_t *ptr) { - struct dns_option_t *dns_opt=container_of(opt,typeof(*dns_opt),opt); - struct ipcp_opt32_t *opt32=(struct ipcp_opt32_t*)ptr; + struct dns_option_t *dns_opt = container_of(opt, typeof(*dns_opt), opt); + struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t *)ptr; struct in_addr in; - if (ptr) in.s_addr=opt32->val; - else in.s_addr=dns_opt->addr; + if (ptr) + in.s_addr = opt32->val; + else + in.s_addr = dns_opt->addr; - print("<dns2 %s>",inet_ntoa(in)); + print("<dns2 %s>", inet_ntoa(in)); } static void ev_dns(struct ev_dns_t *ev) diff --git a/accel-pppd/ppp/ipcp_opt_wins.c b/accel-pppd/ppp/ipcp_opt_wins.c index f65b945f..fd69a8cf 100644 --- a/accel-pppd/ppp/ipcp_opt_wins.c +++ b/accel-pppd/ppp/ipcp_opt_wins.c @@ -19,33 +19,31 @@ static void wins_free(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt); static int wins_send_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, uint8_t *ptr); static int wins_send_conf_nak(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, uint8_t *ptr); static int wins_recv_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, uint8_t *ptr); -static int wins_recv_conf_rej(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, uint8_t *ptr); -static void wins1_print(void (*print)(const char *fmt,...), struct ipcp_option_t*, uint8_t *ptr); -static void wins2_print(void (*print)(const char *fmt,...), struct ipcp_option_t*, uint8_t *ptr); +static void wins1_print(void (*print)(const char *fmt, ...), struct ipcp_option_t *, uint8_t *ptr); +static void wins2_print(void (*print)(const char *fmt, ...), struct ipcp_option_t *, uint8_t *ptr); struct wins_option_t { struct ipcp_option_t opt; in_addr_t addr; - int rejected; }; -static struct ipcp_option_handler_t wins1_opt_hnd = { +static struct ipcp_option_handler_t wins1_opt_hnd = +{ .init = wins1_init, .send_conf_req = wins_send_conf_req, .send_conf_nak = wins_send_conf_nak, .recv_conf_req = wins_recv_conf_req, - .recv_conf_rej = wins_recv_conf_rej, .free = wins_free, .print = wins1_print, }; -static struct ipcp_option_handler_t wins2_opt_hnd = { +static struct ipcp_option_handler_t wins2_opt_hnd = +{ .init = wins2_init, .send_conf_req = wins_send_conf_req, .send_conf_nak = wins_send_conf_nak, .recv_conf_req = wins_recv_conf_req, - .recv_conf_rej = wins_recv_conf_rej, .free = wins_free, .print = wins2_print, }; @@ -53,9 +51,11 @@ static struct ipcp_option_handler_t wins2_opt_hnd = { static struct ipcp_option_t *wins1_init(struct ppp_ipcp_t *ipcp) { struct wins_option_t *wins_opt = _malloc(sizeof(*wins_opt)); + memset(wins_opt, 0, sizeof(*wins_opt)); wins_opt->opt.id = CI_WINS1; wins_opt->opt.len = 6; + wins_opt->addr = conf_wins1; return &wins_opt->opt; } @@ -63,33 +63,25 @@ static struct ipcp_option_t *wins1_init(struct ppp_ipcp_t *ipcp) static struct ipcp_option_t *wins2_init(struct ppp_ipcp_t *ipcp) { struct wins_option_t *wins_opt = _malloc(sizeof(*wins_opt)); + memset(wins_opt, 0, sizeof(*wins_opt)); wins_opt->opt.id = CI_WINS2; wins_opt->opt.len = 6; + wins_opt->addr = conf_wins2; return &wins_opt->opt; } static void wins_free(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt) { - struct wins_option_t *wins_opt=container_of(opt,typeof(*wins_opt),opt); + struct wins_option_t *wins_opt = container_of(opt, typeof(*wins_opt), opt); _free(wins_opt); } static int wins_send_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, uint8_t *ptr) { - struct wins_option_t *wins_opt = container_of(opt, typeof(*wins_opt), opt); - struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t *)ptr; - - if (!wins_opt->addr || wins_opt->rejected) - return 0; - - opt32->hdr.id = wins_opt->opt.id; - opt32->hdr.len = 6; - opt32->val = 0; - - return 6; + return 0; } static int wins_send_conf_nak(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, uint8_t *ptr) @@ -105,21 +97,14 @@ static int wins_send_conf_nak(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt static int wins_recv_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, uint8_t *ptr) { struct wins_option_t *wins_opt = container_of(opt, typeof(*wins_opt), opt); - struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t*)ptr; + struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t *)ptr; if (opt32->hdr.len != 6) return IPCP_OPT_REJ; - if (!wins_opt->addr) { - if (wins_opt->opt.id == CI_WINS1 && conf_wins1) - wins_opt->addr=conf_wins1; - else if (wins_opt->opt.id == CI_WINS2 && conf_wins2) - wins_opt->addr=conf_wins2; - - if (!wins_opt->addr) { - wins_opt->addr = opt32->val; - return IPCP_OPT_ACK; - } + if (!wins_opt->addr) { + wins_opt->addr = opt32->val; + return IPCP_OPT_ACK; } if (wins_opt->addr == opt32->val) @@ -128,16 +113,7 @@ static int wins_recv_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt return IPCP_OPT_NAK; } -static int wins_recv_conf_rej(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt, uint8_t *ptr) -{ - struct wins_option_t *wins_opt = container_of(opt, typeof(*wins_opt), opt); - - wins_opt->rejected = 1; - - return 0; -} - -static void wins1_print(void (*print)(const char *fmt,...), struct ipcp_option_t *opt, uint8_t *ptr) +static void wins1_print(void (*print)(const char *fmt, ...), struct ipcp_option_t *opt, uint8_t *ptr) { struct wins_option_t *wins_opt = container_of(opt, typeof(*wins_opt), opt); struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t *)ptr; @@ -151,7 +127,7 @@ static void wins1_print(void (*print)(const char *fmt,...), struct ipcp_option_t print("<wins1 %s>", inet_ntoa(in)); } -static void wins2_print(void (*print)(const char *fmt,...), struct ipcp_option_t *opt, uint8_t *ptr) +static void wins2_print(void (*print)(const char *fmt, ...), struct ipcp_option_t *opt, uint8_t *ptr) { struct wins_option_t *wins_opt = container_of(opt, typeof(*wins_opt), opt); struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t *)ptr; |