Commenting style

This commit is contained in:
Daniel Adolfsson 2019-12-14 01:22:57 +01:00
parent 41627fe276
commit d383218100
21 changed files with 373 additions and 427 deletions

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#include <arpa/inet.h> #include <arpa/inet.h>
#include <string.h> #include <string.h>
@ -26,11 +24,9 @@
#include "ndppd.h" #include "ndppd.h"
/*! Returns the string representation of <tt>addr</tt>. //! Returns the string representation of <tt>addr</tt>.
* //! @note This function returns a pointer to static data. It uses three different static arrays
* @note This function returns a pointer to static data. It uses three different static arrays //! to allow the function to be chained.
* to allow the function to be chained.
*/
const char *nd_aton(nd_addr_t *addr) const char *nd_aton(nd_addr_t *addr)
{ {
static int index; 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])); return inet_ntop(AF_INET6, addr, buf[n], sizeof(buf[n]));
} }
/*! Returns true if <tt>addr</tt> is a multicast address. */ //! Returns true if <tt>addr</tt> is a multicast address.
bool nd_addr_is_multicast(nd_addr_t *addr) bool nd_addr_is_multicast(nd_addr_t *addr)
{ {
return addr->s6_addr[0] == 0xff; 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__ #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
static const uint32_t ndL_masks[] = { static const uint32_t ndL_masks[] = {
0x80000000, 0xc0000000, 0xe0000000, 0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000, 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000,
0xff800000, 0xffc00000, 0xffe00000, 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000, 0xff800000, 0xffc00000, 0xffe00000, 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000,
0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00, 0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00,
0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff, 0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff,
}; };
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
static const uint32_t ndL_masks[] = { static const uint32_t ndL_masks[] = {
0x00000080, 0x000000c0, 0x000000e0, 0x000000f0, 0x000000f8, 0x000000fc, 0x000000fe, 0x000000ff, 0x00000080, 0x000000c0, 0x000000e0, 0x000000f0, 0x000000f8, 0x000000fc, 0x000000fe, 0x000000ff,
@ -73,14 +69,14 @@ static const uint32_t ndL_masks[] = {
# error __BYTE_ORDER__ is not defined # error __BYTE_ORDER__ is not defined
#endif #endif
/*! Returns true if <tt>first</tt> and <tt>second</tt> are the same. */ //! Returns true if <tt>first</tt> and <tt>second</tt> are the same.
bool nd_addr_eq(nd_addr_t *first, nd_addr_t *second) 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] && 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]; first->s6_addr32[2] == second->s6_addr32[2] && first->s6_addr32[3] == second->s6_addr32[3];
} }
/*! Returns true if the first <tt>pflen</tt> bits are the same in <tt>first</tt> and <tt>second</tt>. */ //! Returns true if the first <tt>pflen</tt> bits are the same in <tt>first</tt> and <tt>second</tt>.
bool nd_addr_match(nd_addr_t *first, nd_addr_t *second, int pflen) bool nd_addr_match(nd_addr_t *first, nd_addr_t *second, int pflen)
{ {
if (pflen < 0 || pflen > 128) if (pflen < 0 || pflen > 128)

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef NDPPD_ADDR_H #ifndef NDPPD_ADDR_H
#define 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); int nd_addr_to_pflen(nd_addr_t *netmask);
void nd_addr_from_pflen(int pflen, nd_addr_t *netmask); void nd_addr_from_pflen(int pflen, nd_addr_t *netmask);
#endif /* NDPPD_ADDR_H */ #endif // NDPPD_ADDR_H

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -51,7 +49,7 @@ void *nd_alloc(size_t size)
{ {
assert(size > 0 && size < 512); 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; size = (size + 7U) & ~7U;
for (ndL_chunk_t *chunk = ndL_chunks; chunk; chunk = chunk->next) for (ndL_chunk_t *chunk = ndL_chunks; chunk; chunk = chunk->next)

View File

@ -25,6 +25,4 @@ void nd_alloc_cleanup();
#define ND_ALLOC(type) (type *)nd_alloc(sizeof(type)) #define ND_ALLOC(type) (type *)nd_alloc(sizeof(type))
#endif // NDPPD_ALLOC_H
#endif /* NDPPD_ALLOC_H */

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#include <arpa/inet.h> #include <arpa/inet.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
@ -68,7 +66,7 @@ typedef struct
ndL_cfcb_t cb; ndL_cfcb_t cb;
} ndL_cfinfo_t; } ndL_cfinfo_t;
/* Scopes. */ //! Scopes.
enum enum
{ {
NDL_DEFAULT, NDL_DEFAULT,
@ -76,7 +74,7 @@ enum
NDL_RULE NDL_RULE
}; };
/* Configuration types. */ //! Configuration types.
enum enum
{ {
NDL_NONE, NDL_NONE,
@ -85,17 +83,17 @@ enum
NDL_ADDR NDL_ADDR
}; };
/* Character classes. */ //! Character classes.
enum enum
{ {
NDL_ALPHA = 256, /* [a-zA-Z] */ NDL_ALPHA = 256, // [a-zA-Z]
NDL_ALNUM, /* [a-zA-Z0-9] */ NDL_ALNUM, // [a-zA-Z0-9]
NDL_DIGIT, /* [0-9] */ NDL_DIGIT, // [0-9]
NDL_EALNM, /* [a-zA-Z0-9_-] */ NDL_EALNM, // [a-zA-Z0-9_-]
NDL_SPACE, /* [\s] */ NDL_SPACE, // [\s]
NDL_SNONL, /* [^\S\n] */ NDL_SNONL, // [^\S\n]
NDL_XNONL, /* [^\n] */ NDL_XNONL, // [^\n]
NDL_IPV6X, /* [A-Fa-f0-9:] */ NDL_IPV6X, // [A-Fa-f0-9:]
}; };
static bool ndL_parse_rule(ndL_state_t *state, nd_proxy_t *proxy); 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; *value = false;
else else
{ {
/* For accurate reporting of location. */ // For accurate reporting of location.
ndL_state_t tmp = *state; ndL_state_t tmp = *state;
if (ndL_accept_one(&tmp, NDL_XNONL) != 0) if (ndL_accept_one(&tmp, NDL_XNONL) != 0)
return false; 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))) if (!ndL_accept_all(&tmp, NDL_DIGIT, buf, sizeof(buf)))
return false; return false;
/* Trailing [A-Za-z0-9_-] are invalid. */ // Trailing [A-Za-z0-9_-] are invalid.
if (ndL_accept_one(&tmp, NDL_EALNM)) if (ndL_accept_one(&tmp, NDL_EALNM))
return false; return false;
@ -340,7 +338,7 @@ static bool ndL_accept_addr(ndL_state_t *state, nd_addr_t *addr)
if (i == 0) if (i == 0)
return false; 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)) if (ndL_accept_one(&tmp, NDL_EALNM))
return false; return false;
@ -372,7 +370,7 @@ static bool ndL_parse_rule(ndL_state_t *state, nd_proxy_t *proxy)
if (ndL_accept(state, "/", 0)) 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; ndL_state_t tmp = *state;
if (!ndL_accept_int(state, &rule->prefix)) if (!ndL_accept_int(state, &rule->prefix))

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef NDPPD_CONF_H #ifndef NDPPD_CONF_H
#define NDPPD_CONF_H #define NDPPD_CONF_H
@ -23,4 +21,4 @@
bool nd_conf_load(const char *path); bool nd_conf_load(const char *path);
#endif /* NDPPD_CONF_H */ #endif // NDPPD_CONF_H

View File

@ -1,26 +1,24 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <net/if.h> #include <net/if.h>
#include <netinet/in.h> #include <netinet/in.h>
/* Need to include netinet/in.h first on FreeBSD. */ // Need to include netinet/in.h first on FreeBSD.
#include <netinet/icmp6.h> #include <netinet/icmp6.h>
#include <netinet/ip6.h> #include <netinet/ip6.h>
#include <stddef.h> #include <stddef.h>
@ -64,7 +62,7 @@ extern bool nd_conf_keepalive;
static nd_iface_t *ndL_first_iface, *ndL_first_free_iface; static nd_iface_t *ndL_first_iface, *ndL_first_free_iface;
static nd_io_t *ndL_io; 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; bool nd_iface_no_restore_flags;
typedef struct 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)) if (msg->ip6_hdr.ip6_plen < sizeof(struct nd_neighbor_solicit))
return; 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) if (ntohs(msg->ip6_hdr.ip6_plen) - sizeof(struct nd_neighbor_solicit) < 8)
return; 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) static uint16_t ndL_calculate_icmp6_checksum(ndL_icmp6_msg_t *msg, size_t size)
{ {
/* IPv6 pseudo-header. */
struct __attribute__((packed)) struct __attribute__((packed))
{ {
struct in6_addr src; 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__ #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) static void ndL_io_handler(nd_io_t *io, __attribute__((unused)) int events)
{ {
struct sockaddr_ll lladdr; struct sockaddr_ll lladdr;
@ -229,7 +226,7 @@ static void ndL_io_handler(nd_io_t *io, __attribute__((unused)) int events)
} }
} }
#else #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) static void ndL_io_handler(nd_io_t *io, __attribute__((unused)) int events)
{ {
__attribute__((aligned(BPF_ALIGNMENT))) uint8_t buf[4096]; /* Depends on BIOCGBLEN */ __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 # define sock_fprog bpf_program
#endif #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[] = { static struct sock_filter filter[] = {
/* Load ether_type. */ /* Load ether_type. */
BPF_STMT(BPF_LD | BPF_H | BPF_ABS, offsetof(struct ether_header, 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) if (setsockopt(io->fd, SOL_SOCKET, SO_ATTACH_FILTER, &fprog, sizeof(fprog)) == -1)
return false; return false;
#else #else
# undef sock_filter
# undef sock_fprog
if (ioctl(io->fd, BIOCSETF, &fprog) == -1) if (ioctl(io->fd, BIOCSETF, &fprog) == -1)
return false; return false;
#endif #endif
@ -334,7 +334,7 @@ nd_iface_t *nd_iface_open(const char *name, unsigned int index)
return NULL; 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_iface_t *iface;
ND_LL_SEARCH(ndL_first_iface, iface, next, iface->index == index); 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__ #ifdef __linux__
/* Determine link-layer address. */ // Determine link-layer address.
struct ifreq ifr; struct ifreq ifr;
memset(&ifr, 0, sizeof(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))); uint8_t *lladdr = (uint8_t *)LLADDR((struct sockaddr_dl *)(sysctl_buf + sizeof(struct if_msghdr)));
#endif #endif
/* Allocate the nd_iface_t object. */
iface = ndL_first_free_iface; iface = ndL_first_free_iface;
if (iface != NULL) if (iface)
ND_LL_DELETE(ndL_first_free_iface, iface, next); ND_LL_DELETE(ndL_first_free_iface, iface, next);
else else
iface = ND_ALLOC(nd_iface_t); 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; struct ether_header *eh = (struct ether_header *)buf;
eh->ether_type = htons(ETHERTYPE_IPV6); eh->ether_type = htons(ETHERTYPE_IPV6);
/* TODO: Maybe use BIOCSHDRCMPLT instead. */
memcpy(eh->ether_shost, ifa->lladdr, ETHER_ADDR_LEN); memcpy(eh->ether_shost, ifa->lladdr, ETHER_ADDR_LEN);
memcpy(eh->ether_dhost, hwaddr, 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)); 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], nd_log_info("Write NA tgt=%s, dst=%s [%x:%x:%x:%x:%x:%x dev %s]", //
dst_ll[2], dst_ll[3], dst_ll[4], dst_ll[5], iface->name); 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); 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)))) if (!(ndL_io = nd_io_socket(AF_PACKET, SOCK_RAW, htons(ETH_P_IPV6))))
return false; return false;
/* Set up filter, so we only get NS and NA messages. */
if (!ndL_configure_filter(ndL_io)) if (!ndL_configure_filter(ndL_io))
{ {
nd_io_close(ndL_io); nd_io_close(ndL_io);

View File

@ -37,7 +37,7 @@ struct nd_iface
int old_promisc; int old_promisc;
nd_proxy_t *proxy; 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__ #ifndef __linux__
nd_io_t *bpf_io; nd_io_t *bpf_io;
@ -56,4 +56,4 @@ bool nd_iface_set_promisc(nd_iface_t *iface, bool on);
bool nd_iface_startup(); bool nd_iface_startup();
void nd_iface_cleanup(); void nd_iface_cleanup();
#endif /* NDPPD_IFACE_H */ #endif // NDPPD_IFACE_H

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef NDPPD_IO_H #ifndef NDPPD_IO_H
#define 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(); void nd_io_cleanup();
#endif /*NDPPD_IO_H*/ #endif // NDPPD_IO_H

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#include <assert.h> #include <assert.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef NDPPD_LOG_H #ifndef NDPPD_LOG_H
#define 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_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__) #define nd_log_debug(fmt, ...) nd_log_printf(ND_LOG_DEBUG, fmt, ##__VA_ARGS__)
#endif /* NDPPD_LOG_H */ #endif // NDPPD_LOG_H

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <getopt.h> #include <getopt.h>

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef NDPPD_H #ifndef NDPPD_H
#define NDPPD_H #define NDPPD_H
@ -86,4 +84,4 @@ extern bool nd_opt_daemonize;
#include "alloc.h" #include "alloc.h"
#include "log.h" #include "log.h"
#endif /* NDPPD_H */ #endif // NDPPD_H

View File

@ -1,22 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#include <string.h> #include <string.h>
#include "addr.h" #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, 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) 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], 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[2], src_ll[3], src_ll[4], src_ll[5], nd_aton(dst), nd_aton(tgt)); src_ll[3], src_ll[4], src_ll[5], nd_aton(dst), nd_aton(tgt));
nd_session_t *session; nd_session_t *session;
@ -86,8 +83,8 @@ void nd_proxy_handle_ns(nd_proxy_t *proxy, nd_addr_t *src, __attribute__((unused
return; return;
} }
/* If we get down here it means we don't have any valid sessions we can use. // 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. */ // See if we can find one more more matching rules.
nd_rule_t *rule; nd_rule_t *rule;
ND_LL_SEARCH(proxy->rules, rule, next, nd_addr_match(&rule->addr, tgt, rule->prefix)); 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) if (!route || route->oif == proxy->iface->index)
{ {
/* Could not find a matching route. */ // Could not find a matching route.
session->state = ND_STATE_INVALID; session->state = ND_STATE_INVALID;
return; return;
} }
if (!(session->iface = nd_iface_open(NULL, route->oif))) if (!(session->iface = nd_iface_open(NULL, route->oif)))
{ {
/* Could not open interface. */ // Could not open interface.
session->state = ND_STATE_INVALID; session->state = ND_STATE_INVALID;
return; return;
} }
@ -197,8 +194,8 @@ static void ndL_update_session(nd_proxy_t *proxy, nd_session_t *session)
} }
else else
{ {
/* We will only retransmit if nd_conf_keepalive is true, or if the last incoming NS // 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. */ // request was made less than nd_conf_valid_ttl milliseconds ago.
if (!nd_conf_keepalive && nd_current_time - session->atime > nd_conf_valid_ttl) if (!nd_conf_keepalive && nd_current_time - session->atime > nd_conf_valid_ttl)
break; break;

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef NDPPD_PROXY_H #ifndef NDPPD_PROXY_H
#define 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(); bool nd_proxy_startup();
void nd_proxy_update_all(); void nd_proxy_update_all();
#endif /* NDPPD_PROXY_H */ #endif // NDPPD_PROXY_H

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef NDPPD_RT_H #ifndef NDPPD_RT_H
#define NDPPD_RT_H #define NDPPD_RT_H

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#include "rule.h" #include "rule.h"
#include "ndppd.h" #include "ndppd.h"
#include "proxy.h" #include "proxy.h"

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef NDPPD_RULE_H #ifndef NDPPD_RULE_H
#define NDPPD_RULE_H #define NDPPD_RULE_H
@ -40,4 +38,4 @@ struct nd_rule
nd_rule_t *nd_rule_create(nd_proxy_t *proxy); nd_rule_t *nd_rule_create(nd_proxy_t *proxy);
#endif /* NDPPD_RULE_H */ #endif // NDPPD_RULE_H

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#include <string.h> #include <string.h>
#include "ndppd.h" #include "ndppd.h"

View File

@ -1,21 +1,19 @@
/* // This file is part of ndppd.
* This file is part of ndppd. //
* // Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se>
* Copyright (C) 2011-2019 Daniel Adolfsson <daniel@ashen.se> //
* // ndppd is free software: you can redistribute it and/or modify
* ndppd is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by
* it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or
* the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.
* (at your option) any later version. //
* // ndppd is distributed in the hope that it will be useful,
* ndppd is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of
* but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.
* GNU General Public License for more details. //
* // You should have received a copy of the GNU General Public License
* You should have received a copy of the GNU General Public License // along with ndppd. If not, see <https://www.gnu.org/licenses/>.
* along with ndppd. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef NDPPD_SESSION_H #ifndef NDPPD_SESSION_H
#define NDPPD_SESSION_H #define NDPPD_SESSION_H
@ -24,25 +22,15 @@
typedef enum typedef enum
{ {
/* //! Address resolution is in progress.
* Address resolution is in progress.
*/
ND_STATE_INCOMPLETE, ND_STATE_INCOMPLETE,
/*
*
*/
ND_STATE_VALID, ND_STATE_VALID,
/*
*
*/
ND_STATE_STALE, ND_STATE_STALE,
/* //! Resolution failed, and further Neighbor Solicitation messages will be ignored until
* Resolution failed, and further Neighbor Solicitation messages will be ignored until //! the session is removed or a Neighbor Advertisement is received.
* the session is removed or a Neighbor Advertisement is received.
*/
ND_STATE_INVALID, ND_STATE_INVALID,
} nd_state_t; } nd_state_t;
@ -53,15 +41,15 @@ struct nd_session
nd_session_t *next_in_iface; nd_session_t *next_in_iface;
nd_addr_t tgt; nd_addr_t tgt;
int rcount; int rcount;
long atime; /* Last time the session was used in a NA response. */ long atime; // Last time the session was used in a NA response.
long rtime; /* Last time a NS request was made. */ long rtime; // Last time a NS request was made.
long mtime; /* Last time state was changed. */ long mtime; // Last time state was changed.
nd_state_t state; nd_state_t state;
nd_iface_t *iface; nd_iface_t *iface;
nd_rt_route_t *route; /* Autowired route. */ nd_rt_route_t *route; // Autowired route.
}; };
nd_session_t *nd_alloc_session(); nd_session_t *nd_alloc_session();
void nd_free_session(nd_session_t *session); void nd_free_session(nd_session_t *session);
#endif /* NDPPD_SESSION_H */ #endif // NDPPD_SESSION_H