dnsmasq: Update to v2.67test14.
[tomato.git] / release / src / router / dnsmasq / src / outpacket.c
blob9d64c01ef600ce139253cb0a2e0baebe91eacb24
1 /* dnsmasq is Copyright (c) 2000-2013 Simon Kelley
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 dated June, 1991, or
6 (at your option) version 3 dated 29 June, 2007.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "dnsmasq.h"
20 #ifdef HAVE_DHCP6
22 static size_t outpacket_counter;
24 void end_opt6(int container)
26 void *p = daemon->outpacket.iov_base + container + 2;
27 u16 len = outpacket_counter - container - 4 ;
29 PUTSHORT(len, p);
32 int save_counter(int newval)
34 int ret = outpacket_counter;
35 if (newval != -1)
36 outpacket_counter = newval;
38 return ret;
41 void *expand(size_t headroom)
43 void *ret;
45 if (expand_buf(&daemon->outpacket, outpacket_counter + headroom))
47 ret = daemon->outpacket.iov_base + outpacket_counter;
48 outpacket_counter += headroom;
49 return ret;
52 return NULL;
55 int new_opt6(int opt)
57 int ret = outpacket_counter;
58 void *p;
60 if ((p = expand(4)))
62 PUTSHORT(opt, p);
63 PUTSHORT(0, p);
66 return ret;
69 void *put_opt6(void *data, size_t len)
71 void *p;
73 if ((p = expand(len)) && data)
74 memcpy(p, data, len);
76 return p;
79 void put_opt6_long(unsigned int val)
81 void *p;
83 if ((p = expand(4)))
84 PUTLONG(val, p);
87 void put_opt6_short(unsigned int val)
89 void *p;
91 if ((p = expand(2)))
92 PUTSHORT(val, p);
95 void put_opt6_char(unsigned int val)
97 unsigned char *p;
99 if ((p = expand(1)))
100 *p = val;
103 void put_opt6_string(char *s)
105 put_opt6(s, strlen(s));
108 #endif