From 81ca3923a29ea9b67f7291be23b210019546aa5f Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Sat, 22 Nov 2014 08:56:40 +0300 Subject: remove trailing whitespaces --- accel-pppd/ipv6/dhcpv6.c | 82 ++++++++++++++++++++--------------------- accel-pppd/ipv6/dhcpv6.h | 2 +- accel-pppd/ipv6/dhcpv6_packet.c | 22 +++++------ accel-pppd/ipv6/nd.c | 48 ++++++++++++------------ 4 files changed, 77 insertions(+), 77 deletions(-) (limited to 'accel-pppd/ipv6') diff --git a/accel-pppd/ipv6/dhcpv6.c b/accel-pppd/ipv6/dhcpv6.c index a80b622..5b4ed6a 100644 --- a/accel-pppd/ipv6/dhcpv6.c +++ b/accel-pppd/ipv6/dhcpv6.c @@ -64,25 +64,25 @@ static void ev_ses_started(struct ap_session *ses) if (!ses->ipv6) return; - + sock = socket(AF_INET6, SOCK_DGRAM, 0); if (!sock) { log_ppp_error("dhcpv6: socket: %s\n", strerror(errno)); return; } - - setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &f, sizeof(f)); + + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &f, sizeof(f)); if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, ses->ifname, strlen(ses->ifname))) { log_ppp_error("ipv6_nd: setsockopt(SO_BINDTODEVICE): %s\n", strerror(errno)); close(sock); return; } - + memset(&addr, 0, sizeof(addr)); addr.sin6_family = AF_INET6; addr.sin6_port = htons(DHCPV6_SERV_PORT); - + if (bind(sock, (struct sockaddr *)&addr, sizeof(addr))) { log_ppp_error("dhcpv6: bind: %s\n", strerror(errno)); close(sock); @@ -99,13 +99,13 @@ static void ev_ses_started(struct ap_session *ses) close(sock); return; } - + fcntl(sock, F_SETFL, O_NONBLOCK); fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC); pd = _malloc(sizeof(*pd)); memset(pd, 0, sizeof(*pd)); - + pd->pd.key = &pd_key; list_add_tail(&pd->pd.entry, &ses->pd_list); @@ -140,10 +140,10 @@ static void ev_ses_finished(struct ap_session *ses) if (pd->clientid) _free(pd->clientid); - + if (ses->ipv6_dp) ipdb_put_ipv6_prefix(ses, ses->ipv6_dp); - + triton_md_unregister_handler(&pd->hnd, 1); _free(pd); @@ -261,7 +261,7 @@ static void dhcpv6_send_reply(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, i reply = dhcpv6_packet_alloc_reply(req, code); if (!reply) return; - + list_for_each_entry(opt, &req->opt_list, entry) { // IA_NA @@ -294,7 +294,7 @@ static void dhcpv6_send_reply(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, i build_addr(a, ses->ipv6->peer_intf_id, &ia_addr->addr); ia_addr->pref_lifetime = htonl(conf_pref_lifetime); - ia_addr->valid_lifetime = htonl(conf_valid_lifetime); + ia_addr->valid_lifetime = htonl(conf_valid_lifetime); } list_for_each_entry(opt2, &opt->opt_list, entry) { @@ -336,11 +336,11 @@ static void dhcpv6_send_reply(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, i opt1 = dhcpv6_option_alloc(reply, D6_OPTION_IA_PD, sizeof(struct dhcpv6_opt_ia_na) - sizeof(struct dhcpv6_opt_hdr)); memcpy(opt1->hdr + 1, opt->hdr + 1, ntohs(opt1->hdr->len)); - + ia_na = (struct dhcpv6_opt_ia_na *)opt1->hdr; ia_na->T1 = conf_pref_lifetime == -1 ? -1 : htonl(conf_pref_lifetime / 2); ia_na->T2 = conf_pref_lifetime == -1 ? -1 : htonl((conf_pref_lifetime * 4) / 5); - + if (!ses->ipv6_dp) ses->ipv6_dp = ipdb_get_ipv6_prefix(ses); @@ -361,11 +361,11 @@ static void dhcpv6_send_reply(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, i list_for_each_entry(a, &ses->ipv6_dp->prefix_list, entry) { opt2 = dhcpv6_nested_option_alloc(reply, opt1, D6_OPTION_IAPREFIX, sizeof(*ia_prefix) - sizeof(struct dhcpv6_opt_hdr)); ia_prefix = (struct dhcpv6_opt_ia_prefix *)opt2->hdr; - + memcpy(&ia_prefix->prefix, &a->addr, sizeof(a->addr)); ia_prefix->prefix_len = a->prefix_len; ia_prefix->pref_lifetime = htonl(conf_pref_lifetime); - ia_prefix->valid_lifetime = htonl(conf_valid_lifetime); + ia_prefix->valid_lifetime = htonl(conf_valid_lifetime); } list_for_each_entry(opt2, &opt->opt_list, entry) { @@ -396,7 +396,7 @@ static void dhcpv6_send_reply(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, i } } } - + //insert_status(reply, opt1, D6_STATUS_Success); } @@ -450,7 +450,7 @@ static void dhcpv6_send_reply2(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, reply = dhcpv6_packet_alloc_reply(req, code); if (!reply) return; - + list_for_each_entry(opt, &req->opt_list, entry) { // IA_NA @@ -472,7 +472,7 @@ static void dhcpv6_send_reply2(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, continue; f1 = 0; - + if (!f) { list_for_each_entry(a, &ses->ipv6->addr_list, entry) { build_addr(a, ses->ipv6->peer_intf_id, &addr); @@ -490,7 +490,7 @@ static void dhcpv6_send_reply2(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, ia_addr = (struct dhcpv6_opt_ia_addr *)opt3->hdr; if (f1) { ia_addr->pref_lifetime = htonl(conf_pref_lifetime); - ia_addr->valid_lifetime = htonl(conf_valid_lifetime); + ia_addr->valid_lifetime = htonl(conf_valid_lifetime); } else { ia_addr->pref_lifetime = 0; ia_addr->valid_lifetime = 0; @@ -510,11 +510,11 @@ static void dhcpv6_send_reply2(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, } else if (ntohs(opt->hdr->code) == D6_OPTION_IA_PD) { opt1 = dhcpv6_option_alloc(reply, D6_OPTION_IA_PD, sizeof(struct dhcpv6_opt_ia_na) - sizeof(struct dhcpv6_opt_hdr)); memcpy(opt1->hdr + 1, opt->hdr + 1, ntohs(opt1->hdr->len)); - + ia_na = (struct dhcpv6_opt_ia_na *)opt1->hdr; ia_na->T1 = conf_pref_lifetime == -1 ? -1 : htonl(conf_pref_lifetime / 2); ia_na->T2 = conf_pref_lifetime == -1 ? -1 : htonl((conf_pref_lifetime * 4) / 5); - + if (!ses->ipv6_dp) ses->ipv6_dp = ipdb_get_ipv6_prefix(req->ses); @@ -547,7 +547,7 @@ static void dhcpv6_send_reply2(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, if (f1) { ia_prefix->pref_lifetime = htonl(conf_pref_lifetime); - ia_prefix->valid_lifetime = htonl(conf_valid_lifetime); + ia_prefix->valid_lifetime = htonl(conf_valid_lifetime); } else { ia_prefix->pref_lifetime = 0; ia_prefix->valid_lifetime = 0; @@ -633,7 +633,7 @@ static void dhcpv6_recv_request(struct dhcpv6_packet *req) log_ppp_error("dhcpv6: unmatched Client-ID option\n"); return; } - + dhcpv6_send_reply(req, pd, D6_REPLY); } @@ -661,20 +661,20 @@ static void dhcpv6_recv_renew(struct dhcpv6_packet *req) log_ppp_error("dhcpv6: no Request was received\n"); return; } - + if (req->clientid->hdr.len != pd->clientid->hdr.len || memcmp(req->clientid, pd->clientid, ntohs(pd->clientid->hdr.len) + sizeof(struct dhcpv6_opt_hdr))) { log_ppp_error("dhcpv6: unmatched Client-ID option\n"); return; } - + dhcpv6_send_reply(req, pd, D6_REPLY); } static void dhcpv6_recv_information_request(struct dhcpv6_packet *req) { struct dhcpv6_pd *pd = req->pd; - + if (req->rapid_commit) { log_ppp_error("dhcpv6: unexpected Rapid-Commit option\n"); return; @@ -706,7 +706,7 @@ static void dhcpv6_recv_rebind(struct dhcpv6_packet *req) log_ppp_error("dhcpv6: unmatched Client-ID option\n"); return; } - + req->serverid = &conf_serverid; dhcpv6_send_reply2(req, pd, D6_REPLY); @@ -808,19 +808,19 @@ static void add_dnssl(const char *val) n++; else n += 2; - + if (n > 255) { log_error("dnsv6: dnssl '%s' is too long\n", val); return; } - + if (!conf_dnssl) conf_dnssl = _malloc(n); else conf_dnssl = _realloc(conf_dnssl, conf_dnssl_size + n); - + buf = conf_dnssl + conf_dnssl_size; - + while (1) { ptr = strchr(val, '.'); if (!ptr) @@ -838,7 +838,7 @@ static void add_dnssl(const char *val) break; } } - + conf_dnssl_size += n; } @@ -846,12 +846,12 @@ static void load_dns(void) { struct conf_sect_t *s = conf_get_section("ipv6-dns"); struct conf_option_t *opt; - + if (!s) return; - + conf_dns_count = 0; - + if (conf_dnssl) _free(conf_dnssl); conf_dnssl = NULL; @@ -888,7 +888,7 @@ static uint64_t parse_serverid(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; @@ -910,19 +910,19 @@ static void load_config(void) opt = conf_get_opt("ipv6-dhcp", "verbose"); if (opt) conf_verbose = atoi(opt); - + opt = conf_get_opt("ipv6-dhcp", "pref-lifetime"); if (opt) conf_pref_lifetime = atoi(opt); - + opt = conf_get_opt("ipv6-dhcp", "valid-lifetime"); if (opt) conf_valid_lifetime = atoi(opt); - + opt = conf_get_opt("ipv6-dhcp", "route-via-gw"); if (opt) conf_route_via_gw = atoi(opt); - + opt = conf_get_opt("ipv6-dhcp", "server-id"); if (opt) id = parse_serverid(opt); @@ -935,7 +935,7 @@ static void load_config(void) conf_serverid.duid.u.ll.htype = htons(27); //conf_serverid.duid.u.llt.time = htonl(t - t0); *(uint64_t *)conf_serverid.duid.u.ll.addr = id; - + load_dns(); } diff --git a/accel-pppd/ipv6/dhcpv6.h b/accel-pppd/ipv6/dhcpv6.h index 82e366e..1166445 100644 --- a/accel-pppd/ipv6/dhcpv6.h +++ b/accel-pppd/ipv6/dhcpv6.h @@ -158,7 +158,7 @@ struct dhcpv6_packet { struct ap_session *ses; struct dhcpv6_pd *pd; struct sockaddr_in6 addr; - + struct dhcpv6_msg_hdr *hdr; struct dhcpv6_opt_clientid *clientid; struct dhcpv6_opt_serverid *serverid; diff --git a/accel-pppd/ipv6/dhcpv6_packet.c b/accel-pppd/ipv6/dhcpv6_packet.c index 7118491..16db5cb 100644 --- a/accel-pppd/ipv6/dhcpv6_packet.c +++ b/accel-pppd/ipv6/dhcpv6_packet.c @@ -69,7 +69,7 @@ static void *parse_option(void *ptr, void *endptr, struct list_head *opt_list) log_warn("dhcpv6: invalid packet received\n"); return NULL; } - + opt = _malloc(sizeof(*opt)); if (!opt) { log_emerg("out of memory\n"); @@ -85,7 +85,7 @@ static void *parse_option(void *ptr, void *endptr, struct list_head *opt_list) if (dopt->code == ntohs(opth->code)) break; } - + if (dopt->len) { endptr = ptr + sizeof(*opth) + ntohs(opth->len); ptr += dopt->len; @@ -96,7 +96,7 @@ static void *parse_option(void *ptr, void *endptr, struct list_head *opt_list) } } else ptr += sizeof(*opth) + ntohs(opth->len); - + return ptr; } @@ -148,13 +148,13 @@ struct dhcpv6_packet *dhcpv6_packet_parse(const void *buf, size_t size) struct dhcpv6_option *dhcpv6_option_alloc(struct dhcpv6_packet *pkt, int code, int len) { struct dhcpv6_option *opt; - + opt = _malloc(sizeof(*opt)); if (!opt) { log_emerg("out of memory\n"); return NULL; } - + memset(opt, 0, sizeof(*opt)); INIT_LIST_HEAD(&opt->opt_list); @@ -172,13 +172,13 @@ struct dhcpv6_option *dhcpv6_option_alloc(struct dhcpv6_packet *pkt, int code, i struct dhcpv6_option *dhcpv6_nested_option_alloc(struct dhcpv6_packet *pkt, struct dhcpv6_option *popt, int code, int len) { struct dhcpv6_option *opt; - + opt = _malloc(sizeof(*opt)); if (!opt) { log_emerg("out of memory\n"); return NULL; } - + memset(opt, 0, sizeof(*opt)); INIT_LIST_HEAD(&opt->opt_list); opt->parent = popt; @@ -204,7 +204,7 @@ struct dhcpv6_packet *dhcpv6_packet_alloc_reply(struct dhcpv6_packet *req, int t { struct dhcpv6_packet *pkt = _malloc(sizeof(*pkt)); struct dhcpv6_option *opt; - + if (!pkt) { log_emerg("out of memory\n"); return NULL; @@ -306,7 +306,7 @@ void dhcpv6_packet_print(struct dhcpv6_packet *pkt, void (*print)(const char *fm print("Unknown"); else print("%s", type_name[pkt->hdr->type - 1]); - + print(" XID=%x", pkt->hdr->trans_id); print_options(&pkt->opt_list, 0, print); @@ -320,7 +320,7 @@ static void print_clientid(struct dhcpv6_option *opt, void (*print)(const char * struct dhcpv6_opt_clientid *o = (struct dhcpv6_opt_clientid *)opt->hdr; print(" %i:", htons(o->duid.type)); - + for (i = 0; i < ntohs(o->hdr.len) - 2; i++) print("%02x", o->duid.u.raw[i]); } @@ -358,7 +358,7 @@ static void print_oro(struct dhcpv6_option *opt, void (*print)(const char *fmt, for (; ptr < end_ptr; ptr++) { if (f) print(","); - else + else print(" "); for (dopt = known_options; dopt->code; dopt++) { diff --git a/accel-pppd/ipv6/nd.c b/accel-pppd/ipv6/nd.c index 1241380..ff8b64b 100644 --- a/accel-pppd/ipv6/nd.c +++ b/accel-pppd/ipv6/nd.c @@ -104,12 +104,12 @@ static void ipv6_nd_send_ra(struct ipv6_nd_handler_t *h, struct sockaddr_in6 *ad //struct nd_opt_mtu *mtu; struct ipv6db_addr_t *a; int i; - + if (!buf) { log_emerg("out of memory\n"); return; } - + if (!h->ses->ipv6) { triton_timer_del(&h->timer); return; @@ -119,12 +119,12 @@ static void ipv6_nd_send_ra(struct ipv6_nd_handler_t *h, struct sockaddr_in6 *ad adv->nd_ra_type = ND_ROUTER_ADVERT; adv->nd_ra_curhoplimit = conf_AdvCurHopLimit; adv->nd_ra_router_lifetime = htons(conf_AdvDefaultLifetime); - adv->nd_ra_flags_reserved = + adv->nd_ra_flags_reserved = (conf_AdvManagedFlag ? ND_RA_FLAG_MANAGED : 0) | (conf_AdvOtherConfigFlag ? ND_RA_FLAG_OTHER : 0); adv->nd_ra_reachable = htonl(conf_AdvReachableTime); adv->nd_ra_retransmit = htonl(conf_AdvRetransTimer); - + pinfo = (struct nd_opt_prefix_info *)(adv + 1); list_for_each_entry(a, &h->ses->ipv6->addr_list, entry) { memset(pinfo, 0, sizeof(*pinfo)); @@ -138,7 +138,7 @@ static void ipv6_nd_send_ra(struct ipv6_nd_handler_t *h, struct sockaddr_in6 *ad memcpy(&pinfo->nd_opt_pi_prefix, &a->addr, 8); pinfo++; } - + /*rinfo = (struct nd_opt_route_info_local *)pinfo; list_for_each_entry(a, &h->ses->ipv6->route_list, entry) { memset(rinfo, 0, sizeof(*rinfo)); @@ -163,7 +163,7 @@ static void ipv6_nd_send_ra(struct ipv6_nd_handler_t *h, struct sockaddr_in6 *ad } } else rdnss_addr = (struct in6_addr *)pinfo; - + if (conf_dnssl) { dnsslinfo = (struct nd_opt_dnssl_info_local *)rdnss_addr; memset(dnsslinfo, 0, sizeof(*dnsslinfo)); @@ -190,7 +190,7 @@ static void send_ra_timer(struct triton_timer_t *t) addr.sin6_family = AF_INET6; addr.sin6_addr.s6_addr32[0] = htonl(0xff020000); addr.sin6_addr.s6_addr32[3] = htonl(0x1); - addr.sin6_scope_id = h->ses->ifindex; + addr.sin6_scope_id = h->ses->ifindex; if (h->ra_sent == conf_init_ra) { h->timer.period = conf_MaxRtrAdvInterval * 1000; @@ -261,7 +261,7 @@ static int ipv6_nd_start(struct ap_session *ses) struct ipv6_nd_handler_t *h; sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6); - + if (sock < 0) { log_ppp_error("socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6): %s\n", strerror(errno)); return -1; @@ -283,7 +283,7 @@ static int ipv6_nd_start(struct ap_session *ses) log_ppp_error("ipv6_nd: setsockopt(IPV6_UNICAST_HOPS): %s\n", strerror(errno)); goto out_err; } - + if (setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &val, sizeof(val))) { log_ppp_error("ipv6_nd: setsockopt(IPV6_MULTICAST_HOPS): %s\n", strerror(errno)); goto out_err; @@ -372,14 +372,14 @@ static void ev_ses_finishing(struct ap_session *ses) if (!h) return; - + if (h->timer.tpd) triton_timer_del(&h->timer); triton_md_unregister_handler(&h->hnd, 1); list_del(&h->pd.entry); - + _free(h); } @@ -393,19 +393,19 @@ static void add_dnssl(const char *val) n++; else n += 2; - + if (n > 255) { log_error("dnsv6: dnssl '%s' is too long\n", val); return; } - + if (!conf_dnssl) conf_dnssl = _malloc(n); else conf_dnssl = _realloc(conf_dnssl, conf_dnssl_size + n); - + buf = conf_dnssl + conf_dnssl_size; - + while (1) { ptr = strchr(val, '.'); if (!ptr) @@ -423,7 +423,7 @@ static void add_dnssl(const char *val) break; } } - + conf_dnssl_size += n; } @@ -431,12 +431,12 @@ static void load_dns(void) { struct conf_sect_t *s = conf_get_section("ipv6-dns"); struct conf_option_t *opt; - + if (!s) return; - + conf_dns_count = 0; - + if (conf_dnssl) _free(conf_dnssl); conf_dnssl = NULL; @@ -447,7 +447,7 @@ static void load_dns(void) add_dnssl(opt->val); continue; } - + if (!strcmp(opt->name, "lifetime")) { conf_rdnss_lifetime = atoi(opt->val); continue; @@ -473,10 +473,10 @@ static void load_config(void) opt = conf_get_opt("ipv6-nd", "MaxRtrAdvInterval"); if (opt) conf_MaxRtrAdvInterval = atoi(opt); - + conf_MinRtrAdvInterval = 0.33 * conf_MaxRtrAdvInterval; conf_AdvDefaultLifetime = 3 * conf_MaxRtrAdvInterval; - + conf_AdvManagedFlag = triton_module_loaded("ipv6_dhcp"); conf_AdvOtherConfigFlag = triton_module_loaded("ipv6_dhcp"); conf_AdvPrefixAutonomousFlag = !conf_AdvManagedFlag; @@ -532,7 +532,7 @@ static void load_config(void) opt = conf_get_opt("ipv6-nd", "AdvAutonomousFlag"); if (opt) conf_AdvPrefixAutonomousFlag = atoi(opt); - + load_dns(); } @@ -541,7 +541,7 @@ static void init(void) buf_pool = mempool_create(BUF_SIZE); load_config(); - + triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config); triton_event_register_handler(EV_SES_STARTED, (triton_event_func)ev_ses_started); triton_event_register_handler(EV_SES_FINISHING, (triton_event_func)ev_ses_finishing); -- cgit v1.2.3