Commit 27058b3e authored by Francis Dupont's avatar Francis Dupont
Browse files

Fixed CID 1426986, 1426985, 1426984 and 1426983

parent 563f0b8a
...@@ -1098,7 +1098,9 @@ void dhcpinform (packet, ms_nulltp) ...@@ -1098,7 +1098,9 @@ void dhcpinform (packet, ms_nulltp)
struct interface_info *interface; struct interface_info *interface;
int result, h_m_client_ip = 0; int result, h_m_client_ip = 0;
struct host_decl *host = NULL, *hp = NULL, *h; struct host_decl *host = NULL, *hp = NULL, *h;
#if defined(RELAY_PORT)
u_int16_t relay_port = 0; u_int16_t relay_port = 0;
#endif
#if defined (DEBUG_INFORM_HOST) #if defined (DEBUG_INFORM_HOST)
int h_w_fixed_addr = 0; int h_w_fixed_addr = 0;
#endif #endif
...@@ -1715,7 +1717,11 @@ void dhcpinform (packet, ms_nulltp) ...@@ -1715,7 +1717,11 @@ void dhcpinform (packet, ms_nulltp)
*/ */
if (!raw.ciaddr.s_addr && gip.len) { if (!raw.ciaddr.s_addr && gip.len) {
memcpy(&to.sin_addr, gip.iabuf, 4); memcpy(&to.sin_addr, gip.iabuf, 4);
#if defined(RELAY_PORT)
to.sin_port = relay_port ? relay_port : local_port; to.sin_port = relay_port ? relay_port : local_port;
#else
to.sin_port = local_port;
#endif
raw.flags |= htons(BOOTP_BROADCAST); raw.flags |= htons(BOOTP_BROADCAST);
} else { } else {
gip.len = 0; gip.len = 0;
...@@ -1772,7 +1778,9 @@ void nak_lease (packet, cip, network_group) ...@@ -1772,7 +1778,9 @@ void nak_lease (packet, cip, network_group)
unsigned char nak = DHCPNAK; unsigned char nak = DHCPNAK;
struct packet outgoing; struct packet outgoing;
unsigned i; unsigned i;
#if defined(RELAY_PORT)
u_int16_t relay_port = 0; u_int16_t relay_port = 0;
#endif
struct option_state *options = (struct option_state *)0; struct option_state *options = (struct option_state *)0;
struct option_cache *oc = (struct option_cache *)0; struct option_cache *oc = (struct option_cache *)0;
struct option_state *eval_options = NULL; struct option_state *eval_options = NULL;
...@@ -1953,7 +1961,11 @@ void nak_lease (packet, cip, network_group) ...@@ -1953,7 +1961,11 @@ void nak_lease (packet, cip, network_group)
if (raw.giaddr.s_addr) { if (raw.giaddr.s_addr) {
to.sin_addr = raw.giaddr; to.sin_addr = raw.giaddr;
if (raw.giaddr.s_addr != htonl (INADDR_LOOPBACK)) if (raw.giaddr.s_addr != htonl (INADDR_LOOPBACK))
#if defined(RELAY_PORT)
to.sin_port = relay_port ? relay_port : local_port; to.sin_port = relay_port ? relay_port : local_port;
#else
to.sin_port = local_port;
#endif
else else
to.sin_port = remote_port; /* for testing. */ to.sin_port = remote_port; /* for testing. */
...@@ -3776,7 +3788,9 @@ void dhcp_reply (lease) ...@@ -3776,7 +3788,9 @@ void dhcp_reply (lease)
int result; int result;
struct lease_state *state = lease -> state; struct lease_state *state = lease -> state;
int nulltp, bootpp, unicastp = 1; int nulltp, bootpp, unicastp = 1;
#if defined(RELAY_PORT)
u_int16_t relay_port = 0; u_int16_t relay_port = 0;
#endif
struct data_string d1; struct data_string d1;
const char *s; const char *s;
...@@ -3954,7 +3968,11 @@ void dhcp_reply (lease) ...@@ -3954,7 +3968,11 @@ void dhcp_reply (lease)
if (raw.giaddr.s_addr) { if (raw.giaddr.s_addr) {
to.sin_addr = raw.giaddr; to.sin_addr = raw.giaddr;
if (raw.giaddr.s_addr != htonl (INADDR_LOOPBACK)) if (raw.giaddr.s_addr != htonl (INADDR_LOOPBACK))
#if defined(RELAY_PORT)
to.sin_port = relay_port ? relay_port : local_port; to.sin_port = relay_port ? relay_port : local_port;
#else
to.sin_port = local_port;
#endif
else else
to.sin_port = remote_port; /* For debugging. */ to.sin_port = remote_port; /* For debugging. */
......
...@@ -152,7 +152,9 @@ dhcpleasequery(struct packet *packet, int ms_nulltp) { ...@@ -152,7 +152,9 @@ dhcpleasequery(struct packet *packet, int ms_nulltp) {
u_int32_t time_rebinding; u_int32_t time_rebinding;
u_int32_t time_expiry; u_int32_t time_expiry;
u_int32_t client_last_transaction_time; u_int32_t client_last_transaction_time;
#if defined(RELAY_PORT)
u_int16_t relay_port = 0; u_int16_t relay_port = 0;
#endif
struct sockaddr_in to; struct sockaddr_in to;
struct in_addr siaddr; struct in_addr siaddr;
struct data_string prl; struct data_string prl;
...@@ -670,7 +672,11 @@ dhcpleasequery(struct packet *packet, int ms_nulltp) { ...@@ -670,7 +672,11 @@ dhcpleasequery(struct packet *packet, int ms_nulltp) {
*/ */
to.sin_addr = packet->raw->giaddr; to.sin_addr = packet->raw->giaddr;
if (packet->raw->giaddr.s_addr != htonl(INADDR_LOOPBACK)) { if (packet->raw->giaddr.s_addr != htonl(INADDR_LOOPBACK)) {
#if defined(RELAY_PORT)
to.sin_port = relay_port ? relay_port : local_port; to.sin_port = relay_port ? relay_port : local_port;
#else
to.sin_port = local_port;
#endif
} else { } else {
to.sin_port = remote_port; /* XXXSK: For debugging. */ to.sin_port = remote_port; /* XXXSK: For debugging. */
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment