]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Allow DHCP-Opcode and DHCP-Hop-Count to be set from VPs.
authorAlan T. DeKok <aland@freeradius.org>
Tue, 28 Jun 2011 13:54:12 +0000 (15:54 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 28 Jun 2011 13:54:12 +0000 (15:54 +0200)
This makes it easier to relay && respond to clients

src/lib/dhcp.c

index fe73cde1a824f8539a6e7a8a8aebd87d972a52a5..87afc3fd0568133667c2a235d89a9cec9c99df08 100644 (file)
@@ -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);