mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-09-03 07:45:20 +00:00
Add dhcp_option_lookup and agent_option_lookup functions.
This commit is contained in:
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
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 */
|
#endif /* not lint */
|
||||||
|
|
||||||
#define DHCP_OPTION_DATA
|
#define DHCP_OPTION_DATA
|
||||||
@@ -723,3 +723,40 @@ void do_packet (interface, packbuf, len, from_port, from, hfrom)
|
|||||||
/* XXX what about freeing the options ?!? */
|
/* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user