diff --git a/src/addr.c b/src/addr.c index 5480537..c14a791 100644 --- a/src/addr.c +++ b/src/addr.c @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #include #include @@ -26,11 +24,9 @@ #include "ndppd.h" -/*! Returns the string representation of addr. - * - * @note This function returns a pointer to static data. It uses three different static arrays - * to allow the function to be chained. - */ +//! Returns the string representation of addr. +//! @note This function returns a pointer to static data. It uses three different static arrays +//! to allow the function to be chained. const char *nd_aton(nd_addr_t *addr) { static int index; @@ -44,7 +40,7 @@ const char *nd_aton(nd_addr_t *addr) return inet_ntop(AF_INET6, addr, buf[n], sizeof(buf[n])); } -/*! Returns true if addr is a multicast address. */ +//! Returns true if addr is a multicast address. bool nd_addr_is_multicast(nd_addr_t *addr) { return addr->s6_addr[0] == 0xff; @@ -57,11 +53,11 @@ bool nd_addr_is_unicast(nd_addr_t *addr) #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ static const uint32_t ndL_masks[] = { - 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000, - 0xff800000, 0xffc00000, 0xffe00000, 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000, - 0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00, - 0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff, - }; + 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000, + 0xff800000, 0xffc00000, 0xffe00000, 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000, + 0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00, + 0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff, +}; #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ static const uint32_t ndL_masks[] = { 0x00000080, 0x000000c0, 0x000000e0, 0x000000f0, 0x000000f8, 0x000000fc, 0x000000fe, 0x000000ff, @@ -73,14 +69,14 @@ static const uint32_t ndL_masks[] = { # error __BYTE_ORDER__ is not defined #endif -/*! Returns true if first and second are the same. */ +//! Returns true if first and second are the same. bool nd_addr_eq(nd_addr_t *first, nd_addr_t *second) { return first->s6_addr32[0] == second->s6_addr32[0] && first->s6_addr32[1] == second->s6_addr32[1] && first->s6_addr32[2] == second->s6_addr32[2] && first->s6_addr32[3] == second->s6_addr32[3]; } -/*! Returns true if the first pflen bits are the same in first and second. */ +//! Returns true if the first pflen bits are the same in first and second. bool nd_addr_match(nd_addr_t *first, nd_addr_t *second, int pflen) { if (pflen < 0 || pflen > 128) diff --git a/src/addr.h b/src/addr.h index 1a685d9..fceefb5 100644 --- a/src/addr.h +++ b/src/addr.h @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #ifndef NDPPD_ADDR_H #define NDPPD_ADDR_H @@ -30,4 +28,4 @@ bool nd_addr_eq(nd_addr_t *first, nd_addr_t *second); int nd_addr_to_pflen(nd_addr_t *netmask); void nd_addr_from_pflen(int pflen, nd_addr_t *netmask); -#endif /* NDPPD_ADDR_H */ +#endif // NDPPD_ADDR_H diff --git a/src/alloc.c b/src/alloc.c index 5a6f4c9..ad1a977 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #include #include #include @@ -51,7 +49,7 @@ void *nd_alloc(size_t size) { assert(size > 0 && size < 512); - /* To keep everything properly aligned, we'll make sure it's multiple of 8. */ + // To keep everything properly aligned, we'll make sure it's multiple of 8. size = (size + 7U) & ~7U; for (ndL_chunk_t *chunk = ndL_chunks; chunk; chunk = chunk->next) diff --git a/src/alloc.h b/src/alloc.h index 69952fe..94d5e51 100644 --- a/src/alloc.h +++ b/src/alloc.h @@ -25,6 +25,4 @@ void nd_alloc_cleanup(); #define ND_ALLOC(type) (type *)nd_alloc(sizeof(type)) - - -#endif /* NDPPD_ALLOC_H */ +#endif // NDPPD_ALLOC_H diff --git a/src/conf.c b/src/conf.c index ba6f183..13ada31 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #include #include #include @@ -68,7 +66,7 @@ typedef struct ndL_cfcb_t cb; } ndL_cfinfo_t; -/* Scopes. */ +//! Scopes. enum { NDL_DEFAULT, @@ -76,7 +74,7 @@ enum NDL_RULE }; -/* Configuration types. */ +//! Configuration types. enum { NDL_NONE, @@ -85,17 +83,17 @@ enum NDL_ADDR }; -/* Character classes. */ +//! Character classes. enum { - NDL_ALPHA = 256, /* [a-zA-Z] */ - NDL_ALNUM, /* [a-zA-Z0-9] */ - NDL_DIGIT, /* [0-9] */ - NDL_EALNM, /* [a-zA-Z0-9_-] */ - NDL_SPACE, /* [\s] */ - NDL_SNONL, /* [^\S\n] */ - NDL_XNONL, /* [^\n] */ - NDL_IPV6X, /* [A-Fa-f0-9:] */ + NDL_ALPHA = 256, // [a-zA-Z] + NDL_ALNUM, // [a-zA-Z0-9] + NDL_DIGIT, // [0-9] + NDL_EALNM, // [a-zA-Z0-9_-] + NDL_SPACE, // [\s] + NDL_SNONL, // [^\S\n] + NDL_XNONL, // [^\n] + NDL_IPV6X, // [A-Fa-f0-9:] }; static bool ndL_parse_rule(ndL_state_t *state, nd_proxy_t *proxy); @@ -253,7 +251,7 @@ static bool ndL_accept_bool(ndL_state_t *state, bool *value) *value = false; else { - /* For accurate reporting of location. */ + // For accurate reporting of location. ndL_state_t tmp = *state; if (ndL_accept_one(&tmp, NDL_XNONL) != 0) return false; @@ -275,7 +273,7 @@ static bool ndL_accept_int(ndL_state_t *state, int *value) if (!ndL_accept_all(&tmp, NDL_DIGIT, buf, sizeof(buf))) return false; - /* Trailing [A-Za-z0-9_-] are invalid. */ + // Trailing [A-Za-z0-9_-] are invalid. if (ndL_accept_one(&tmp, NDL_EALNM)) return false; @@ -340,7 +338,7 @@ static bool ndL_accept_addr(ndL_state_t *state, nd_addr_t *addr) if (i == 0) return false; - /* Make sure we don't have a trailing [A-Za-z0-9-_]. */ + // Make sure we don't have a trailing [A-Za-z0-9-_]. if (ndL_accept_one(&tmp, NDL_EALNM)) return false; @@ -372,7 +370,7 @@ static bool ndL_parse_rule(ndL_state_t *state, nd_proxy_t *proxy) if (ndL_accept(state, "/", 0)) { - /* Just for accurate logging if there is an error. */ + // Just for accurate logging if there is an error. ndL_state_t tmp = *state; if (!ndL_accept_int(state, &rule->prefix)) diff --git a/src/conf.h b/src/conf.h index 3f7a537..f9ee55c 100644 --- a/src/conf.h +++ b/src/conf.h @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #ifndef NDPPD_CONF_H #define NDPPD_CONF_H @@ -23,4 +21,4 @@ bool nd_conf_load(const char *path); -#endif /* NDPPD_CONF_H */ +#endif // NDPPD_CONF_H diff --git a/src/iface.c b/src/iface.c index 79f3377..410b8f8 100644 --- a/src/iface.c +++ b/src/iface.c @@ -1,26 +1,24 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #include #include #include #include -/* Need to include netinet/in.h first on FreeBSD. */ +// Need to include netinet/in.h first on FreeBSD. #include #include #include @@ -64,7 +62,7 @@ extern bool nd_conf_keepalive; static nd_iface_t *ndL_first_iface, *ndL_first_free_iface; static nd_io_t *ndL_io; -/* Used when daemonizing to make sure the parent process does not restore these flags upon exit. */ +//! Used when daemonizing to make sure the parent process does not restore these flags upon exit. bool nd_iface_no_restore_flags; typedef struct @@ -80,7 +78,7 @@ static void ndL_handle_ns(nd_iface_t *iface, ndL_icmp6_msg_t *msg) if (msg->ip6_hdr.ip6_plen < sizeof(struct nd_neighbor_solicit)) return; - /* We're not doing "proper" parsing of options here. */ + // We're not doing "proper" parsing of options here. if (ntohs(msg->ip6_hdr.ip6_plen) - sizeof(struct nd_neighbor_solicit) < 8) return; @@ -139,7 +137,6 @@ static uint16_t ndL_calculate_checksum(uint32_t sum, const void *data, size_t le static uint16_t ndL_calculate_icmp6_checksum(ndL_icmp6_msg_t *msg, size_t size) { - /* IPv6 pseudo-header. */ struct __attribute__((packed)) { struct in6_addr src; @@ -190,7 +187,7 @@ static void ndL_handle_packet(nd_iface_t *iface, uint8_t *buf, size_t buflen) } #ifdef __linux__ -/* Called from nd_io_poll() when there are pending events on the nd_io_t. */ +// Called from nd_io_poll() when there are pending events on the nd_io_t. static void ndL_io_handler(nd_io_t *io, __attribute__((unused)) int events) { struct sockaddr_ll lladdr; @@ -229,7 +226,7 @@ static void ndL_io_handler(nd_io_t *io, __attribute__((unused)) int events) } } #else -/* Called from nd_io_poll() when there are pending events on the nd_io_t. */ +// Called from nd_io_poll() when there are pending events on the nd_io_t. static void ndL_io_handler(nd_io_t *io, __attribute__((unused)) int events) { __attribute__((aligned(BPF_ALIGNMENT))) uint8_t buf[4096]; /* Depends on BIOCGBLEN */ @@ -275,7 +272,7 @@ static bool ndL_configure_filter(nd_io_t *io) # define sock_fprog bpf_program #endif - /* Set up filter, so we only get NS and NA messages. */ + // Set up filter, so we only get NS and NA messages. static struct sock_filter filter[] = { /* Load ether_type. */ BPF_STMT(BPF_LD | BPF_H | BPF_ABS, offsetof(struct ether_header, ether_type)), @@ -304,6 +301,9 @@ static bool ndL_configure_filter(nd_io_t *io) if (setsockopt(io->fd, SOL_SOCKET, SO_ATTACH_FILTER, &fprog, sizeof(fprog)) == -1) return false; #else +# undef sock_filter +# undef sock_fprog + if (ioctl(io->fd, BIOCSETF, &fprog) == -1) return false; #endif @@ -334,7 +334,7 @@ nd_iface_t *nd_iface_open(const char *name, unsigned int index) return NULL; } - /* If the specified interface is already opened, just increase the reference counter. */ + // If the specified interface is already opened, just increase the reference counter. nd_iface_t *iface; ND_LL_SEARCH(ndL_first_iface, iface, next, iface->index == index); @@ -346,7 +346,7 @@ nd_iface_t *nd_iface_open(const char *name, unsigned int index) } #ifdef __linux__ - /* Determine link-layer address. */ + // Determine link-layer address. struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); @@ -425,11 +425,9 @@ nd_iface_t *nd_iface_open(const char *name, unsigned int index) uint8_t *lladdr = (uint8_t *)LLADDR((struct sockaddr_dl *)(sysctl_buf + sizeof(struct if_msghdr))); #endif - /* Allocate the nd_iface_t object. */ - iface = ndL_first_free_iface; - if (iface != NULL) + if (iface) ND_LL_DELETE(ndL_first_free_iface, iface, next); else iface = ND_ALLOC(nd_iface_t); @@ -507,7 +505,6 @@ static ssize_t ndL_send_icmp6(nd_iface_t *ifa, ndL_icmp6_msg_t *msg, size_t size struct ether_header *eh = (struct ether_header *)buf; eh->ether_type = htons(ETHERTYPE_IPV6); - /* TODO: Maybe use BIOCSHDRCMPLT instead. */ memcpy(eh->ether_shost, ifa->lladdr, ETHER_ADDR_LEN); memcpy(eh->ether_dhost, hwaddr, ETHER_ADDR_LEN); @@ -554,8 +551,10 @@ ssize_t nd_iface_write_na(nd_iface_t *iface, nd_addr_t *dst, uint8_t *dst_ll, nd memcpy(msg.lladdr, iface->lladdr, sizeof(msg.lladdr)); - nd_log_info("Write NA tgt=%s, dst=%s [%x:%x:%x:%x:%x:%x dev %s]", nd_aton(tgt), nd_aton(dst), dst_ll[0], dst_ll[1], - dst_ll[2], dst_ll[3], dst_ll[4], dst_ll[5], iface->name); + nd_log_info("Write NA tgt=%s, dst=%s [%x:%x:%x:%x:%x:%x dev %s]", // + nd_aton(tgt), nd_aton(dst), // + dst_ll[0], dst_ll[1], dst_ll[2], dst_ll[3], dst_ll[4], dst_ll[5], // + iface->name); return ndL_send_icmp6(iface, (ndL_icmp6_msg_t *)&msg, sizeof(msg), dst_ll); } @@ -602,8 +601,6 @@ bool nd_iface_startup() if (!(ndL_io = nd_io_socket(AF_PACKET, SOCK_RAW, htons(ETH_P_IPV6)))) return false; - /* Set up filter, so we only get NS and NA messages. */ - if (!ndL_configure_filter(ndL_io)) { nd_io_close(ndL_io); diff --git a/src/iface.h b/src/iface.h index ff3bcb3..a2e308a 100644 --- a/src/iface.h +++ b/src/iface.h @@ -37,7 +37,7 @@ struct nd_iface int old_promisc; nd_proxy_t *proxy; - nd_session_t *sessions; /* All sessions expecting NA messages to arrive here. */ + nd_session_t *sessions; // All sessions expecting NA messages to arrive here. #ifndef __linux__ nd_io_t *bpf_io; @@ -56,4 +56,4 @@ bool nd_iface_set_promisc(nd_iface_t *iface, bool on); bool nd_iface_startup(); void nd_iface_cleanup(); -#endif /* NDPPD_IFACE_H */ +#endif // NDPPD_IFACE_H diff --git a/src/io.c b/src/io.c index e7bfd00..242b0fe 100644 --- a/src/io.c +++ b/src/io.c @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #include #include #include diff --git a/src/io.h b/src/io.h index 6d3cb50..c7ce06e 100644 --- a/src/io.h +++ b/src/io.h @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #ifndef NDPPD_IO_H #define NDPPD_IO_H @@ -43,4 +41,4 @@ ssize_t nd_io_write(nd_io_t *io, void *buf, size_t count); void nd_io_cleanup(); -#endif /*NDPPD_IO_H*/ +#endif // NDPPD_IO_H diff --git a/src/log.c b/src/log.c index 98bbd6b..415dec0 100644 --- a/src/log.c +++ b/src/log.c @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #include #include #include diff --git a/src/log.h b/src/log.h index 9cf76c4..2b872b3 100644 --- a/src/log.h +++ b/src/log.h @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #ifndef NDPPD_LOG_H #define NDPPD_LOG_H @@ -44,4 +42,4 @@ void nd_log_printf(nd_loglevel_t level, const char *fmt, ...); #define nd_log_info(fmt, ...) nd_log_printf(ND_LOG_INFO, fmt, ##__VA_ARGS__) #define nd_log_debug(fmt, ...) nd_log_printf(ND_LOG_DEBUG, fmt, ##__VA_ARGS__) -#endif /* NDPPD_LOG_H */ +#endif // NDPPD_LOG_H diff --git a/src/ndppd.c b/src/ndppd.c index ac33bf8..ae2a6f5 100644 --- a/src/ndppd.c +++ b/src/ndppd.c @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #include #include #include diff --git a/src/ndppd.h b/src/ndppd.h index 64ad674..ab4d41b 100644 --- a/src/ndppd.h +++ b/src/ndppd.h @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #ifndef NDPPD_H #define NDPPD_H @@ -86,4 +84,4 @@ extern bool nd_opt_daemonize; #include "alloc.h" #include "log.h" -#endif /* NDPPD_H */ +#endif // NDPPD_H diff --git a/src/proxy.c b/src/proxy.c index cff18c1..5c647fa 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1,22 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ - +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #include #include "addr.h" @@ -66,8 +63,8 @@ nd_proxy_t *nd_proxy_create(const char *ifname) void nd_proxy_handle_ns(nd_proxy_t *proxy, nd_addr_t *src, __attribute__((unused)) nd_addr_t *dst, nd_addr_t *tgt, uint8_t *src_ll) { - nd_log_trace("Handle NA src=%s [%x:%x:%x:%x:%x:%x], dst=%s, tgt=%s", nd_aton(src), src_ll[0], src_ll[1], - src_ll[2], src_ll[3], src_ll[4], src_ll[5], nd_aton(dst), nd_aton(tgt)); + nd_log_trace("Handle NA src=%s [%x:%x:%x:%x:%x:%x], dst=%s, tgt=%s", nd_aton(src), src_ll[0], src_ll[1], src_ll[2], + src_ll[3], src_ll[4], src_ll[5], nd_aton(dst), nd_aton(tgt)); nd_session_t *session; @@ -86,8 +83,8 @@ void nd_proxy_handle_ns(nd_proxy_t *proxy, nd_addr_t *src, __attribute__((unused return; } - /* If we get down here it means we don't have any valid sessions we can use. - * See if we can find one more more matching rules. */ + // If we get down here it means we don't have any valid sessions we can use. + // See if we can find one more more matching rules. nd_rule_t *rule; ND_LL_SEARCH(proxy->rules, rule, next, nd_addr_match(&rule->addr, tgt, rule->prefix)); @@ -111,14 +108,14 @@ void nd_proxy_handle_ns(nd_proxy_t *proxy, nd_addr_t *src, __attribute__((unused if (!route || route->oif == proxy->iface->index) { - /* Could not find a matching route. */ + // Could not find a matching route. session->state = ND_STATE_INVALID; return; } if (!(session->iface = nd_iface_open(NULL, route->oif))) { - /* Could not open interface. */ + // Could not open interface. session->state = ND_STATE_INVALID; return; } @@ -197,8 +194,8 @@ static void ndL_update_session(nd_proxy_t *proxy, nd_session_t *session) } else { - /* We will only retransmit if nd_conf_keepalive is true, or if the last incoming NS - * request was made less than nd_conf_valid_ttl milliseconds ago. */ + // We will only retransmit if nd_conf_keepalive is true, or if the last incoming NS + // request was made less than nd_conf_valid_ttl milliseconds ago. if (!nd_conf_keepalive && nd_current_time - session->atime > nd_conf_valid_ttl) break; diff --git a/src/proxy.h b/src/proxy.h index 36296a1..10b5203 100644 --- a/src/proxy.h +++ b/src/proxy.h @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #ifndef NDPPD_PROXY_H #define NDPPD_PROXY_H @@ -40,4 +38,4 @@ void nd_proxy_handle_ns(nd_proxy_t *proxy, nd_addr_t *src, nd_addr_t *dst, nd_ad bool nd_proxy_startup(); void nd_proxy_update_all(); -#endif /* NDPPD_PROXY_H */ +#endif // NDPPD_PROXY_H diff --git a/src/rt.h b/src/rt.h index f373ec5..6f70369 100644 --- a/src/rt.h +++ b/src/rt.h @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #ifndef NDPPD_RT_H #define NDPPD_RT_H diff --git a/src/rule.c b/src/rule.c index 699f1ef..c5d0df6 100644 --- a/src/rule.c +++ b/src/rule.c @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #include "rule.h" #include "ndppd.h" #include "proxy.h" diff --git a/src/rule.h b/src/rule.h index f26f296..9e4ede0 100644 --- a/src/rule.h +++ b/src/rule.h @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #ifndef NDPPD_RULE_H #define NDPPD_RULE_H @@ -40,4 +38,4 @@ struct nd_rule nd_rule_t *nd_rule_create(nd_proxy_t *proxy); -#endif /* NDPPD_RULE_H */ +#endif // NDPPD_RULE_H diff --git a/src/session.c b/src/session.c index e2dd0fb..abc3db0 100644 --- a/src/session.c +++ b/src/session.c @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #include #include "ndppd.h" diff --git a/src/session.h b/src/session.h index 1062313..cb15aea 100644 --- a/src/session.h +++ b/src/session.h @@ -1,21 +1,19 @@ -/* - * This file is part of ndppd. - * - * Copyright (C) 2011-2019 Daniel Adolfsson - * - * ndppd is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ndppd is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with ndppd. If not, see . - */ +// This file is part of ndppd. +// +// Copyright (C) 2011-2019 Daniel Adolfsson +// +// ndppd is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ndppd is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with ndppd. If not, see . #ifndef NDPPD_SESSION_H #define NDPPD_SESSION_H @@ -24,25 +22,15 @@ typedef enum { - /* - * Address resolution is in progress. - */ + //! Address resolution is in progress. ND_STATE_INCOMPLETE, - /* - * - */ ND_STATE_VALID, - /* - * - */ ND_STATE_STALE, - /* - * Resolution failed, and further Neighbor Solicitation messages will be ignored until - * the session is removed or a Neighbor Advertisement is received. - */ + //! Resolution failed, and further Neighbor Solicitation messages will be ignored until + //! the session is removed or a Neighbor Advertisement is received. ND_STATE_INVALID, } nd_state_t; @@ -53,15 +41,15 @@ struct nd_session nd_session_t *next_in_iface; nd_addr_t tgt; int rcount; - long atime; /* Last time the session was used in a NA response. */ - long rtime; /* Last time a NS request was made. */ - long mtime; /* Last time state was changed. */ + long atime; // Last time the session was used in a NA response. + long rtime; // Last time a NS request was made. + long mtime; // Last time state was changed. nd_state_t state; nd_iface_t *iface; - nd_rt_route_t *route; /* Autowired route. */ + nd_rt_route_t *route; // Autowired route. }; nd_session_t *nd_alloc_session(); void nd_free_session(nd_session_t *session); -#endif /* NDPPD_SESSION_H */ +#endif // NDPPD_SESSION_H