Mercurial > hg > dhcpcd
changeset 28:0d5ccf61c062 draft
Compiles on FreeBSD again
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Fri, 15 Dec 2006 00:00:18 +0000 |
| parents | 6b6fb3350708 |
| children | a637d87f54e5 |
| files | ChangeLog Makefile socket.c |
| diffstat | 3 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Dec 14 23:47:56 2006 +0000 +++ b/ChangeLog Fri Dec 15 00:00:18 2006 +0000 @@ -1,3 +1,6 @@ +Add new CFLAGS to ensure that the code quality is good. +Use const more in public functions. + dhcpcd-3.0.6 Don't set the broadcast flag anymore as all BPF and Linux sockets should be able to unicast correctly.
--- a/Makefile Thu Dec 14 23:47:56 2006 +0000 +++ b/Makefile Fri Dec 15 00:00:18 2006 +0000 @@ -3,6 +3,9 @@ VERSION = 3.0.7_pre1 INSTALL ?= install + +# Loads of nice flags to ensure our code is good +# And yes, we require C99 style code which means gcc-3 as a minimum CFLAGS = -O2 -pedantic -std=gnu99 \ -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \ -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
--- a/socket.c Thu Dec 14 23:47:56 2006 +0000 +++ b/socket.c Fri Dec 15 00:00:18 2006 +0000 @@ -294,7 +294,8 @@ return fd; } -int send_packet (interface_t *iface, int type, unsigned char *data, int len) +int send_packet (const interface_t *iface, int type, + const unsigned char *data, int len) { /* We only support ethernet atm */ struct ether_header hw; @@ -307,7 +308,7 @@ iov[0].iov_base = &hw; iov[0].iov_len = sizeof (struct ether_header); - iov[1].iov_base = data; + iov[1].iov_base = (unsigned char *) data; iov[1].iov_len = len; if ((retval = writev(iface->fd, iov, 2)) == -1) @@ -318,7 +319,7 @@ /* BPF requires that we read the entire buffer. So we pass the buffer in the API so we can loop on >1 dhcp packet. */ -int get_packet (interface_t *iface, unsigned char *data, +int get_packet (const interface_t *iface, unsigned char *data, unsigned char *buffer, int *buffer_len, int *buffer_pos) { unsigned char *buf = buffer; @@ -349,8 +350,8 @@ { /* Ensure that the entire packet is in our buffer */ if (*buffer_pos + packet->bh_hdrlen + packet->bh_caplen - > (unsigned) *buffer_len) - break; + > (unsigned) *buffer_len) + break; hw = (struct ether_header *) ((char *) packet + packet->bh_hdrlen); hdr = (unsigned char *) ((char *) hw + sizeof (struct ether_header)); @@ -430,7 +431,7 @@ close (fd); return -1; } - + if (iface->fd > -1) close (iface->fd); iface->fd = fd; @@ -467,7 +468,7 @@ /* 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. */ int get_packet (const interface_t *iface, unsigned char *data, - unsigned char *buffer, int *buffer_len, int *buffer_pos) + unsigned char *buffer, int *buffer_len, int *buffer_pos) { long bytes;
