const unsigned char *taddr, struct in_addr tip)
{
struct arphdr *arp;
- int arpsize = arphdr_len2 (iface->hwlen, sizeof (struct in_addr));
+ size_t arpsize = arphdr_len2 (iface->hwlen, sizeof (struct in_addr));
caddr_t tha;
int retval;
arp->ar_hln = iface->hwlen;
arp->ar_pln = sizeof (struct in_addr);
arp->ar_op = htons (op);
- memcpy (ar_sha (arp), iface->hwaddr, arp->ar_hln);
- memcpy (ar_spa (arp), &sip, arp->ar_pln);
+ memcpy (ar_sha (arp), iface->hwaddr, (size_t) arp->ar_hln);
+ memcpy (ar_spa (arp), &sip, (size_t) arp->ar_pln);
if (taddr) {
/* NetBSD can return NULL from ar_tha, which is probably wrong
* but we still need to deal with it */
errno = EINVAL;
return (-1);
}
- memcpy (tha, taddr, arp->ar_hln);
+ memcpy (tha, taddr, (size_t) arp->ar_hln);
}
- memcpy (ar_tpa (arp), &tip, arp->ar_pln);
+ memcpy (ar_tpa (arp), &tip, (size_t) arp->ar_pln);
retval = send_packet (iface, ETHERTYPE_ARP,
(unsigned char *) arp, arphdr_len (arp));
for (;;) {
struct timeval tv;
- int bufpos = -1;
- int buflen = iface->buffer_length;
+ size_t bufpos = 0;
+ size_t buflen = iface->buffer_length;
fd_set rset;
int bytes;
int s = 0;
continue;
memset (buffer, 0, buflen);
- while (bufpos != 0) {
+ do {
union {
unsigned char *c;
struct in_addr *a;
logger (LOG_ERR, "ARPOP_REPLY received from %s (%s)",
inet_ntoa (*rp.a),
- hwaddr_ntoa (rh.c, reply->ar_hln));
+ hwaddr_ntoa (rh.c, (size_t) reply->ar_hln));
retval = -1;
goto eexit;
- }
+ } while (bufpos != 0);
}
eexit:
#ifdef THERE_IS_NO_FORK
# ifndef ENABLE_INFO
-# error "Non MMU requires ENABLE_INFO to work"
+ # error "Non MMU requires ENABLE_INFO to work"
# endif
#endif
time_t last_sent;
time_t last_type;
long timeout;
- long nakoff;
+ time_t nakoff;
bool daemonised;
bool persistent;
unsigned char *buffer;
- ssize_t buffer_len;
- ssize_t buffer_pos;
+ size_t buffer_len;
+ size_t buffer_pos;
} state_t;
static pid_t daemonise (int *pidfd)
else
tv.tv_sec = TIMEOUT_MINI;
if (state->timeout < tv.tv_sec)
- tv.tv_sec = state->timeout;
+ tv.tv_sec = (time_t) state->timeout;
tv.tv_usec = 0;
state->start = uptime ();
maxfd = signal_fd_set (rset, iface->fd);
logger (LOG_INFO, "received SIGHUP, releasing lease");
if (! IN_LINKLOCAL (ntohl (state->dhcp->address.s_addr))) {
do_socket (state, SOCKET_OPEN);
- state->xid = random ();
+ state->xid = (uint32_t) random ();
if ((open_socket (state->interface, false)) >= 0)
_send_message (state, DHCP_RELEASE, options);
do_socket (state, SOCKET_CLOSED);
switch (state->state) {
case STATE_INIT:
- state->xid = random ();
+ state->xid = (uint32_t) random ();
do_socket (state, SOCKET_OPEN);
state->timeout = options->timeout;
iface->start_uptime = uptime ();
break;
}
state->state = STATE_RENEWING;
- state->xid = random ();
+ state->xid = (uint32_t) random ();
+ /* FALLTHROUGH */
case STATE_RENEWING:
iface->start_uptime = uptime ();
logger (LOG_INFO, "renewing lease of %s", inet_ntoa
memset (&dhcp->address, 0, sizeof (struct in_addr));
do_socket (state, SOCKET_OPEN);
if (state->xid == 0)
- state->xid = random ();
+ state->xid = (uint32_t) random ();
_send_message (state, DHCP_REQUEST, options);
state->timeout = dhcp->leasetime - dhcp->rebindtime;
state->state = STATE_REQUESTING;
break;
case STATE_RELEASED:
- dhcp->leasetime = -1;
+ dhcp->leasetime = 0;
break;
}
/* If we constantly get NAKS then we should slowly back off */
if (state->nakoff > 0) {
logger (LOG_DEBUG, "sleeping for %ld seconds",
- state->nakoff);
+ (long) state->nakoff);
tv.tv_sec = state->nakoff;
tv.tv_usec = 0;
state->nakoff *= 2;
if (! state->buffer)
state->buffer = xmalloc (iface->buffer_length);
state->buffer_len = iface->buffer_length;
- state->buffer_pos = -1;
+ 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
memset (&message, 0, sizeof (struct dhcpmessage_t));
new_dhcp = xmalloc (sizeof (dhcp_t));
- while (state->buffer_pos != 0) {
+ do {
if (get_packet (iface, (unsigned char *) &message,
state->buffer,
&state->buffer_len, &state->buffer_pos) == -1)
any more DHCP packets at this point. */
valid = true;
break;
- }
+ } while (state->buffer_pos != 0);
/* No packets for us, so wait until we get one */
if (! valid) {
void writepid (int fd, pid_t pid)
{
char spid[16];
- if (ftruncate (fd, 0) == -1) {
+ if (ftruncate (fd, (off_t) 0) == -1) {
logger (LOG_ERR, "ftruncate: %s", strerror (errno));
} else {
ssize_t len;
snprintf (spid, sizeof (spid), "%u", pid);
- len = pwrite (fd, spid, strlen (spid), 0);
+ len = pwrite (fd, spid, strlen (spid), (off_t) 0);
if (len != (ssize_t) strlen (spid))
logger (LOG_ERR, "pwrite: %s", strerror (errno));
}
return (value);
logger (LOG_ERR, "memory exhausted");
+
exit (EXIT_FAILURE);
+ /* NOTREACHED */
}
void *xrealloc (void *ptr, size_t s)
logger (LOG_ERR, "memory exhausted");
exit (EXIT_FAILURE);
+ /* NOTREACHED */
}
char *xstrdup (const char *str)
logger (LOG_ERR, "memory exhausted");
exit (EXIT_FAILURE);
+ /* NOTREACHED */
}
-
# define NISRESTARTARGS "--nodeps", "--quiet", "conditionalrestart"
# define NTPSERVICE ETCDIR "/init.d/ntpd"
# define NTPRESTARTARGS "--nodeps", "--quiet", "conditionalrestart"
-#elif ENABLE_BSDRC
+#endif
+#if ENABLE_BSDRC
# define SERVICE "BSDRC"
# define NISSERVICE ETCDIR "/rc.d/ypbind"
# define NISRESTARTARGS "restart"
# define NTPSERVICE ETCDIR "/rc.d/ntpd"
# define NTPRESTARTARGS "restart"
-#elif ENABLE_SLACKRC
+#endif
+#if ENABLE_SLACKRC
# define SERVICE "SLACKRC"
# define NISSERVICE ETCDIR "/rc.d/rc.ypbind"
# define NISRESTARTARGS "restart"
# define NTPSERVICE ETCDIR "/rc.d/rc.ntpd"
# define NTPRESTARTARGS "restart"
-#elif ENABLE_SERVICE
+#endif
+#if ENABLE_SERVICE
# define SERVICE "SERVICE"
# define NISSERVICE "service"
# define NISRESTARTARGS "ypbind", "restart"
# define NTPSERVICE "service"
# define NTPRESTARTARGS "ntpd", "restart"
-#elif ENABLE_SYSV
+#endif
+#if ENABLE_SYSV
# define SERVICE "SYSV"
# define NISSERVICE ETCDIR "/init.d/ypbind"
# define NISRESTARTARGS "restart"
# define NTPSERVICE ETCDIR "/init.d/ntpd"
# define NTPRESTARTARGS "restart"
-#else
+#endif
+
+#ifndef NISSERVICE
# undef ENABLE_NIS
+#endif
+#ifndef NTPSERVICE
# undef ENABLE_NTP
#endif
fprintf (f, "# Generated by dhcpcd for interface %s\n", ifname);
if (dhcp->nisdomain) {
- setdomainname (dhcp->nisdomain, strlen (dhcp->nisdomain));
+ setdomainname (dhcp->nisdomain, (int) strlen (dhcp->nisdomain));
if (dhcp->nisservers)
snprintf (prefix, PREFIXSIZE, "domain %s server",
if (*newhostname) {
logger (LOG_INFO, "setting hostname to `%s'",
newhostname);
- sethostname (newhostname, strlen (newhostname));
+ sethostname (newhostname, (int) strlen (newhostname));
}
free (newhostname);
}
ssize_t send_message (const interface_t *iface, const dhcp_t *dhcp,
- unsigned long xid, char type,
+ uint32_t xid, char type,
const options_t *options)
{
struct udp_dhcp_packet *packet;
unsigned char *m;
unsigned char *p;
unsigned char *n_params = NULL;
- unsigned long l;
+ size_t l;
struct in_addr from;
struct in_addr to;
time_t up = uptime() - iface->start_uptime;
uint32_t ul;
uint16_t sz;
- unsigned int message_length;
+ size_t message_length;
ssize_t retval;
if (!iface || !options || !dhcp)
memcpy (p, options->clientid, options->clientid_len);
p += options->clientid_len;
#ifdef ENABLE_DUID
- } else if (iface->duid && options->clientid_len != -1) {
+ } else if (iface->duid && options->doduid) {
*p++ = iface->duid_length + 5;
*p++ = 255; /* RFC 4361 */
from, to);
free (message);
- logger (LOG_DEBUG, "sending %s with xid 0x%lx",
+ logger (LOG_DEBUG, "sending %s with xid 0x%x",
dhcp_message (type), xid);
retval = send_packet (iface, ETHERTYPE_IP, (unsigned char *) packet,
message_length + sizeof (struct ip) +
ocets = (cidr + 7) / 8;
if (ocets > 0) {
- memcpy (&route->destination.s_addr, q, ocets);
+ memcpy (&route->destination.s_addr, q, (size_t) ocets);
q += ocets;
}
/* Now enter the netmask */
if (ocets > 0) {
- memset (&route->netmask.s_addr, 255, ocets - 1);
+ memset (&route->netmask.s_addr, 255, (size_t) ocets - 1);
memset ((unsigned char *) &route->netmask.s_addr +
(ocets - 1),
(256 - (1 << (32 - cidr) % 8)), 1);
char *p;
const char encoding = *data++;
struct in_addr addr;
- int len;
+ size_t len;
length--;
/* This calculates the netmask that we should use for static routes.
* This IS different from the calculation used to calculate the netmask
* for an interface address. */
-static unsigned long route_netmask (unsigned long ip_in)
+static uint32_t route_netmask (uint32_t ip_in)
{
- unsigned long p = ntohl (ip_in);
- unsigned long t;
+ /* used to be unsigned long - check if error */
+ uint32_t p = ntohl (ip_in);
+ uint32_t t;
if (IN_CLASSA (p))
t = ~IN_CLASSA_NET;
#define GETSTR(_var) { \
MIN_LENGTH (sizeof (char)); \
if (_var) free (_var); \
- _var = xmalloc (length + 1); \
- memcpy (_var, p, length); \
+ _var = xmalloc ((size_t) length + 1); \
+ memcpy (_var, p, (size_t) length); \
memset (_var + length, 0, 1); \
}
case DHCP_HOSTNAME:
struct in_addr broadcast;
unsigned short mtu;
- unsigned int leasedfrom;
- unsigned int leasetime;
- unsigned int renewaltime;
- unsigned int rebindtime;
+ uint32_t leasedfrom;
+ uint32_t leasetime;
+ uint32_t renewaltime;
+ uint32_t rebindtime;
route_t *routes;
};
ssize_t send_message (const interface_t *iface, const dhcp_t *dhcp,
- unsigned long xid, char type,
+ uint32_t xid, char type,
const options_t *options);
void free_dhcp (dhcp_t *dhcp);
int parse_dhcpmessage (dhcp_t *dhcp, const dhcpmessage_t *message);
return (-1);
}
- return (n);
+ return ((int) n);
}
static pid_t read_pid (const char *pidfile)
options->daemonise = true;
options->doinform = false;
options->doipv4ll = true;
+ options->doduid = true;
options->timeout = DEFAULT_TIMEOUT;
gethostname (options->hostname, sizeof (options->hostname));
"option `%s' should set a flag",
longopts[option_index].name);
goto abort;
- break;
case 'c':
options->script = optarg;
break;
sig = SIGHUP;
break;
case 'l':
- options->leasetime = atoint (optarg);
- if (options->leasetime <= 0) {
+ if (*optarg == '-') {
logger (LOG_ERR,
"leasetime must be a positive value");
goto abort;
}
+ errno = 0;
+ options->leasetime = (uint32_t) strtol (optarg, NULL, 0);
+ if (errno == EINVAL || errno == ERANGE) {
+ logger (LOG_ERR, "`%s' out of range", optarg);
+ goto abort;
+ }
break;
case 'm':
options->metric = atoint (optarg);
goto abort;
}
}
- /* fall through */
}
+ /* FALLTHROUGH */
case 'r':
if (! options->doinform)
options->dorequest = true;
sizeof (options->clientid));
/* empty string disabled duid */
if (options->clientid_len == 0)
- options->clientid_len = -1;
+ options->doduid = false;
+
} else {
memset (options->clientid, 0, sizeof (options->clientid));
- options->clientid_len = -1;
+ options->doduid = false;
}
break;
case 'L':
logger (LOG_INFO, "exiting");
exit (retval);
+ /* NOTREACHED */
}
char hostname[MAXHOSTNAMELEN];
int fqdn;
char classid[CLASS_ID_MAX_LEN];
- int classid_len;
+ size_t classid_len;
char clientid[CLIENT_ID_MAX_LEN];
- int clientid_len;
+ size_t clientid_len;
char userclass[USERCLASS_MAX_LEN];
- int userclass_len;
- unsigned leasetime;
+ size_t userclass_len;
+ uint32_t leasetime;
time_t timeout;
int metric;
bool doinform;
bool dorequest;
bool doipv4ll;
+ bool doduid;
int domscsr;
struct in_addr request_address;
if (! (fp = fopen (DUIDFILE, "w")))
logger (LOG_ERR, "fopen `%s': %s", DUIDFILE, strerror (errno));
else {
- int i;
+ size_t i;
for (i = 0; i < iface->duid_length; i++)
x += fprintf (fp, "%.2X", iface->duid[i]);
fprintf (fp, "\n");
free (clean);
}
#ifdef ENABLE_DUID
- else if (iface->duid_length > 0 && options->clientid_len != -1) {
+ else if (iface->duid_length > 0 && options->doduid) {
unsigned char *duid;
unsigned char *p;
uint32_t ul;
memcpy (p, iface->duid, iface->duid_length);
p += iface->duid_length;
- fprintf (f, "CLIENTID='%s'\n", hwaddr_ntoa (duid, p - duid));
+ fprintf (f, "CLIENTID='%s'\n", hwaddr_ntoa (duid,
+ (size_t) (p - duid)));
free (duid);
}
#endif
memset (addr, 0, sizeof (struct in_addr));
if (ocets > 0) {
- memset (&addr->s_addr, 255, ocets - 1);
+ memset (&addr->s_addr, 255, (size_t) ocets - 1);
memset ((unsigned char *) &addr->s_addr + (ocets - 1),
(256 - (1 << (32 - cidr) % 8)), 1);
}
return (0);
}
-unsigned long get_netmask (unsigned long addr)
+uint32_t get_netmask (uint32_t addr)
{
- unsigned long dst;
+ uint32_t dst;
if (addr == 0)
return (0);
return (0);
}
-char *hwaddr_ntoa (const unsigned char *hwaddr, int hwlen)
+char *hwaddr_ntoa (const unsigned char *hwaddr, size_t hwlen)
{
static char buffer[(HWADDR_LEN * 3) + 1];
char *p = buffer;
- int i;
+ size_t i;
for (i = 0; i < hwlen && i < HWADDR_LEN; i++) {
if (i > 0)
}
static int _do_interface (const char *ifname,
- unsigned char *hwaddr, int *hwlen,
+ unsigned char *hwaddr, size_t *hwlen,
struct in_addr *addr,
bool flush, bool get)
{
memset (&ifc, 0, sizeof (struct ifconf));
for (;;) {
ifc.ifc_len = len;
- ifc.ifc_buf = xmalloc (len);
+ ifc.ifc_buf = xmalloc ((size_t) len);
if (ioctl (s, SIOCGIFCONF, &ifc) == -1) {
if (errno != EINVAL || lastlen != 0) {
logger (LOG_ERR, "ioctl SIOCGIFCONF: %s",
sizeof (struct sockaddr_dl));
*hwlen = sdl.sdl_alen;
memcpy (hwaddr, sdl.sdl_data + sdl.sdl_nlen,
- sdl.sdl_alen);
+ (size_t) sdl.sdl_alen);
retval = 1;
break;
}
struct ifreq ifr;
interface_t *iface = NULL;
unsigned char *hwaddr = NULL;
- int hwlen = 0;
+ size_t hwlen = 0;
sa_family_t family = 0;
unsigned short mtu;
#ifdef __linux__
static void log_route (struct in_addr destination,
struct in_addr netmask,
struct in_addr gateway,
- int metric,
+ __unused int metric,
int change, int del)
{
char *dstd = xstrdup (inet_ntoa (destination));
#define METRIC " metric %d"
#else
#define METRIC ""
- metric = 0;
#endif
if (gateway.s_addr == destination.s_addr ||
struct sockaddr_storage ss;
} su;
- int l;
+ size_t l;
if (! ifname)
return -1;
{
/* Make us a link layer socket */
unsigned char *hwaddr;
- int hwlen = 0;
+ size_t hwlen = 0;
if (netmask.s_addr == INADDR_BROADCAST)
rtm.hdr.rtm_flags |= RTF_HOST;
su.sdl.sdl_len = sizeof (struct sockaddr_dl);
su.sdl.sdl_family = AF_LINK;
su.sdl.sdl_nlen = strlen (ifname);
- memcpy (&su.sdl.sdl_data, ifname, su.sdl.sdl_nlen);
+ memcpy (&su.sdl.sdl_data, ifname, (size_t) su.sdl.sdl_nlen);
su.sdl.sdl_alen = hwlen;
memcpy (((unsigned char *) &su.sdl.sdl_data) + su.sdl.sdl_nlen,
- hwaddr, su.sdl.sdl_alen);
+ hwaddr, (size_t) su.sdl.sdl_alen);
l = SA_SIZE (&(su.sa));
memcpy (bp, &su, l);
}
#else
-# error "Platform not supported!"
-# error "We currently support BPF and Linux sockets."
-# error "Other platforms may work using BPF. If yours does, please let me know"
-# error "so I can add it to our list."
+ #error "Platform not supported!"
+ #error "We currently support BPF and Linux sockets."
+ #error "Other platforms may work using BPF. If yours does, please let me know"
+ #error "so I can add it to our list."
#endif
int add_address (const char *ifname, struct in_addr address,
return (_do_interface (ifname, NULL, NULL, NULL, true, false));
}
-unsigned long get_address (const char *ifname)
+in_addr_t get_address (const char *ifname)
{
struct in_addr address;
if (_do_interface (ifname, NULL, NULL, &address, false, true) > 0)
char name[IF_NAMESIZE];
sa_family_t family;
unsigned char hwaddr[HWADDR_LEN];
- int hwlen;
+ size_t hwlen;
bool arpable;
unsigned short mtu;
int fd;
- int buffer_length;
+ size_t buffer_length;
#ifdef __linux__
int socket_protocol;
#ifdef ENABLE_DUID
unsigned char duid[DUID_LEN];
- int duid_length;
+ size_t duid_length;
#endif
} interface_t;
void free_address (address_t *addresses);
void free_route (route_t *routes);
-unsigned long get_netmask (unsigned long addr);
-char *hwaddr_ntoa (const unsigned char *hwaddr, int hwlen);
+uint32_t get_netmask (uint32_t addr);
+char *hwaddr_ntoa (const unsigned char *hwaddr, size_t hwlen);
interface_t *read_interface (const char *ifname, int metric);
int get_mtu (const char *ifname);
int set_mtu (const char *ifname, short int mtu);
int add_address (const char *ifname, struct in_addr address,
- struct in_addr netmask, struct in_addr broadcast);
+ struct in_addr netmask, struct in_addr broadcast);
int del_address (const char *ifname, struct in_addr address,
struct in_addr netmask);
int flush_addresses (const char *ifname);
-unsigned long get_address (const char *ifname);
+in_addr_t get_address (const char *ifname);
int has_address (const char *ifname, struct in_addr address);
int add_route (const char *ifname, struct in_addr destination,
#ifdef ENABLE_IPV4LL
#ifndef ENABLE_ARP
-#error IPV4LL requires ARP
+ # error IPV4LL requires ARP
#endif
#define IPV4LL_LEASETIME 20
for (;;) {
addr.s_addr = htonl (LINKLOCAL_ADDR |
- ((abs (random ()) % 0xFD00) + 0x0100));
+ (((uint32_t) abs ((int) random ())
+ % 0xFD00) + 0x0100));
errno = 0;
if (! arp_claim (iface, addr))
break;
}
if (level < LOG_DEBUG || level <= loglevel) {
- int len = strlen (logprefix);
- int fmt2len = strlen (fmt) + len + 1;
+ size_t len = strlen (logprefix);
+ size_t fmt2len = strlen (fmt) + len + 1;
char *fmt2 = malloc (sizeof (char) * fmt2len);
char *pf = fmt2;
if (fmt2) {
#ifdef __GNUC__
# define _PRINTF_LIKE(_one, _two) __attribute__ ((__format__ (__printf__, _one, _two)))
+#else
+# define _PRINTF_LIKE(_one, _two)
#endif
#include <syslog.h>
clean:
rm -f ${OBJS} ${PROG} ${CLEANFILES}
+
+LINTFLAGS?= -hx
+LINTFLAGS+= -X 159,247,352
+
+lint: ${SRCS:.c=.c}
+ ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} $^ ${.ALLSRC}
}
void make_dhcp_packet(struct udp_dhcp_packet *packet,
- const unsigned char *data, int length,
+ const unsigned char *data, size_t length,
struct in_addr source, struct in_addr dest)
{
struct ip *ip = &packet->ip;
}
ssize_t send_packet (const interface_t *iface, int type,
- const unsigned char *data, int len)
+ const unsigned char *data, size_t len)
{
ssize_t retval = -1;
struct iovec iov[2];
/* BPF requires that we read the entire buffer.
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, int *buffer_len, int *buffer_pos)
+ unsigned char *buffer,
+ size_t *buffer_len, size_t *buffer_pos)
{
union
{
bpf.buffer += *buffer_pos;
while (bpf.packet) {
- ssize_t len = -1;
+ size_t len = 0;
union
{
unsigned char *buffer;
struct ether_header *hw;
} hdr;
unsigned char *payload;
+ bool have_data = false;
/* Ensure that the entire packet is in our buffer */
if (*buffer_pos + bpf.packet->bh_hdrlen + bpf.packet->bh_caplen
len = bpf.packet->bh_caplen -
sizeof (struct ether_header);
memcpy (data, payload, len);
+ have_data = true;
} else {
if (valid_dhcp_packet (payload) >= 0) {
union
sizeof (struct ip) -
sizeof (struct udphdr);
memcpy (data, &pay.packet->dhcp, len);
+ have_data = true;
}
}
/* Update the buffer_pos pointer */
bpf.buffer += BPF_WORDALIGN (bpf.packet->bh_hdrlen +
bpf.packet->bh_caplen);
- if (bpf.buffer - buffer < *buffer_len)
+ if ((unsigned) (bpf.buffer - buffer) < *buffer_len)
*buffer_pos = bpf.buffer - buffer;
else
*buffer_pos = 0;
- if (len != -1)
+ if (have_data)
return len;
if (*buffer_pos == 0)
return fd;
}
-ssize_t send_packet (const interface_t *iface, const int type,
- const unsigned char *data, const int len)
+ssize_t send_packet (const interface_t *iface, int type,
+ const unsigned char *data, size_t len)
{
union sockunion {
struct sockaddr sa;
/* 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. */
ssize_t get_packet (const interface_t *iface, unsigned char *data,
- unsigned char *buffer, int *buffer_len, int *buffer_pos)
+ unsigned char *buffer,
+ size_t *buffer_len, size_t *buffer_pos)
{
ssize_t bytes;
union
}
#else
-# error "Platform not supported!"
-# error "We currently support BPF and Linux sockets."
-# error "Other platforms may work using BPF. If yours does, please let me know"
-# error "so I can add it to our list."
+ #error "Platform not supported!"
+ #error "We currently support BPF and Linux sockets."
+ #error "Other platforms may work using BPF. If yours does, please let me know"
+ #error "so I can add it to our list."
#endif
#include "interface.h"
void make_dhcp_packet(struct udp_dhcp_packet *packet,
- const unsigned char *data, int length,
+ const unsigned char *data, size_t length,
struct in_addr source, struct in_addr dest);
int open_socket (interface_t *iface, bool arp);
ssize_t send_packet (const interface_t *iface, int type,
- const unsigned char *data, int len);
+ const unsigned char *data, size_t len);
ssize_t get_packet (const interface_t *iface, unsigned char *data,
- unsigned char *buffer, int *buffer_len, int *buffer_pos);
+ unsigned char *buffer, size_t *buffer_len, size_t *buffer_pos);
#endif