1 /* dnsmasq is Copyright (c) 2000-2022 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/>.
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 ;
32 void reset_counter(void)
34 /* Clear out buffer when starting from beginning */
35 if (daemon->outpacket.iov_base)
36 memset(daemon->outpacket.iov_base, 0, daemon->outpacket.iov_len);
41 int save_counter(int newval)
43 int ret = outpacket_counter;
46 outpacket_counter = newval;
51 void *expand(size_t headroom)
55 if (expand_buf(&daemon->outpacket, outpacket_counter + headroom))
57 ret = daemon->outpacket.iov_base + outpacket_counter;
58 outpacket_counter += headroom;
67 int ret = outpacket_counter;
79 void *put_opt6(void *data, size_t len)
83 if ((p = expand(len)) && data)
89 void put_opt6_long(unsigned int val)
97 void put_opt6_short(unsigned int val)
105 void put_opt6_char(unsigned int val)
113 void put_opt6_string(char *s)
115 put_opt6(s, strlen(s));