-/*
- * Function: dhcpoa_{init_common, init_no_end, init}
- *
- * Purpose:
- * Initialize an option area structure so that it can be used
- * in calling the dhcpoa_* routines.
- */
-static void
-dhcpoa_init_common(dhcpoa_t * oa_p, void * buffer, int size, int reserve)
-{
- bzero(oa_p, sizeof(*oa_p));
- oa_p->oa_buffer = buffer;
- oa_p->oa_size = size;
- oa_p->oa_reserve = reserve;
-}
-
-void
-dhcpoa_init_no_end(dhcpoa_t * oa_p, void * buffer, int size)
-{
- dhcpoa_init_common(oa_p, buffer, size, 0);
- return;
-}
-
-int
-dhcpoa_size(dhcpoa_t * oa_p)
-{
- return (oa_p->oa_size);
-}
-
-void
-dhcpoa_init(dhcpoa_t * oa_p, void * buffer, int size)
-{
- /* initialize the area, reserve space for the end tag */
- dhcpoa_init_common(oa_p, buffer, size, 1);
- return;
-}
-/*
- * Function: dhcpoa_add
- *
- * Purpose:
- * Add an option to the option area.
- */
-dhcpoa_ret_t
-dhcpoa_add(dhcpoa_t * oa_p, dhcptag_t tag, int len, const void * option)
-{
- if (len > DHCP_OPTION_SIZE_MAX) {
- dprintf(("tag %d option %d > %d\n", tag, len, DHCP_OPTION_SIZE_MAX));
- return (dhcpoa_failed_e);
- }
-
- if (oa_p->oa_end_tag) {
- dprintf(("attempt to add data after end tag\n"));
- return (dhcpoa_failed_e);
- }
-
- switch (tag) {
- case dhcptag_end_e:
- if ((oa_p->oa_offset + 1) > oa_p->oa_size) {
- /* this can't happen since we're careful to leave space */
- dprintf(("can't add end tag %d > %d\n",
- oa_p->oa_offset + oa_p->oa_reserve, oa_p->oa_size));
- return (dhcpoa_failed_e);