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
8 - int i, c, mode = REMAINING;
9 + int i, c, mode = ABSOLUTE;
11 const char *file = LEASES_FILE;
12 struct dhcpOfferedAddr lease;
15 fp = xfopen(file, "r");
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)) {
23 addr.s_addr = lease.yiaddr;
24 printf(" %-15s", inet_ntoa(addr));
25 expires = ntohl(lease.expires);
27 + //expires = lease.expires;
28 + printf(" %-15s ",lease.hostname);
29 if (mode == REMAINING) {
30 if (!expires) printf("expired\n");
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
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);
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
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)
54 struct dhcpOfferedAddr *oldest;
57 oldest = oldest_expired_lease();
61 + uint8_t length = *(hostname-1);
62 + if (length>15) length=15;
63 + memcpy(oldest->hostname,hostname,length);
64 + oldest->hostname[length]=0;
67 memcpy(oldest->chaddr, chaddr, 16);
68 oldest->yiaddr = yiaddr;
69 oldest->expires = time(0) + lease;
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);
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
85 struct dhcpOfferedAddr {
86 + uint8_t hostname[16];
88 uint32_t yiaddr; /* network order */
89 uint32_t expires; /* host order */
91 extern uint8_t blank_chaddr[];
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
108 /* send a packet to giaddr using the kernel ip stack */
109 static int send_packet_to_relay(struct dhcpMessage *payload)
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");
120 if (send_packet(&packet, 0) < 0)
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);