diff options
Diffstat (limited to 'networking/udhcp/dhcprelay.c')
-rw-r--r-- | networking/udhcp/dhcprelay.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c index 9bb7aeab5..4ed65a2d6 100644 --- a/networking/udhcp/dhcprelay.c +++ b/networking/udhcp/dhcprelay.c | |||
@@ -30,7 +30,7 @@ static struct xid_item { | |||
30 | } dhcprelay_xid_list = {0, {0}, 0, 0, NULL}; | 30 | } dhcprelay_xid_list = {0, {0}, 0, 0, NULL}; |
31 | 31 | ||
32 | 32 | ||
33 | static struct xid_item * xid_add(uint32_t xid, struct sockaddr_in *ip, int client) | 33 | static struct xid_item *xid_add(uint32_t xid, struct sockaddr_in *ip, int client) |
34 | { | 34 | { |
35 | struct xid_item *item; | 35 | struct xid_item *item; |
36 | 36 | ||
@@ -48,7 +48,6 @@ static struct xid_item * xid_add(uint32_t xid, struct sockaddr_in *ip, int clien | |||
48 | return item; | 48 | return item; |
49 | } | 49 | } |
50 | 50 | ||
51 | |||
52 | static void xid_expire(void) | 51 | static void xid_expire(void) |
53 | { | 52 | { |
54 | struct xid_item *item = dhcprelay_xid_list.next; | 53 | struct xid_item *item = dhcprelay_xid_list.next; |
@@ -56,7 +55,7 @@ static void xid_expire(void) | |||
56 | time_t current_time = time(NULL); | 55 | time_t current_time = time(NULL); |
57 | 56 | ||
58 | while (item != NULL) { | 57 | while (item != NULL) { |
59 | if ((current_time-item->timestamp) > MAX_LIFETIME) { | 58 | if ((current_time - item->timestamp) > MAX_LIFETIME) { |
60 | last->next = item->next; | 59 | last->next = item->next; |
61 | free(item); | 60 | free(item); |
62 | item = last->next; | 61 | item = last->next; |
@@ -67,7 +66,7 @@ static void xid_expire(void) | |||
67 | } | 66 | } |
68 | } | 67 | } |
69 | 68 | ||
70 | static struct xid_item * xid_find(uint32_t xid) | 69 | static struct xid_item *xid_find(uint32_t xid) |
71 | { | 70 | { |
72 | struct xid_item *item = dhcprelay_xid_list.next; | 71 | struct xid_item *item = dhcprelay_xid_list.next; |
73 | while (item != NULL) { | 72 | while (item != NULL) { |
@@ -95,7 +94,6 @@ static void xid_del(uint32_t xid) | |||
95 | } | 94 | } |
96 | } | 95 | } |
97 | 96 | ||
98 | |||
99 | /** | 97 | /** |
100 | * get_dhcp_packet_type - gets the message type of a dhcp packet | 98 | * get_dhcp_packet_type - gets the message type of a dhcp packet |
101 | * p - pointer to the dhcp packet | 99 | * p - pointer to the dhcp packet |
@@ -119,7 +117,8 @@ static int get_dhcp_packet_type(struct dhcpMessage *p) | |||
119 | * signal_handler - handles signals ;-) | 117 | * signal_handler - handles signals ;-) |
120 | * sig - sent signal | 118 | * sig - sent signal |
121 | */ | 119 | */ |
122 | static int dhcprelay_stopflag; | 120 | static smallint dhcprelay_stopflag; |
121 | |||
123 | static void dhcprelay_signal_handler(int sig) | 122 | static void dhcprelay_signal_handler(int sig) |
124 | { | 123 | { |
125 | dhcprelay_stopflag = 1; | 124 | dhcprelay_stopflag = 1; |
@@ -130,7 +129,7 @@ static void dhcprelay_signal_handler(int sig) | |||
130 | * dev_list - comma separated list of devices | 129 | * dev_list - comma separated list of devices |
131 | * returns array | 130 | * returns array |
132 | */ | 131 | */ |
133 | static char ** get_client_devices(char *dev_list, int *client_number) | 132 | static char **get_client_devices(char *dev_list, int *client_number) |
134 | { | 133 | { |
135 | char *s, *list, **client_dev; | 134 | char *s, *list, **client_dev; |
136 | int i, cn; | 135 | int i, cn; |
@@ -286,7 +285,7 @@ static void dhcprelay_loop(int *fds, int num_sockets, int max_socket, char **cli | |||
286 | (struct sockaddr *)(&client_addr), &addr_size); | 285 | (struct sockaddr *)(&client_addr), &addr_size); |
287 | if (packlen <= 0) | 286 | if (packlen <= 0) |
288 | continue; | 287 | continue; |
289 | if (read_interface(clients[i-1], NULL, &dhcp_msg.giaddr, NULL) < 0) | 288 | if (read_interface(clients[i-1], NULL, &dhcp_msg.giaddr, NULL)) |
290 | dhcp_msg.giaddr = gw_ip; | 289 | dhcp_msg.giaddr = gw_ip; |
291 | pass_on(&dhcp_msg, packlen, i, fds, &client_addr, server_addr); | 290 | pass_on(&dhcp_msg, packlen, i, fds, &client_addr, server_addr); |
292 | } | 291 | } |
@@ -322,7 +321,7 @@ int dhcprelay_main(int argc, char **argv) | |||
322 | 321 | ||
323 | num_sockets = init_sockets(clients, num_sockets, argv[2], fds, &max_socket); | 322 | num_sockets = init_sockets(clients, num_sockets, argv[2], fds, &max_socket); |
324 | 323 | ||
325 | if (read_interface(argv[2], NULL, &gw_ip, NULL) == -1) | 324 | if (read_interface(argv[2], NULL, &gw_ip, NULL)) |
326 | return 1; | 325 | return 1; |
327 | 326 | ||
328 | dhcprelay_loop(fds, num_sockets, max_socket, clients, &server_addr, gw_ip); | 327 | dhcprelay_loop(fds, num_sockets, max_socket, clients, &server_addr, gw_ip); |