| 1 |
diff -up dhcp-4.1.0/server/bootp.c.unicast dhcp-4.1.0/server/bootp.c
|
| 2 |
--- dhcp-4.1.0/server/bootp.c.unicast 2008-08-20 13:07:19.000000000 -1000
|
| 3 |
+++ dhcp-4.1.0/server/bootp.c 2009-01-06 10:13:29.000000000 -1000
|
| 4 |
@@ -58,6 +58,7 @@ void bootp (packet)
|
| 5 |
char msgbuf [1024];
|
| 6 |
int ignorep;
|
| 7 |
int peer_has_leases = 0;
|
| 8 |
+ int norelay = 0;
|
| 9 |
|
| 10 |
if (packet -> raw -> op != BOOTREQUEST)
|
| 11 |
return;
|
| 12 |
@@ -73,7 +74,7 @@ void bootp (packet)
|
| 13 |
? inet_ntoa (packet -> raw -> giaddr)
|
| 14 |
: packet -> interface -> name);
|
| 15 |
|
| 16 |
- if (!locate_network (packet)) {
|
| 17 |
+ if ((norelay = locate_network (packet)) == 0) {
|
| 18 |
log_info ("%s: network unknown", msgbuf);
|
| 19 |
return;
|
| 20 |
}
|
| 21 |
@@ -390,6 +391,13 @@ void bootp (packet)
|
| 22 |
from, &to, &hto);
|
| 23 |
goto out;
|
| 24 |
}
|
| 25 |
+ } else if (norelay == 2) {
|
| 26 |
+ to.sin_addr = raw.ciaddr;
|
| 27 |
+ to.sin_port = remote_port;
|
| 28 |
+ if (fallback_interface) {
|
| 29 |
+ result = send_packet (fallback_interface, (struct packet *)0, &raw, outgoing.packet_length, from, &to, &hto);
|
| 30 |
+ goto out;
|
| 31 |
+ }
|
| 32 |
|
| 33 |
/* If it comes from a client that already knows its address
|
| 34 |
and is not requesting a broadcast response, and we can
|
| 35 |
diff -up dhcp-4.1.0/server/dhcp.c.unicast dhcp-4.1.0/server/dhcp.c
|
| 36 |
--- dhcp-4.1.0/server/dhcp.c.unicast 2008-11-03 08:13:58.000000000 -1000
|
| 37 |
+++ dhcp-4.1.0/server/dhcp.c 2009-01-06 10:13:29.000000000 -1000
|
| 38 |
@@ -4111,6 +4111,7 @@ int locate_network (packet)
|
| 39 |
struct data_string data;
|
| 40 |
struct subnet *subnet = (struct subnet *)0;
|
| 41 |
struct option_cache *oc;
|
| 42 |
+ int norelay = 0;
|
| 43 |
|
| 44 |
/* See if there's a Relay Agent Link Selection Option, or a
|
| 45 |
* Subnet Selection Option. The Link-Select and Subnet-Select
|
| 46 |
@@ -4126,12 +4127,24 @@ int locate_network (packet)
|
| 47 |
from the interface, if there is one. If not, fail. */
|
| 48 |
if (!oc && !packet -> raw -> giaddr.s_addr) {
|
| 49 |
if (packet -> interface -> shared_network) {
|
| 50 |
- shared_network_reference
|
| 51 |
- (&packet -> shared_network,
|
| 52 |
- packet -> interface -> shared_network, MDL);
|
| 53 |
- return 1;
|
| 54 |
+ struct in_addr any_addr;
|
| 55 |
+ any_addr.s_addr = INADDR_ANY;
|
| 56 |
+
|
| 57 |
+ if (!packet -> packet_type && memcmp(&packet -> raw -> ciaddr, &any_addr, 4)) {
|
| 58 |
+ struct iaddr cip;
|
| 59 |
+ memcpy(cip.iabuf, &packet -> raw -> ciaddr, 4);
|
| 60 |
+ cip.len = 4;
|
| 61 |
+ if (!find_grouped_subnet(&subnet, packet->interface->shared_network, cip, MDL))
|
| 62 |
+ norelay = 2;
|
| 63 |
+ }
|
| 64 |
+
|
| 65 |
+ if (!norelay) {
|
| 66 |
+ shared_network_reference(&packet -> shared_network, packet -> interface -> shared_network, MDL);
|
| 67 |
+ return 1;
|
| 68 |
+ }
|
| 69 |
+ } else {
|
| 70 |
+ return 0;
|
| 71 |
}
|
| 72 |
- return 0;
|
| 73 |
}
|
| 74 |
|
| 75 |
/* If there's an option indicating link connection, and it's valid,
|
| 76 |
@@ -4154,7 +4167,10 @@ int locate_network (packet)
|
| 77 |
data_string_forget (&data, MDL);
|
| 78 |
} else {
|
| 79 |
ia.len = 4;
|
| 80 |
- memcpy (ia.iabuf, &packet -> raw -> giaddr, 4);
|
| 81 |
+ if (norelay)
|
| 82 |
+ memcpy (ia.iabuf, &packet->raw->ciaddr, 4);
|
| 83 |
+ else
|
| 84 |
+ memcpy (ia.iabuf, &packet->raw->giaddr, 4);
|
| 85 |
}
|
| 86 |
|
| 87 |
/* If we know the subnet on which the IP address lives, use it. */
|
| 88 |
@@ -4162,7 +4178,10 @@ int locate_network (packet)
|
| 89 |
shared_network_reference (&packet -> shared_network,
|
| 90 |
subnet -> shared_network, MDL);
|
| 91 |
subnet_dereference (&subnet, MDL);
|
| 92 |
- return 1;
|
| 93 |
+ if (norelay)
|
| 94 |
+ return norelay;
|
| 95 |
+ else
|
| 96 |
+ return 1;
|
| 97 |
}
|
| 98 |
|
| 99 |
/* Otherwise, fail. */
|