summaryrefslogtreecommitdiffstats
path: root/web/attachments/217472-check_dhcp.c.patch
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/217472-check_dhcp.c.patch')
-rw-r--r--web/attachments/217472-check_dhcp.c.patch93
1 files changed, 93 insertions, 0 deletions
diff --git a/web/attachments/217472-check_dhcp.c.patch b/web/attachments/217472-check_dhcp.c.patch
new file mode 100644
index 0000000..d9b69e0
--- /dev/null
+++ b/web/attachments/217472-check_dhcp.c.patch
@@ -0,0 +1,93 @@
1--- nagios-plugins-HEAD-200702121300/plugins-root/check_dhcp.c 2007-01-28 22:46:41.000000000 +0100
2+++ nagios-plugins-HEAD-200702121300/plugins-root/check_dhcp.c 2007-02-23 22:36:30.200102288 +0100
3@@ -182,6 +182,7 @@ typedef struct requested_server_struct{
4 #define DHCP_OPTION_BROADCAST_ADDRESS 28
5 #define DHCP_OPTION_REQUESTED_ADDRESS 50
6 #define DHCP_OPTION_LEASE_TIME 51
7+#define DHCP_OPTION_SERVER_IDENTIFIER 54
8 #define DHCP_OPTION_RENEWAL_TIME 58
9 #define DHCP_OPTION_REBINDING_TIME 59
10
11@@ -768,6 +769,7 @@ int add_dhcp_offer(struct in_addr source
12 int y;
13 unsigned option_type;
14 unsigned option_length;
15+ struct in_addr serv_ident = {0};
16
17 if(offer_packet==NULL)
18 return ERROR;
19@@ -789,23 +791,27 @@ int add_dhcp_offer(struct in_addr source
20 printf("Option: %d (0x%02X)\n",option_type,option_length);
21
22 /* get option data */
23- if(option_type==DHCP_OPTION_LEASE_TIME){
24- memcpy(&dhcp_lease_time, &offer_packet->options[x],sizeof(dhcp_lease_time));
25+ switch(option_type) {
26+ case DHCP_OPTION_LEASE_TIME:
27+ memcpy(&dhcp_lease_time,offer_packet->options+x,sizeof dhcp_lease_time);
28 dhcp_lease_time = ntohl(dhcp_lease_time);
29- }
30- if(option_type==DHCP_OPTION_RENEWAL_TIME){
31- memcpy(&dhcp_renewal_time, &offer_packet->options[x],sizeof(dhcp_renewal_time));
32+ break;
33+ case DHCP_OPTION_RENEWAL_TIME:
34+ memcpy(&dhcp_renewal_time,offer_packet->options+x,sizeof dhcp_renewal_time);
35 dhcp_renewal_time = ntohl(dhcp_renewal_time);
36- }
37- if(option_type==DHCP_OPTION_REBINDING_TIME){
38- memcpy(&dhcp_rebinding_time, &offer_packet->options[x],sizeof(dhcp_rebinding_time));
39+ break;
40+ case DHCP_OPTION_REBINDING_TIME:
41+ memcpy(&dhcp_rebinding_time,offer_packet->options+x,sizeof dhcp_rebinding_time);
42 dhcp_rebinding_time = ntohl(dhcp_rebinding_time);
43- }
44-
45+ break;
46+ case DHCP_OPTION_SERVER_IDENTIFIER:
47+ memcpy(&serv_ident.s_addr,offer_packet->options+x,sizeof serv_ident.s_addr);
48+ break;
49+ }
50 /* skip option data we're ignoring */
51- else
52- for(y=0;y<option_length;y++,x++);
53- }
54+ if(option_type!=DHCP_OPTION_REBINDING_TIME)
55+ x+=option_length;
56+ }
57
58 if(verbose){
59 if(dhcp_lease_time==DHCP_INFINITE_TIME)
60@@ -819,14 +825,14 @@ int add_dhcp_offer(struct in_addr source
61 if(dhcp_rebinding_time==DHCP_INFINITE_TIME)
62 printf(_("Rebinding Time: Infinite\n"));
63 printf(_("Rebinding Time: %lu seconds\n"),(unsigned long)dhcp_rebinding_time);
64- }
65+ }
66
67 new_offer=(dhcp_offer *)malloc(sizeof(dhcp_offer));
68
69 if(new_offer==NULL)
70 return ERROR;
71
72- new_offer->server_address=source;
73+ new_offer->server_address=serv_ident.s_addr?serv_ident:source;
74 new_offer->offered_address=offer_packet->yiaddr;
75 new_offer->lease_time=dhcp_lease_time;
76 new_offer->renewal_time=dhcp_renewal_time;
77@@ -836,14 +842,14 @@ int add_dhcp_offer(struct in_addr source
78 if(verbose){
79 printf(_("Added offer from server @ %s"),inet_ntoa(new_offer->server_address));
80 printf(_(" of IP address %s\n"),inet_ntoa(new_offer->offered_address));
81- }
82+ }
83
84 /* add new offer to head of list */
85 new_offer->next=dhcp_offer_list;
86 dhcp_offer_list=new_offer;
87
88 return OK;
89- }
90+}
91
92
93 /* frees memory allocated to DHCP OFFER list */