]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Add dhcp_option_lookup and agent_option_lookup functions.
authorTed Lemon <source@isc.org>
Sun, 19 Apr 1998 23:19:14 +0000 (23:19 +0000)
committerTed Lemon <source@isc.org>
Sun, 19 Apr 1998 23:19:14 +0000 (23:19 +0000)
common/options.c

index 8d6d4ed7f9ccb84089ad04943b146e9a977d8702..96db702048d0fdf8cc34f15437b4c718fd20d16c 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: options.c,v 1.30 1998/04/09 04:31:59 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: options.c,v 1.31 1998/04/19 23:19:14 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #define DHCP_OPTION_DATA
@@ -723,3 +723,40 @@ void do_packet (interface, packbuf, len, from_port, from, hfrom)
        /* XXX what about freeing the options ?!? */
 }
 
+struct data_string dhcp_option_lookup (packet, code)
+       struct packet *packet;
+       int code;
+{
+       struct data_string result;
+
+       result.len = packet -> options [code].len;
+       result.data = packet -> options [code].data;
+       result.terminated = 1;
+       result.buffer = (unsigned char *)0;
+       return result;
+}
+
+struct data_string agent_suboption_lookup (packet, code)
+       struct packet *packet;
+       int code;
+{
+       struct agent_options *ao;
+       struct option_tag *t;
+       struct data_string result;
+
+       memset (&result, 0, sizeof result);
+
+       /* Find the last set of agent options and consider it definitive. */
+       if (ao) {
+               for (ao = packet -> agent_options; ao -> next; ao = ao -> next)
+                       ;
+               for (t = ao -> first; t; t = t -> next)
+                       if (t -> data [0] == code) {
+                               result.len = t -> data [1];
+                               result.data = &t -> data [2];
+                               break;
+                       }
+       }
+       return result;
+}
+