Use standard C99 types

This commit is contained in:
Eric Andersen 2004-01-30 23:45:53 +00:00
parent 1a834be1ce
commit ad95373efc
19 changed files with 117 additions and 117 deletions

View File

@ -29,7 +29,7 @@
*/ */
/* FIXME: match response against chaddr */ /* FIXME: match response against chaddr */
int arpping(u_int32_t yiaddr, u_int32_t ip, unsigned char *mac, char *interface) int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
{ {
int timeout = 2; int timeout = 2;
@ -91,7 +91,7 @@ int arpping(u_int32_t yiaddr, u_int32_t ip, unsigned char *mac, char *interface)
if (recv(s, &arp, sizeof(arp), 0) < 0 ) rv = 0; if (recv(s, &arp, sizeof(arp), 0) < 0 ) rv = 0;
if (arp.operation == htons(ARPOP_REPLY) && if (arp.operation == htons(ARPOP_REPLY) &&
bcmp(arp.tHaddr, mac, 6) == 0 && bcmp(arp.tHaddr, mac, 6) == 0 &&
*((u_int *) arp.sInaddr) == yiaddr) { *((uint32_t *) arp.sInaddr) == yiaddr) {
DEBUG(LOG_INFO, "Valid arp reply receved for this address"); DEBUG(LOG_INFO, "Valid arp reply receved for this address");
rv = 0; rv = 0;
break; break;

View File

@ -12,19 +12,19 @@
struct arpMsg { struct arpMsg {
struct ethhdr ethhdr; /* Ethernet header */ struct ethhdr ethhdr; /* Ethernet header */
u_short htype; /* hardware type (must be ARPHRD_ETHER) */ uint16_t htype; /* hardware type (must be ARPHRD_ETHER) */
u_short ptype; /* protocol type (must be ETH_P_IP) */ uint16_t ptype; /* protocol type (must be ETH_P_IP) */
u_char hlen; /* hardware address length (must be 6) */ uint8_t hlen; /* hardware address length (must be 6) */
u_char plen; /* protocol address length (must be 4) */ uint8_t plen; /* protocol address length (must be 4) */
u_short operation; /* ARP opcode */ uint16_t operation; /* ARP opcode */
u_char sHaddr[6]; /* sender's hardware address */ uint8_t sHaddr[6]; /* sender's hardware address */
u_char sInaddr[4]; /* sender's IP address */ uint8_t sInaddr[4]; /* sender's IP address */
u_char tHaddr[6]; /* target's hardware address */ uint8_t tHaddr[6]; /* target's hardware address */
u_char tInaddr[4]; /* target's IP address */ uint8_t tInaddr[4]; /* target's IP address */
u_char pad[18]; /* pad for min. Ethernet payload (60 bytes) */ uint8_t pad[18]; /* pad for min. Ethernet payload (60 bytes) */
}; };
/* function prototypes */ /* function prototypes */
int arpping(u_int32_t yiaddr, u_int32_t ip, unsigned char *arp, char *interface); int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *arp, char *interface);
#endif #endif

View File

@ -78,7 +78,7 @@ static void init_packet(struct dhcpMessage *packet, char type)
memcpy(packet->chaddr, client_config.arp, 6); memcpy(packet->chaddr, client_config.arp, 6);
add_option_string(packet->options, client_config.clientid); add_option_string(packet->options, client_config.clientid);
if (client_config.hostname) add_option_string(packet->options, client_config.hostname); if (client_config.hostname) add_option_string(packet->options, client_config.hostname);
add_option_string(packet->options, (unsigned char *) &vendor_id); add_option_string(packet->options, (uint8_t *) &vendor_id);
} }
@ -179,8 +179,8 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
{ {
int bytes; int bytes;
struct udp_dhcp_packet packet; struct udp_dhcp_packet packet;
u_int32_t source, dest; uint32_t source, dest;
u_int16_t check; uint16_t check;
memset(&packet, 0, sizeof(struct udp_dhcp_packet)); memset(&packet, 0, sizeof(struct udp_dhcp_packet));
bytes = read(fd, &packet, sizeof(struct udp_dhcp_packet)); bytes = read(fd, &packet, sizeof(struct udp_dhcp_packet));
@ -207,7 +207,7 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
if (packet.ip.protocol != IPPROTO_UDP || packet.ip.version != IPVERSION || if (packet.ip.protocol != IPPROTO_UDP || packet.ip.version != IPVERSION ||
packet.ip.ihl != sizeof(packet.ip) >> 2 || packet.udp.dest != htons(CLIENT_PORT) || packet.ip.ihl != sizeof(packet.ip) >> 2 || packet.udp.dest != htons(CLIENT_PORT) ||
bytes > (int) sizeof(struct udp_dhcp_packet) || bytes > (int) sizeof(struct udp_dhcp_packet) ||
ntohs(packet.udp.len) != (short) (bytes - sizeof(packet.ip))) { ntohs(packet.udp.len) != (uint16_t) (bytes - sizeof(packet.ip))) {
DEBUG(LOG_INFO, "unrelated/bogus packet"); DEBUG(LOG_INFO, "unrelated/bogus packet");
return -2; return -2;
} }

View File

@ -179,7 +179,7 @@ int udhcpc_main(int argc, char *argv[])
int main(int argc, char *argv[]) int main(int argc, char *argv[])
#endif #endif
{ {
unsigned char *temp, *message; uint8_t *temp, *message;
unsigned long t1 = 0, t2 = 0, xid = 0; unsigned long t1 = 0, t2 = 0, xid = 0;
unsigned long start = 0, lease; unsigned long start = 0, lease;
fd_set rfds; fd_set rfds;

View File

@ -25,10 +25,10 @@ struct client_config_t {
char *interface; /* The name of the interface to use */ char *interface; /* The name of the interface to use */
char *pidfile; /* Optionally store the process ID */ char *pidfile; /* Optionally store the process ID */
char *script; /* User script to run at dhcp events */ char *script; /* User script to run at dhcp events */
unsigned char *clientid; /* Optional client id to use */ uint8_t *clientid; /* Optional client id to use */
unsigned char *hostname; /* Optional hostname to use */ uint8_t *hostname; /* Optional hostname to use */
int ifindex; /* Index number of the interface to use */ int ifindex; /* Index number of the interface to use */
unsigned char arp[6]; /* Our arp address */ uint8_t arp[6]; /* Our arp address */
}; };
extern struct client_config_t client_config; extern struct client_config_t client_config;

View File

@ -62,9 +62,9 @@ int main(int argc, char *argv[])
int server_socket = -1; int server_socket = -1;
int bytes, retval; int bytes, retval;
struct dhcpMessage packet; struct dhcpMessage packet;
unsigned char *state; uint8_t *state;
unsigned char *server_id, *requested; uint8_t *server_id, *requested;
u_int32_t server_id_align, requested_align; uint32_t server_id_align, requested_align;
unsigned long timeout_end; unsigned long timeout_end;
struct option_set *option; struct option_set *option;
struct dhcpOfferedAddr *lease; struct dhcpOfferedAddr *lease;

View File

@ -89,24 +89,24 @@
#define SNAME_FIELD 2 #define SNAME_FIELD 2
/* miscellaneous defines */ /* miscellaneous defines */
#define MAC_BCAST_ADDR (unsigned char *) "\xff\xff\xff\xff\xff\xff" #define MAC_BCAST_ADDR (uint8_t *) "\xff\xff\xff\xff\xff\xff"
#define OPT_CODE 0 #define OPT_CODE 0
#define OPT_LEN 1 #define OPT_LEN 1
#define OPT_DATA 2 #define OPT_DATA 2
struct option_set { struct option_set {
unsigned char *data; uint8_t *data;
struct option_set *next; struct option_set *next;
}; };
struct server_config_t { struct server_config_t {
u_int32_t server; /* Our IP, in network order */ uint32_t server; /* Our IP, in network order */
u_int32_t start; /* Start address of leases, network order */ uint32_t start; /* Start address of leases, network order */
u_int32_t end; /* End of leases, network order */ uint32_t end; /* End of leases, network order */
struct option_set *options; /* List of DHCP options loaded from the config file */ struct option_set *options; /* List of DHCP options loaded from the config file */
char *interface; /* The name of the interface to use */ char *interface; /* The name of the interface to use */
int ifindex; /* Index number of the interface to use */ int ifindex; /* Index number of the interface to use */
unsigned char arp[6]; /* Our arp address */ uint8_t arp[6]; /* Our arp address */
unsigned long lease; /* lease time in seconds (host order) */ unsigned long lease; /* lease time in seconds (host order) */
unsigned long max_leases; /* maximum number of leases (including reserved address) */ unsigned long max_leases; /* maximum number of leases (including reserved address) */
char remaining; /* should the lease file be interpreted as lease time remaining, or char remaining; /* should the lease file be interpreted as lease time remaining, or
@ -121,7 +121,7 @@ struct server_config_t {
char *lease_file; char *lease_file;
char *pidfile; char *pidfile;
char *notify_file; /* What to run whenever leases are written */ char *notify_file; /* What to run whenever leases are written */
u_int32_t siaddr; /* next server bootp option */ uint32_t siaddr; /* next server bootp option */
char *sname; /* bootp server name */ char *sname; /* bootp server name */
char *boot_file; /* bootp boot file option */ char *boot_file; /* bootp boot file option */
}; };

View File

@ -52,7 +52,7 @@ static int read_str(const char *line, void *arg)
static int read_u32(const char *line, void *arg) static int read_u32(const char *line, void *arg)
{ {
u_int32_t *dest = arg; uint32_t *dest = arg;
char *endptr; char *endptr;
*dest = strtoul(line, &endptr, 0); *dest = strtoul(line, &endptr, 0);
return endptr[0] == '\0'; return endptr[0] == '\0';
@ -83,8 +83,8 @@ static int read_opt(const char *const_line, void *arg)
int retval = 0, length; int retval = 0, length;
char buffer[8]; char buffer[8];
char *line; char *line;
u_int16_t *result_u16 = (u_int16_t *) buffer; uint16_t *result_u16 = (uint16_t *) buffer;
u_int32_t *result_u32 = (u_int32_t *) buffer; uint32_t *result_u32 = (uint32_t *) buffer;
/* Cheat, the only const line we'll actually get is "" */ /* Cheat, the only const line we'll actually get is "" */
line = (char *) const_line; line = (char *) const_line;

View File

@ -17,10 +17,10 @@
#include "common.h" #include "common.h"
unsigned char blank_chaddr[] = {[0 ... 15] = 0}; uint8_t blank_chaddr[] = {[0 ... 15] = 0};
/* clear every lease out that chaddr OR yiaddr matches and is nonzero */ /* clear every lease out that chaddr OR yiaddr matches and is nonzero */
void clear_lease(u_int8_t *chaddr, u_int32_t yiaddr) void clear_lease(uint8_t *chaddr, uint32_t yiaddr)
{ {
unsigned int i, j; unsigned int i, j;
@ -35,7 +35,7 @@ void clear_lease(u_int8_t *chaddr, u_int32_t yiaddr)
/* add a lease into the table, clearing out any old ones */ /* add a lease into the table, clearing out any old ones */
struct dhcpOfferedAddr *add_lease(u_int8_t *chaddr, u_int32_t yiaddr, unsigned long lease) struct dhcpOfferedAddr *add_lease(uint8_t *chaddr, uint32_t yiaddr, unsigned long lease)
{ {
struct dhcpOfferedAddr *oldest; struct dhcpOfferedAddr *oldest;
@ -80,7 +80,7 @@ struct dhcpOfferedAddr *oldest_expired_lease(void)
/* Find the first lease that matches chaddr, NULL if no match */ /* Find the first lease that matches chaddr, NULL if no match */
struct dhcpOfferedAddr *find_lease_by_chaddr(u_int8_t *chaddr) struct dhcpOfferedAddr *find_lease_by_chaddr(uint8_t *chaddr)
{ {
unsigned int i; unsigned int i;
@ -92,7 +92,7 @@ struct dhcpOfferedAddr *find_lease_by_chaddr(u_int8_t *chaddr)
/* Find the first lease that matches yiaddr, NULL is no match */ /* Find the first lease that matches yiaddr, NULL is no match */
struct dhcpOfferedAddr *find_lease_by_yiaddr(u_int32_t yiaddr) struct dhcpOfferedAddr *find_lease_by_yiaddr(uint32_t yiaddr)
{ {
unsigned int i; unsigned int i;
@ -104,7 +104,7 @@ struct dhcpOfferedAddr *find_lease_by_yiaddr(u_int32_t yiaddr)
/* check is an IP is taken, if it is, add it to the lease table */ /* check is an IP is taken, if it is, add it to the lease table */
static int check_ip(u_int32_t addr) static int check_ip(uint32_t addr)
{ {
struct in_addr temp; struct in_addr temp;
@ -120,9 +120,9 @@ static int check_ip(u_int32_t addr)
/* find an assignable address, it check_expired is true, we check all the expired leases as well. /* find an assignable address, it check_expired is true, we check all the expired leases as well.
* Maybe this should try expired leases by age... */ * Maybe this should try expired leases by age... */
u_int32_t find_address(int check_expired) uint32_t find_address(int check_expired)
{ {
u_int32_t addr, ret; uint32_t addr, ret;
struct dhcpOfferedAddr *lease = NULL; struct dhcpOfferedAddr *lease = NULL;
addr = ntohl(server_config.start); /* addr is in host order here */ addr = ntohl(server_config.start); /* addr is in host order here */

View File

@ -4,20 +4,20 @@
struct dhcpOfferedAddr { struct dhcpOfferedAddr {
u_int8_t chaddr[16]; uint8_t chaddr[16];
u_int32_t yiaddr; /* network order */ uint32_t yiaddr; /* network order */
u_int32_t expires; /* host order */ uint32_t expires; /* host order */
}; };
extern unsigned char blank_chaddr[]; extern uint8_t blank_chaddr[];
void clear_lease(u_int8_t *chaddr, u_int32_t yiaddr); void clear_lease(uint8_t *chaddr, uint32_t yiaddr);
struct dhcpOfferedAddr *add_lease(u_int8_t *chaddr, u_int32_t yiaddr, unsigned long lease); struct dhcpOfferedAddr *add_lease(uint8_t *chaddr, uint32_t yiaddr, unsigned long lease);
int lease_expired(struct dhcpOfferedAddr *lease); int lease_expired(struct dhcpOfferedAddr *lease);
struct dhcpOfferedAddr *oldest_expired_lease(void); struct dhcpOfferedAddr *oldest_expired_lease(void);
struct dhcpOfferedAddr *find_lease_by_chaddr(u_int8_t *chaddr); struct dhcpOfferedAddr *find_lease_by_chaddr(uint8_t *chaddr);
struct dhcpOfferedAddr *find_lease_by_yiaddr(u_int32_t yiaddr); struct dhcpOfferedAddr *find_lease_by_yiaddr(uint32_t yiaddr);
u_int32_t find_address(int check_expired); uint32_t find_address(int check_expired);
#endif #endif

View File

@ -59,10 +59,10 @@ int option_lengths[] = {
/* get an option with bounds checking (warning, not aligned). */ /* get an option with bounds checking (warning, not aligned). */
unsigned char *get_option(struct dhcpMessage *packet, int code) uint8_t *get_option(struct dhcpMessage *packet, int code)
{ {
int i, length; int i, length;
unsigned char *optionptr; uint8_t *optionptr;
int over = 0, done = 0, curr = OPTION_FIELD; int over = 0, done = 0, curr = OPTION_FIELD;
optionptr = packet->options; optionptr = packet->options;
@ -114,7 +114,7 @@ unsigned char *get_option(struct dhcpMessage *packet, int code)
/* return the position of the 'end' option (no bounds checking) */ /* return the position of the 'end' option (no bounds checking) */
int end_option(unsigned char *optionptr) int end_option(uint8_t *optionptr)
{ {
int i = 0; int i = 0;
@ -128,7 +128,7 @@ int end_option(unsigned char *optionptr)
/* add an option string to the options (an option string contains an option code, /* add an option string to the options (an option string contains an option code,
* length, then data) */ * length, then data) */
int add_option_string(unsigned char *optionptr, unsigned char *string) int add_option_string(uint8_t *optionptr, uint8_t *string)
{ {
int end = end_option(optionptr); int end = end_option(optionptr);
@ -145,17 +145,17 @@ int add_option_string(unsigned char *optionptr, unsigned char *string)
/* add a one to four byte option to a packet */ /* add a one to four byte option to a packet */
int add_simple_option(unsigned char *optionptr, unsigned char code, u_int32_t data) int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data)
{ {
char length = 0; char length = 0;
int i; int i;
unsigned char option[2 + 4]; uint8_t option[2 + 4];
unsigned char *u8; uint8_t *u8;
u_int16_t *u16; uint16_t *u16;
u_int32_t *u32; uint32_t *u32;
u_int32_t aligned; uint32_t aligned;
u8 = (unsigned char *) &aligned; u8 = (uint8_t *) &aligned;
u16 = (u_int16_t *) &aligned; u16 = (uint16_t *) &aligned;
u32 = &aligned; u32 = &aligned;
for (i = 0; dhcp_options[i].code; i++) for (i = 0; dhcp_options[i].code; i++)

View File

@ -24,16 +24,16 @@ enum {
struct dhcp_option { struct dhcp_option {
char name[10]; char name[10];
char flags; char flags;
unsigned char code; uint8_t code;
}; };
extern struct dhcp_option dhcp_options[]; extern struct dhcp_option dhcp_options[];
extern int option_lengths[]; extern int option_lengths[];
unsigned char *get_option(struct dhcpMessage *packet, int code); uint8_t *get_option(struct dhcpMessage *packet, int code);
int end_option(unsigned char *optionptr); int end_option(uint8_t *optionptr);
int add_option_string(unsigned char *optionptr, unsigned char *string); int add_option_string(uint8_t *optionptr, uint8_t *string);
int add_simple_option(unsigned char *optionptr, unsigned char code, u_int32_t data); int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data);
struct option_set *find_option(struct option_set *opt_list, char code); struct option_set *find_option(struct option_set *opt_list, char code);
void attach_option(struct option_set **opt_list, struct dhcp_option *option, char *buffer, int length); void attach_option(struct option_set **opt_list, struct dhcp_option *option, char *buffer, int length);

View File

@ -69,7 +69,7 @@ int get_packet(struct dhcpMessage *packet, int fd)
if (packet->op == BOOTREQUEST && (vendor = get_option(packet, DHCP_VENDOR))) { if (packet->op == BOOTREQUEST && (vendor = get_option(packet, DHCP_VENDOR))) {
for (i = 0; broken_vendors[i][0]; i++) { for (i = 0; broken_vendors[i][0]; i++) {
if (vendor[OPT_LEN - 2] == (unsigned char) strlen(broken_vendors[i]) && if (vendor[OPT_LEN - 2] == (uint8_t) strlen(broken_vendors[i]) &&
!strncmp(vendor, broken_vendors[i], vendor[OPT_LEN - 2])) { !strncmp(vendor, broken_vendors[i], vendor[OPT_LEN - 2])) {
DEBUG(LOG_INFO, "broken client (%s), forcing broadcast", DEBUG(LOG_INFO, "broken client (%s), forcing broadcast",
broken_vendors[i]); broken_vendors[i]);
@ -83,13 +83,13 @@ int get_packet(struct dhcpMessage *packet, int fd)
} }
u_int16_t checksum(void *addr, int count) uint16_t checksum(void *addr, int count)
{ {
/* Compute Internet Checksum for "count" bytes /* Compute Internet Checksum for "count" bytes
* beginning at location "addr". * beginning at location "addr".
*/ */
register int32_t sum = 0; register int32_t sum = 0;
u_int16_t *source = (u_int16_t *) addr; uint16_t *source = (uint16_t *) addr;
while (count > 1) { while (count > 1) {
/* This is the inner loop */ /* This is the inner loop */
@ -101,8 +101,8 @@ u_int16_t checksum(void *addr, int count)
if (count > 0) { if (count > 0) {
/* Make sure that the left-over byte is added correctly both /* Make sure that the left-over byte is added correctly both
* with little and big endian hosts */ * with little and big endian hosts */
u_int16_t tmp = 0; uint16_t tmp = 0;
*(unsigned char *) (&tmp) = * (unsigned char *) source; *(uint8_t *) (&tmp) = * (uint8_t *) source;
sum += tmp; sum += tmp;
} }
/* Fold 32-bit sum to 16 bits */ /* Fold 32-bit sum to 16 bits */
@ -114,8 +114,8 @@ u_int16_t checksum(void *addr, int count)
/* Constuct a ip/udp header for a packet, and specify the source and dest hardware address */ /* Constuct a ip/udp header for a packet, and specify the source and dest hardware address */
int raw_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port, int raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port,
u_int32_t dest_ip, int dest_port, unsigned char *dest_arp, int ifindex) uint32_t dest_ip, int dest_port, uint8_t *dest_arp, int ifindex)
{ {
int fd; int fd;
int result; int result;
@ -167,8 +167,8 @@ int raw_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port
/* Let the kernel do all the work for packet generation */ /* Let the kernel do all the work for packet generation */
int kernel_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port, int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port,
u_int32_t dest_ip, int dest_port) uint32_t dest_ip, int dest_port)
{ {
int n = 1; int n = 1;
int fd, result; int fd, result;

View File

@ -5,22 +5,22 @@
#include <netinet/ip.h> #include <netinet/ip.h>
struct dhcpMessage { struct dhcpMessage {
u_int8_t op; uint8_t op;
u_int8_t htype; uint8_t htype;
u_int8_t hlen; uint8_t hlen;
u_int8_t hops; uint8_t hops;
u_int32_t xid; uint32_t xid;
u_int16_t secs; uint16_t secs;
u_int16_t flags; uint16_t flags;
u_int32_t ciaddr; uint32_t ciaddr;
u_int32_t yiaddr; uint32_t yiaddr;
u_int32_t siaddr; uint32_t siaddr;
u_int32_t giaddr; uint32_t giaddr;
u_int8_t chaddr[16]; uint8_t chaddr[16];
u_int8_t sname[64]; uint8_t sname[64];
u_int8_t file[128]; uint8_t file[128];
u_int32_t cookie; uint32_t cookie;
u_int8_t options[308]; /* 312 - cookie */ uint8_t options[308]; /* 312 - cookie */
}; };
struct udp_dhcp_packet { struct udp_dhcp_packet {
@ -31,11 +31,11 @@ struct udp_dhcp_packet {
void init_header(struct dhcpMessage *packet, char type); void init_header(struct dhcpMessage *packet, char type);
int get_packet(struct dhcpMessage *packet, int fd); int get_packet(struct dhcpMessage *packet, int fd);
u_int16_t checksum(void *addr, int count); uint16_t checksum(void *addr, int count);
int raw_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port, int raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port,
u_int32_t dest_ip, int dest_port, unsigned char *dest_arp, int ifindex); uint32_t dest_ip, int dest_port, uint8_t *dest_arp, int ifindex);
int kernel_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port, int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port,
u_int32_t dest_ip, int dest_port); uint32_t dest_ip, int dest_port);
#endif #endif

View File

@ -55,7 +55,7 @@ static inline int upper_length(int length, int opt_index)
} }
static int sprintip(char *dest, char *pre, unsigned char *ip) static int sprintip(char *dest, char *pre, uint8_t *ip)
{ {
return sprintf(dest, "%s%d.%d.%d.%d", pre, ip[0], ip[1], ip[2], ip[3]); return sprintf(dest, "%s%d.%d.%d.%d", pre, ip[0], ip[1], ip[2], ip[3]);
} }
@ -74,12 +74,12 @@ static int mton(struct in_addr *mask)
/* Fill dest with the text of option 'option'. */ /* Fill dest with the text of option 'option'. */
static void fill_options(char *dest, unsigned char *option, struct dhcp_option *type_p) static void fill_options(char *dest, uint8_t *option, struct dhcp_option *type_p)
{ {
int type, optlen; int type, optlen;
u_int16_t val_u16; uint16_t val_u16;
int16_t val_s16; int16_t val_s16;
u_int32_t val_u32; uint32_t val_u32;
int32_t val_s32; int32_t val_s32;
int len = option[OPT_LEN - 2]; int len = option[OPT_LEN - 2];
@ -138,7 +138,7 @@ static char **fill_envp(struct dhcpMessage *packet)
int num_options = 0; int num_options = 0;
int i, j; int i, j;
char **envp; char **envp;
unsigned char *temp; uint8_t *temp;
struct in_addr subnet; struct in_addr subnet;
char over = 0; char over = 0;
@ -168,7 +168,7 @@ static char **fill_envp(struct dhcpMessage *packet)
if (packet == NULL) return envp; if (packet == NULL) return envp;
envp[j] = xmalloc(sizeof("ip=255.255.255.255")); envp[j] = xmalloc(sizeof("ip=255.255.255.255"));
sprintip(envp[j++], "ip=", (unsigned char *) &packet->yiaddr); sprintip(envp[j++], "ip=", (uint8_t *) &packet->yiaddr);
for (i = 0; dhcp_options[i].code; i++) { for (i = 0; dhcp_options[i].code; i++) {
@ -186,7 +186,7 @@ static char **fill_envp(struct dhcpMessage *packet)
} }
if (packet->siaddr) { if (packet->siaddr) {
envp[j] = xmalloc(sizeof("siaddr=255.255.255.255")); envp[j] = xmalloc(sizeof("siaddr=255.255.255.255"));
sprintip(envp[j++], "siaddr=", (unsigned char *) &packet->siaddr); sprintip(envp[j++], "siaddr=", (uint8_t *) &packet->siaddr);
} }
if (!(over & FILE_FIELD) && packet->file[0]) { if (!(over & FILE_FIELD) && packet->file[0]) {
/* watch out for invalid packets */ /* watch out for invalid packets */

View File

@ -43,8 +43,8 @@ static int send_packet_to_relay(struct dhcpMessage *payload)
/* send a packet to a specific arp address and ip address by creating our own ip packet */ /* send a packet to a specific arp address and ip address by creating our own ip packet */
static int send_packet_to_client(struct dhcpMessage *payload, int force_broadcast) static int send_packet_to_client(struct dhcpMessage *payload, int force_broadcast)
{ {
unsigned char *chaddr; uint8_t *chaddr;
u_int32_t ciaddr; uint32_t ciaddr;
if (force_broadcast) { if (force_broadcast) {
DEBUG(LOG_INFO, "broadcasting packet to client (NAK)"); DEBUG(LOG_INFO, "broadcasting packet to client (NAK)");
@ -108,8 +108,8 @@ int sendOffer(struct dhcpMessage *oldpacket)
{ {
struct dhcpMessage packet; struct dhcpMessage packet;
struct dhcpOfferedAddr *lease = NULL; struct dhcpOfferedAddr *lease = NULL;
u_int32_t req_align, lease_time_align = server_config.lease; uint32_t req_align, lease_time_align = server_config.lease;
unsigned char *req, *lease_time; uint8_t *req, *lease_time;
struct option_set *curr; struct option_set *curr;
struct in_addr addr; struct in_addr addr;
@ -196,12 +196,12 @@ int sendNAK(struct dhcpMessage *oldpacket)
} }
int sendACK(struct dhcpMessage *oldpacket, u_int32_t yiaddr) int sendACK(struct dhcpMessage *oldpacket, uint32_t yiaddr)
{ {
struct dhcpMessage packet; struct dhcpMessage packet;
struct option_set *curr; struct option_set *curr;
unsigned char *lease_time; uint8_t *lease_time;
u_int32_t lease_time_align = server_config.lease; uint32_t lease_time_align = server_config.lease;
struct in_addr addr; struct in_addr addr;
init_packet(&packet, oldpacket, DHCPACK); init_packet(&packet, oldpacket, DHCPACK);

View File

@ -5,7 +5,7 @@
int sendOffer(struct dhcpMessage *oldpacket); int sendOffer(struct dhcpMessage *oldpacket);
int sendNAK(struct dhcpMessage *oldpacket); int sendNAK(struct dhcpMessage *oldpacket);
int sendACK(struct dhcpMessage *oldpacket, u_int32_t yiaddr); int sendACK(struct dhcpMessage *oldpacket, uint32_t yiaddr);
int send_inform(struct dhcpMessage *oldpacket); int send_inform(struct dhcpMessage *oldpacket);

View File

@ -44,7 +44,7 @@
#include "socket.h" #include "socket.h"
#include "common.h" #include "common.h"
int read_interface(char *interface, int *ifindex, u_int32_t *addr, unsigned char *arp) int read_interface(char *interface, int *ifindex, uint32_t *addr, uint8_t *arp)
{ {
int fd; int fd;
struct ifreq ifr; struct ifreq ifr;
@ -90,7 +90,7 @@ int read_interface(char *interface, int *ifindex, u_int32_t *addr, unsigned char
} }
int listen_socket(unsigned int ip, int port, char *inf) int listen_socket(uint32_t ip, int port, char *inf)
{ {
struct ifreq interface; struct ifreq interface;
int fd; int fd;

View File

@ -2,7 +2,7 @@
#ifndef _SOCKET_H #ifndef _SOCKET_H
#define _SOCKET_H #define _SOCKET_H
int read_interface(char *interface, int *ifindex, u_int32_t *addr, unsigned char *arp); int read_interface(char *interface, int *ifindex, uint32_t *addr, uint8_t *arp);
int listen_socket(unsigned int ip, int port, char *inf); int listen_socket(uint32_t ip, int port, char *inf);
#endif #endif