continue;
/* Some systems send a reply back from our hwaddress,
- * which is weird */
+ * which is wierd */
if (reply->ar_hln == iface->hwlen &&
memcmp (rh.c, iface->hwaddr, iface->hwlen) == 0)
continue;
#endif
/* We need this for our maximum timeout as FreeBSD's select cannot handle
- any higher than this. Is there a better way of working this out? */
+ * any higher than this. Is there a better way of working this out? */
#define SELECT_MAX 100000000
/* This is out mini timeout.
- Basically we resend the last request every TIMEOUT_MINI seconds. */
+ * Basically we resend the last request every TIMEOUT_MINI seconds. */
#define TIMEOUT_MINI 3
/* Except for an infinite timeout. We keep adding TIMEOUT_MINI to
- ourself until TIMEOUT_MINI_INF is reached. */
+ * ourself until TIMEOUT_MINI_INF is reached. */
#define TIMEOUT_MINI_INF 60
#define STATE_INIT 0
state->state = STATE_INIT;
/* RFC 2131 says that we should wait for 10 seconds
- before doing anything else */
+ * before doing anything else */
logger (LOG_INFO, "sleeping for 10 seconds");
tv.tv_sec = 10;
tv.tv_usec = 0;
dhcpmessage_t message;
/* Allocate our buffer space for BPF.
- We cannot do this until we have opened our socket as we don't
- know how much of a buffer we need until then. */
+ * We cannot do this until we have opened our socket as we don't
+ * know how much of a buffer we need until then. */
if (! state->buffer)
state->buffer = xmalloc (iface->buffer_length);
state->buffer_len = iface->buffer_length;
state->buffer_pos = 0;
/* We loop through until our buffer is empty.
- The benefit is that if we get >1 DHCP packet in our buffer and
- the first one fails for any reason, we can use the next. */
+ * The benefit is that if we get >1 DHCP packet in our buffer and
+ * the first one fails for any reason, we can use the next. */
memset (&message, 0, sizeof (message));
new_dhcp = xmalloc (sizeof (*new_dhcp));
}
/* If we got here then the DHCP packet is valid and appears to
- be for us, so let's clear the buffer as we don't care about
- any more DHCP packets at this point. */
+ * be for us, so let's clear the buffer as we don't care about
+ * any more DHCP packets at this point. */
valid = true;
break;
} while (state->buffer_pos != 0);
for (address = dhcp->ntpservers; address; address = address->next)
tomatch++;
- /* Check that we really need to update the servers
- We do this because ntp has to be restarted to work with a changed config */
+ /* Check that we really need to update the servers.
+ * We do this because ntp has to be restarted to
+ * work with a changed config. */
if (! (f = fopen (file, "r"))) {
if (errno != ENOENT) {
logger (LOG_ERR, "fopen `%s': %s",
static int make_ntp (const char *ifname, const dhcp_t *dhcp)
{
- /* On some systems we have only have one ntp service, but we don't know
- which configuration file we're using. So we need to write to both and
- restart accordingly. */
+ /* On some systems we have only have one ntp service, but we don't
+ * know which configuration file we're using. So we need to write
+ * to both and restart accordingly. */
bool restart_ntp = false;
bool restart_openntp = false;
if (dhcp->address.s_addr == 0)
up = 0;
- /* Remove old routes
- Always do this as the interface may have >1 address not added by us
- so the routes we added may still exist */
+ /* Remove old routes.
+ * Always do this as the interface may have >1 address not added by us
+ * so the routes we added may still exist. */
for (route = iface->previous_routes; route; route = route->next)
if ((route->destination.s_addr || options->dogateway) &&
(! up || ! in_routes (dhcp->routes, route)))
}
/* Set the MTU requested.
- If the DHCP server no longer sends one OR it's invalid then
- we restore the original MTU */
+ * If the DHCP server no longer sends one OR it's invalid then
+ * we restore the original MTU */
if (options->domtu) {
unsigned short mtu = iface->mtu;
if (dhcp->mtu)
return (0);
}
-
*p++ = 0;
/* Only request DNSSERVER in discover to keep the packets small.
- RFC2131 Section 3.5 states that the REQUEST must include the
- list from the DISCOVER message, so I think this is ok. */
+ * RFC2131 Section 3.5 states that the REQUEST must include the
+ * list from the DISCOVER message, so I think this is ok. */
if (type == DHCP_DISCOVER && ! options->test)
*p++ = DHCP_DNSSERVER;
#ifdef BOOTP_MESSAGE_LENTH_MIN
/* Some crappy DHCP servers think they have to obey the BOOTP minimum
- * messag length. They are wrong, but we should still cater for them */
+ * message length.
+ * They are wrong, but we should still cater for them. */
while (p - m < BOOTP_MESSAGE_LENTH_MIN)
*p++ = DHCP_PAD;
#endif
}
/* Decode an RFC3397 DNS search order option into a space
- seperated string. Returns length of string (including
- terminating zero) or zero on error. out may be NULL
- to just determine output length. */
+ * seperated string. Returns length of string (including
+ * terminating zero) or zero on error. out may be NULL
+ * to just determine output length. */
static unsigned int decode_search (const unsigned char *p, int len, char *out)
{
const unsigned char *r, *q = p;
~dhcp->netmask.s_addr;
/* If we have classess static routes then we discard
- static routes and routers according to RFC 3442 */
+ * static routes and routers according to RFC 3442 */
if (csr) {
dhcp->routes = csr;
free_route (mscsr);
#elif __linux__
/* This netlink stuff is overly compex IMO.
- The BSD implementation is much cleaner and a lot less code.
- send_netlink handles the actual transmission so we can work out
- if there was an error or not.
- */
+ * The BSD implementation is much cleaner and a lot less code.
+ * send_netlink handles the actual transmission so we can work out
+ * if there was an error or not. */
#define BUFFERLEN 256
static int send_netlink(struct nlmsghdr *hdr)
{
#include "socket.h"
/* A suitably large buffer for all transactions.
- BPF buffer size is set by the kernel, so no define. */
+ * BPF buffer size is set by the kernel, so no define. */
#ifdef __linux__
# define BUFFER_LENGTH 4096
#endif
};
/* Credit where credit is due :)
- The below BPF filter is taken from ISC DHCP */
+ * The below BPF filter is taken from ISC DHCP */
static struct bpf_insn dhcp_bpf_filter [] = {
/* Make sure this is an IP packet... */
BPF_STMT (BPF_LD | BPF_H | BPF_ABS, 12),
struct udphdr *udp = &packet->udp;
/* OK, this is important :)
- We copy the data to our packet and then create a small part of the
- ip structure and an invalid ip_len (basically udp length).
- We then fill the udp structure and put the checksum
- of the whole packet into the udp checksum.
- Finally we complete the ip structure and ip checksum.
- If we don't do the ordering like so then the udp checksum will be
- broken, so find another way of doing it! */
+ * We copy the data to our packet and then create a small part of the
+ * ip structure and an invalid ip_len (basically udp length).
+ * We then fill the udp structure and put the checksum
+ * of the whole packet into the udp checksum.
+ * Finally we complete the ip structure and ip checksum.
+ * If we don't do the ordering like so then the udp checksum will be
+ * broken, so find another way of doing it! */
memcpy (&packet->dhcp, data, length);
}
/* BPF requires that we read the entire buffer.
- So we pass the buffer in the API so we can loop on >1 dhcp packet. */
+ * So we pass the buffer in the API so we can loop on >1 dhcp packet. */
ssize_t get_packet (const interface_t *iface, unsigned char *data,
unsigned char *buffer,
size_t *buffer_len, size_t *buffer_pos)
}
/* Linux has no need for the buffer as we can read as much as we want.
- We only have the buffer listed to keep the same API. */
+ * We only have the buffer listed to keep the same API. */
ssize_t get_packet (const interface_t *iface, unsigned char *data,
unsigned char *buffer,
size_t *buffer_len, size_t *buffer_pos)