diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2012-11-12 16:29:28 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2012-11-12 16:29:28 +0400 |
commit | ce56e6c72c0363cd02a77cd7c7b37f9f0b50d8a4 (patch) | |
tree | 5b872d3800cca70c4041bb0b94ef118021f8a052 | |
parent | 4cbea24a9e2a71f6586a107c1e5ad4f2dc85b871 (diff) | |
download | accel-ppp-ce56e6c72c0363cd02a77cd7c7b37f9f0b50d8a4.tar.gz accel-ppp-ce56e6c72c0363cd02a77cd7c7b37f9f0b50d8a4.zip |
Revert "ppp: force to send dns"
This reverts commit 1c89473d04c74e224546c596608f227dcd77518b.
-rw-r--r-- | accel-pppd/ppp/ipcp_opt_dns.c | 133 | ||||
-rw-r--r-- | accel-pppd/ppp/lcp_opt_mru.c | 2 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_ipcp.c | 8 | ||||
-rw-r--r-- | accel-pppd/ppp/ppp_ipcp.h | 2 |
4 files changed, 60 insertions, 85 deletions
diff --git a/accel-pppd/ppp/ipcp_opt_dns.c b/accel-pppd/ppp/ipcp_opt_dns.c index a62fc493..19183eb7 100644 --- a/accel-pppd/ppp/ipcp_opt_dns.c +++ b/accel-pppd/ppp/ipcp_opt_dns.c @@ -19,53 +19,51 @@ 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 int dns_recv_conf_rej(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 { struct ipcp_option_t opt; in_addr_t addr; - int rejected; }; -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, - .recv_conf_rej = dns_recv_conf_rej, - .free = dns_free, - .print = dns1_print, +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, }; -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, - .recv_conf_rej = dns_recv_conf_rej, - .free = dns_free, - .print = dns2_print, +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, }; 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; 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; return &dns_opt->opt; } @@ -79,90 +77,67 @@ 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) { - struct dns_option_t *dns_opt = container_of(opt, typeof(*dns_opt), opt); - struct ipcp_opt32_t *opt32 = (struct ipcp_opt32_t *)ptr; - - if (!dns_opt->addr || dns_opt->rejected) - return 0; - - opt32->hdr.id = dns_opt->opt.id; - opt32->hdr.len = 6; - opt32->val = 0; - - return 6; + return 0; } 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) + { + 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; + 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 int dns_recv_conf_rej(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 *opt, uint8_t *ptr) { - struct dns_option_t *dns_opt = container_of(opt, typeof(*dns_opt), opt); - - dns_opt->rejected = 1; - - return 0; -} - -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/lcp_opt_mru.c b/accel-pppd/ppp/lcp_opt_mru.c index 8aaede05..577e0191 100644 --- a/accel-pppd/ppp/lcp_opt_mru.c +++ b/accel-pppd/ppp/lcp_opt_mru.c @@ -118,7 +118,7 @@ static int mru_recv_conf_ack(struct ppp_lcp_t *lcp, struct lcp_option_t *opt, ui { struct mru_option_t *mru_opt = container_of(opt,typeof(*mru_opt), opt); struct ifreq ifr = { - .ifr_mtu = mru_opt->mtu < mru_opt->mru ? mru_opt->mtu : mru_opt->mru, + .ifr_mtu = mru_opt->mtu, }; strcpy(ifr.ifr_name, lcp->ppp->ifname); diff --git a/accel-pppd/ppp/ppp_ipcp.c b/accel-pppd/ppp/ppp_ipcp.c index 6fcf05bf..9ec92d49 100644 --- a/accel-pppd/ppp/ppp_ipcp.c +++ b/accel-pppd/ppp/ppp_ipcp.c @@ -265,18 +265,18 @@ static int send_conf_req(struct ppp_fsm_t *fsm) return -1; } if (n) { - lopt->ptr = ptr; ptr += n; + lopt->print = 1; } else - lopt->ptr = NULL; + lopt->print = 0; } if (conf_ppp_verbose) { log_ppp_info2("send [IPCP ConfReq id=%x", ipcp_hdr->id); list_for_each_entry(lopt,&ipcp->options,entry) { - if (lopt->ptr) { + if (lopt->print) { log_ppp_info2(" "); - lopt->h->print(log_ppp_info2, lopt, lopt->ptr); + lopt->h->print(log_ppp_info2, lopt, NULL); } } log_ppp_info2("]\n"); diff --git a/accel-pppd/ppp/ppp_ipcp.h b/accel-pppd/ppp/ppp_ipcp.h index e430d7b2..301bdcec 100644 --- a/accel-pppd/ppp/ppp_ipcp.h +++ b/accel-pppd/ppp/ppp_ipcp.h @@ -58,7 +58,7 @@ struct ipcp_option_t int id; int len; int state; - uint8_t *ptr; + int print:1; struct ipcp_option_handler_t *h; }; |