From: Alan T. DeKok Date: Tue, 28 Jun 2011 13:54:12 +0000 (+0200) Subject: Allow DHCP-Opcode and DHCP-Hop-Count to be set from VPs. X-Git-Tag: release_2_1_12~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5eb9973104d40d7a2773cffeb4a6cda394ce48f1;p=thirdparty%2Ffreeradius-server.git Allow DHCP-Opcode and DHCP-Hop-Count to be set from VPs. This makes it easier to relay && respond to clients --- diff --git a/src/lib/dhcp.c b/src/lib/dhcp.c index fe73cde1a82..87afc3fd056 100644 --- a/src/lib/dhcp.c +++ b/src/lib/dhcp.c @@ -1141,14 +1141,25 @@ int fr_dhcp_encode(RADIUS_PACKET *packet, RADIUS_PACKET *original) } } - if (!original) { - *p++ = 1; /* client message */ + vp = pairfind(packet->vps, DHCP2ATTR(256)); + if (vp) { + *p++ = vp->vp_integer & 0xff; } else { - *p++ = 2; /* server message */ + if (!original) { + *p++ = 1; /* client message */ + } else { + *p++ = 2; /* server message */ + } } *p++ = 1; /* hardware type = ethernet */ *p++ = 6; /* 6 bytes of ethernet */ - *p++ = 0; /* hops */ + + vp = pairfind(packet->vps, DHCP2ATTR(259)); + if (vp) { + *p++ = vp->vp_integer & 0xff; + } else { + *p++ = 0; /* hops */ + } if (original) { /* Xid */ memcpy(p, original->data + 4, 4);