diff options
-rw-r--r-- | networking/udhcp/Config.in | 3 | ||||
-rw-r--r-- | networking/udhcp/common.h | 2 | ||||
-rw-r--r-- | networking/udhcp/dhcpd.h | 4 | ||||
-rw-r--r-- | networking/udhcp/leases.c | 4 |
4 files changed, 11 insertions, 2 deletions
diff --git a/networking/udhcp/Config.in b/networking/udhcp/Config.in index d4b76e188..495b07941 100644 --- a/networking/udhcp/Config.in +++ b/networking/udhcp/Config.in | |||
@@ -74,6 +74,9 @@ config FEATURE_UDHCP_PORT | |||
74 | At the cost of ~300 bytes, enables -P port option. | 74 | At the cost of ~300 bytes, enables -P port option. |
75 | This feature is typically not needed. | 75 | This feature is typically not needed. |
76 | 76 | ||
77 | # TODO: UDHCP_DEBUG is inconvenient to use. | ||
78 | # Make it controllable at runtime (say, via -v, -vv, -vvv) | ||
79 | |||
77 | config UDHCP_DEBUG | 80 | config UDHCP_DEBUG |
78 | bool "Compile udhcp with noisy debugging messages" | 81 | bool "Compile udhcp with noisy debugging messages" |
79 | default n | 82 | default n |
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index 91e8ccc53..0f12be063 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h | |||
@@ -23,6 +23,7 @@ extern const uint8_t MAC_BCAST_ADDR[6]; /* six all-ones */ | |||
23 | 23 | ||
24 | #define DHCP_OPTIONS_BUFSIZE 308 | 24 | #define DHCP_OPTIONS_BUFSIZE 308 |
25 | 25 | ||
26 | //TODO: rename to dhcp_packet; rename ciaddr/yiaddr/chaddr | ||
26 | struct dhcpMessage { | 27 | struct dhcpMessage { |
27 | uint8_t op; /* 1 = BOOTREQUEST, 2 = BOOTREPLY */ | 28 | uint8_t op; /* 1 = BOOTREQUEST, 2 = BOOTREPLY */ |
28 | uint8_t htype; /* hardware address type. 1 = 10mb ethernet */ | 29 | uint8_t htype; /* hardware address type. 1 = 10mb ethernet */ |
@@ -44,6 +45,7 @@ struct dhcpMessage { | |||
44 | uint8_t options[DHCP_OPTIONS_BUFSIZE + CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS]; | 45 | uint8_t options[DHCP_OPTIONS_BUFSIZE + CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS]; |
45 | } PACKED; | 46 | } PACKED; |
46 | 47 | ||
48 | //TODO: rename to ip_udp_dhcp_packet? | ||
47 | struct udp_dhcp_packet { | 49 | struct udp_dhcp_packet { |
48 | struct iphdr ip; | 50 | struct iphdr ip; |
49 | struct udphdr udp; | 51 | struct udphdr udp; |
diff --git a/networking/udhcp/dhcpd.h b/networking/udhcp/dhcpd.h index b233962b0..bb2febbba 100644 --- a/networking/udhcp/dhcpd.h +++ b/networking/udhcp/dhcpd.h | |||
@@ -78,6 +78,10 @@ struct server_config_t { | |||
78 | typedef uint32_t leasetime_t; | 78 | typedef uint32_t leasetime_t; |
79 | typedef int32_t signed_leasetime_t; | 79 | typedef int32_t signed_leasetime_t; |
80 | 80 | ||
81 | //TODO: (1) rename to dyn_lease (that's what it is. we also have static_lease). | ||
82 | //(2) lease_mac16 may be shortened to lease_mac[6], since e.g. ARP probing uses | ||
83 | //only 6 first bytes anyway. We can check received dhcp packets | ||
84 | //that their "chaddr"s have only 6 first bytes != 0, and complain otherwise. | ||
81 | struct dhcpOfferedAddr { | 85 | struct dhcpOfferedAddr { |
82 | uint8_t lease_mac16[16]; | 86 | uint8_t lease_mac16[16]; |
83 | /* "nip": IP in network order */ | 87 | /* "nip": IP in network order */ |
diff --git a/networking/udhcp/leases.c b/networking/udhcp/leases.c index 291ae8053..06bc086ba 100644 --- a/networking/udhcp/leases.c +++ b/networking/udhcp/leases.c | |||
@@ -22,7 +22,7 @@ static struct dhcpOfferedAddr *oldest_expired_lease(void) | |||
22 | for (i = 0; i < server_config.max_leases; i++) { | 22 | for (i = 0; i < server_config.max_leases; i++) { |
23 | if (leases[i].expires < oldest_time) { | 23 | if (leases[i].expires < oldest_time) { |
24 | oldest_time = leases[i].expires; | 24 | oldest_time = leases[i].expires; |
25 | oldest_lease = &(leases[i]); | 25 | oldest_lease = &leases[i]; |
26 | } | 26 | } |
27 | } | 27 | } |
28 | return oldest_lease; | 28 | return oldest_lease; |
@@ -142,7 +142,7 @@ static int nobody_responds_to_arp(uint32_t addr, const uint8_t *safe_mac) | |||
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | /* Find a new usable (we think) address. */ | 145 | /* Find a new usable (we think) address */ |
146 | uint32_t FAST_FUNC find_free_or_expired_address(const uint8_t *chaddr) | 146 | uint32_t FAST_FUNC find_free_or_expired_address(const uint8_t *chaddr) |
147 | { | 147 | { |
148 | uint32_t addr; | 148 | uint32_t addr; |