openssl/openssh updates from below0
[openwrt.git] / obsolete-buildroot / sources / busybox-openwrt-120-udhcp.patch
1 diff -urN busybox-dist/networking/udhcp/dumpleases.c busybox/networking/udhcp/dumpleases.c
2 --- busybox-dist/networking/udhcp/dumpleases.c 2004-03-15 02:29:00.000000000 -0600
3 +++ busybox/networking/udhcp/dumpleases.c 2004-03-16 09:52:32.000000000 -0600
4 @@ -42,7 +42,7 @@
5 #endif
6 {
7 FILE *fp;
8 - int i, c, mode = REMAINING;
9 + int i, c, mode = ABSOLUTE;
10 long expires;
11 const char *file = LEASES_FILE;
12 struct dhcpOfferedAddr lease;
13 @@ -73,7 +73,7 @@
14
15 fp = xfopen(file, "r");
16
17 - printf("Mac Address IP-Address Expires %s\n", mode == REMAINING ? "in" : "at");
18 + printf("Mac Address IP-Address Hostname Expires %s\n", mode == REMAINING ? "in" : "at");
19 /* "00:00:00:00:00:00 255.255.255.255 Wed Jun 30 21:49:08 1993" */
20 while (fread(&lease, sizeof(lease), 1, fp)) {
21
22 @@ -84,7 +84,8 @@
23 addr.s_addr = lease.yiaddr;
24 printf(" %-15s", inet_ntoa(addr));
25 expires = ntohl(lease.expires);
26 - printf(" ");
27 + //expires = lease.expires;
28 + printf(" %-15s ",lease.hostname);
29 if (mode == REMAINING) {
30 if (!expires) printf("expired\n");
31 else {
32 diff -urN busybox-dist/networking/udhcp/files.c busybox/networking/udhcp/files.c
33 --- busybox-dist/networking/udhcp/files.c 2004-03-15 02:29:00.000000000 -0600
34 +++ busybox/networking/udhcp/files.c 2004-03-16 09:50:04.000000000 -0600
35 @@ -281,7 +281,7 @@
36 if (lease.yiaddr >= server_config.start && lease.yiaddr <= server_config.end) {
37 lease.expires = ntohl(lease.expires);
38 if (!server_config.remaining) lease.expires -= time(0);
39 - if (!(add_lease(lease.chaddr, lease.yiaddr, lease.expires))) {
40 + if (!(add_lease(lease.hostname, lease.chaddr, lease.yiaddr, lease.expires))) {
41 LOG(LOG_WARNING, "Too many leases while loading %s\n", file);
42 break;
43 }
44 diff -urN busybox-dist/networking/udhcp/leases.c busybox/networking/udhcp/leases.c
45 --- busybox-dist/networking/udhcp/leases.c 2004-03-15 02:29:00.000000000 -0600
46 +++ busybox/networking/udhcp/leases.c 2004-03-16 09:50:04.000000000 -0600
47 @@ -35,7 +35,7 @@
48
49
50 /* add a lease into the table, clearing out any old ones */
51 -struct dhcpOfferedAddr *add_lease(uint8_t *chaddr, uint32_t yiaddr, unsigned long lease)
52 +struct dhcpOfferedAddr *add_lease(uint8_t *hostname, uint8_t *chaddr, uint32_t yiaddr, unsigned long lease)
53 {
54 struct dhcpOfferedAddr *oldest;
55
56 @@ -45,6 +45,13 @@
57 oldest = oldest_expired_lease();
58
59 if (oldest) {
60 + if (hostname) {
61 + uint8_t length = *(hostname-1);
62 + if (length>15) length=15;
63 + memcpy(oldest->hostname,hostname,length);
64 + oldest->hostname[length]=0;
65 + }
66 +
67 memcpy(oldest->chaddr, chaddr, 16);
68 oldest->yiaddr = yiaddr;
69 oldest->expires = time(0) + lease;
70 @@ -112,7 +119,7 @@
71 temp.s_addr = addr;
72 LOG(LOG_INFO, "%s belongs to someone, reserving it for %ld seconds",
73 inet_ntoa(temp), server_config.conflict_time);
74 - add_lease(blank_chaddr, addr, server_config.conflict_time);
75 + add_lease(blank_chaddr, blank_chaddr, addr, server_config.conflict_time);
76 return 1;
77 } else return 0;
78 }
79 diff -urN busybox-dist/networking/udhcp/leases.h busybox/networking/udhcp/leases.h
80 --- busybox-dist/networking/udhcp/leases.h 2004-01-30 17:45:12.000000000 -0600
81 +++ busybox/networking/udhcp/leases.h 2004-03-16 09:50:04.000000000 -0600
82 @@ -4,6 +4,7 @@
83
84
85 struct dhcpOfferedAddr {
86 + uint8_t hostname[16];
87 uint8_t chaddr[16];
88 uint32_t yiaddr; /* network order */
89 uint32_t expires; /* host order */
90 @@ -12,7 +13,7 @@
91 extern uint8_t blank_chaddr[];
92
93 void clear_lease(uint8_t *chaddr, uint32_t yiaddr);
94 -struct dhcpOfferedAddr *add_lease(uint8_t *chaddr, uint32_t yiaddr, unsigned long lease);
95 +struct dhcpOfferedAddr *add_lease(uint8_t *hostname, uint8_t *chaddr, uint32_t yiaddr, unsigned long lease);
96 int lease_expired(struct dhcpOfferedAddr *lease);
97 struct dhcpOfferedAddr *oldest_expired_lease(void);
98 struct dhcpOfferedAddr *find_lease_by_chaddr(uint8_t *chaddr);
99 diff -urN busybox-dist/networking/udhcp/serverpacket.c busybox/networking/udhcp/serverpacket.c
100 --- busybox-dist/networking/udhcp/serverpacket.c 2004-03-15 02:29:01.000000000 -0600
101 +++ busybox/networking/udhcp/serverpacket.c 2004-03-16 09:51:36.000000000 -0600
102 @@ -29,6 +29,7 @@
103 #include "dhcpd.h"
104 #include "options.h"
105 #include "common.h"
106 +#include "files.h"
107
108 /* send a packet to giaddr using the kernel ip stack */
109 static int send_packet_to_relay(struct dhcpMessage *payload)
110 @@ -152,7 +153,7 @@
111 return -1;
112 }
113
114 - if (!add_lease(packet.chaddr, packet.yiaddr, server_config.offer_time)) {
115 + if (!add_lease(get_option(oldpacket, DHCP_HOST_NAME), packet.chaddr, packet.yiaddr, server_config.offer_time)) {
116 LOG(LOG_WARNING, "lease pool is full -- OFFER abandoned");
117 return -1;
118 }
119 @@ -233,7 +234,9 @@
120 if (send_packet(&packet, 0) < 0)
121 return -1;
122
123 - add_lease(packet.chaddr, packet.yiaddr, lease_time_align);
124 + add_lease(get_option(oldpacket, DHCP_HOST_NAME), packet.chaddr, packet.yiaddr, lease_time_align);
125 +
126 + write_leases();
127
128 return 0;
129 }
This page took 0.041262 seconds and 5 git commands to generate.