Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 441 lines (351 sloc) 9.527 kb
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
1 /*
2 * Copyright (c) 2003, 2004 Niels Provos <provos@citi.umich.edu>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #ifdef HAVE_CONFIG_H
b5d2f9a2 » provos
2007-03-01 rolling back r339: evconfig.h does not work
29 #include "config.h"
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
30 #endif
31
4e1ec3e0 » Nick Mathewson
2007-11-07 Make all the C files in the libraries compile under MSVC 2005 Express…
32 #ifdef HAVE_SYS_TYPES_H
33 #include <sys/types.h>
34 #endif
35 #ifdef HAVE_SYS_PARAM_H
36 #include <sys/param.h>
37 #endif
38
868f10e7 » provos
2006-11-22 mingw fixes from Nick
39 #ifdef WIN32
40 #define WIN32_LEAN_AND_MEAN
4e1ec3e0 » Nick Mathewson
2007-11-07 Make all the C files in the libraries compile under MSVC 2005 Express…
41 #include <winsock2.h>
868f10e7 » provos
2006-11-22 mingw fixes from Nick
42 #include <windows.h>
43 #undef WIN32_LEAN_AND_MEAN
44 #else
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
45 #include <sys/ioctl.h>
868f10e7 » provos
2006-11-22 mingw fixes from Nick
46 #endif
47
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
48 #include <sys/queue.h>
49 #ifdef HAVE_SYS_TIME_H
50 #include <sys/time.h>
51 #endif
52
53 #include <errno.h>
54 #include <stdio.h>
55 #include <stdlib.h>
56 #include <string.h>
868f10e7 » provos
2006-11-22 mingw fixes from Nick
57 #ifndef WIN32
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
58 #include <syslog.h>
868f10e7 » provos
2006-11-22 mingw fixes from Nick
59 #endif
4e1ec3e0 » Nick Mathewson
2007-11-07 Make all the C files in the libraries compile under MSVC 2005 Express…
60 #ifdef HAVE_UNISTD_H
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
61 #include <unistd.h>
4e1ec3e0 » Nick Mathewson
2007-11-07 Make all the C files in the libraries compile under MSVC 2005 Express…
62 #endif
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
63
64 #include "event.h"
94af961f » provos
2006-07-18 get rid of err.h
65 #include "log.h"
7eb250e9 » Nick Mathewson
2007-11-25 r14939@tombo: nickm | 2007-11-25 11:59:26 -0500
66 #include "mm-internal.h"
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
67
ffd606cd » provos
2007-12-13 prefix {encode,decode}_tag functions with evtag to avoid collisions
68 int evtag_decode_int(uint32_t *pnumber, struct evbuffer *evbuf);
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
69
c4836d10 » provos
2006-11-17 make sure that the rpc callback receives an unmarshaled payload;
70 static struct evbuffer *_buf; /* not thread safe */
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
71
72 void
35983cd6 » Nick Mathewson
2007-08-16 r14618@catbus: nickm | 2007-08-16 17:11:47 -0400
73 evtag_init(void)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
74 {
c4836d10 » provos
2006-11-17 make sure that the rpc callback receives an unmarshaled payload;
75 if (_buf != NULL)
76 return;
77
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
78 if ((_buf = evbuffer_new()) == NULL)
94af961f » provos
2006-07-18 get rid of err.h
79 event_err(1, "%s: malloc", __func__);
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
80 }
81
82 /*
83 * We encode integer's by nibbles; the first nibble contains the number
84 * of significant nibbles - 1; this allows us to encode up to 64-bit
85 * integers. This function is byte-order independent.
86 */
87
88 void
753ffa56 » provos
2007-06-30 convert u_int8_t types to uint8_t types
89 encode_int(struct evbuffer *evbuf, uint32_t number)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
90 {
91 int off = 1, nibbles = 0;
753ffa56 » provos
2007-06-30 convert u_int8_t types to uint8_t types
92 uint8_t data[5];
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
93
94 memset(data, 0, sizeof(data));
95 while (number) {
96 if (off & 0x1)
97 data[off/2] = (data[off/2] & 0xf0) | (number & 0x0f);
98 else
99 data[off/2] = (data[off/2] & 0x0f) |
100 ((number & 0x0f) << 4);
101 number >>= 4;
102 off++;
103 }
104
105 if (off > 2)
106 nibbles = off - 2;
107
108 /* Off - 1 is the number of encoded nibbles */
109 data[0] = (data[0] & 0x0f) | ((nibbles & 0x0f) << 4);
110
111 evbuffer_add(evbuf, data, (off + 1) / 2);
112 }
113
114 /*
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
115 * Support variable length encoding of tags; we use the high bit in each
116 * octet as a continuation signal.
117 */
118
119 int
ffd606cd » provos
2007-12-13 prefix {encode,decode}_tag functions with evtag to avoid collisions
120 evtag_encode_tag(struct evbuffer *evbuf, uint32_t tag)
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
121 {
122 int bytes = 0;
123 uint8_t data[5];
124
125 memset(data, 0, sizeof(data));
126 do {
127 uint8_t lower = tag & 0x7f;
128 tag >>= 7;
129
130 if (tag)
131 lower |= 0x80;
132
133 data[bytes++] = lower;
134 } while (tag);
135
136 if (evbuf != NULL)
137 evbuffer_add(evbuf, data, bytes);
138
139 return (bytes);
140 }
141
ffd606cd » provos
2007-12-13 prefix {encode,decode}_tag functions with evtag to avoid collisions
142 static int
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
143 decode_tag_internal(uint32_t *ptag, struct evbuffer *evbuf, int dodrain)
144 {
145 uint32_t number = 0;
146 uint8_t *data = EVBUFFER_DATA(evbuf);
147 int len = EVBUFFER_LENGTH(evbuf);
148 int count = 0, shift = 0, done = 0;
149
150 while (count++ < len) {
151 uint8_t lower = *data++;
152 number |= (lower & 0x7f) << shift;
153 shift += 7;
154
155 if (!(lower & 0x80)) {
156 done = 1;
157 break;
158 }
159 }
160
161 if (!done)
162 return (-1);
163
164 if (dodrain)
165 evbuffer_drain(evbuf, count);
166
167 if (ptag != NULL)
168 *ptag = number;
169
170 return (count);
171 }
172
173 int
ffd606cd » provos
2007-12-13 prefix {encode,decode}_tag functions with evtag to avoid collisions
174 evtag_decode_tag(uint32_t *ptag, struct evbuffer *evbuf)
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
175 {
176 return (decode_tag_internal(ptag, evbuf, 1 /* dodrain */));
177 }
178
179 /*
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
180 * Marshal a data type, the general format is as follows:
181 *
182 * tag number: one byte; length: var bytes; payload: var bytes
183 */
184
185 void
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
186 evtag_marshal(struct evbuffer *evbuf, uint32_t tag,
753ffa56 » provos
2007-06-30 convert u_int8_t types to uint8_t types
187 const void *data, uint32_t len)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
188 {
ffd606cd » provos
2007-12-13 prefix {encode,decode}_tag functions with evtag to avoid collisions
189 evtag_encode_tag(evbuf, tag);
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
190 encode_int(evbuf, len);
191 evbuffer_add(evbuf, (void *)data, len);
192 }
193
194 /* Marshaling for integers */
195 void
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
196 evtag_marshal_int(struct evbuffer *evbuf, uint32_t tag, uint32_t integer)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
197 {
198 evbuffer_drain(_buf, EVBUFFER_LENGTH(_buf));
199 encode_int(_buf, integer);
200
ffd606cd » provos
2007-12-13 prefix {encode,decode}_tag functions with evtag to avoid collisions
201 evtag_encode_tag(evbuf, tag);
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
202 encode_int(evbuf, EVBUFFER_LENGTH(_buf));
203 evbuffer_add_buffer(evbuf, _buf);
204 }
205
206 void
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
207 evtag_marshal_string(struct evbuffer *buf, uint32_t tag, const char *string)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
208 {
209 evtag_marshal(buf, tag, string, strlen(string));
210 }
211
212 void
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
213 evtag_marshal_timeval(struct evbuffer *evbuf, uint32_t tag, struct timeval *tv)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
214 {
215 evbuffer_drain(_buf, EVBUFFER_LENGTH(_buf));
216
217 encode_int(_buf, tv->tv_sec);
218 encode_int(_buf, tv->tv_usec);
219
220 evtag_marshal(evbuf, tag, EVBUFFER_DATA(_buf),
221 EVBUFFER_LENGTH(_buf));
222 }
223
f0ff792a » provos
2007-06-30 fixes from Joerg Sonnenberger:
224 static int
753ffa56 » provos
2007-06-30 convert u_int8_t types to uint8_t types
225 decode_int_internal(uint32_t *pnumber, struct evbuffer *evbuf, int dodrain)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
226 {
753ffa56 » provos
2007-06-30 convert u_int8_t types to uint8_t types
227 uint32_t number = 0;
228 uint8_t *data = EVBUFFER_DATA(evbuf);
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
229 int len = EVBUFFER_LENGTH(evbuf);
7b7742fc » provos
2007-09-16 optimize by removing a variable
230 int nibbles = 0;
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
231
232 if (!len)
233 return (-1);
234
235 nibbles = ((data[0] & 0xf0) >> 4) + 1;
7b7742fc » provos
2007-09-16 optimize by removing a variable
236 if (nibbles > 8 || (nibbles >> 1) + 1 > len)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
237 return (-1);
7b7742fc » provos
2007-09-16 optimize by removing a variable
238 len = (nibbles >> 1) + 1;
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
239
7b7742fc » provos
2007-09-16 optimize by removing a variable
240 while (nibbles > 0) {
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
241 number <<= 4;
7b7742fc » provos
2007-09-16 optimize by removing a variable
242 if (nibbles & 0x1)
243 number |= data[nibbles >> 1] & 0x0f;
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
244 else
7b7742fc » provos
2007-09-16 optimize by removing a variable
245 number |= (data[nibbles >> 1] & 0xf0) >> 4;
246 nibbles--;
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
247 }
248
249 if (dodrain)
250 evbuffer_drain(evbuf, len);
251
252 *pnumber = number;
253
254 return (len);
255 }
256
257 int
ffd606cd » provos
2007-12-13 prefix {encode,decode}_tag functions with evtag to avoid collisions
258 evtag_decode_int(uint32_t *pnumber, struct evbuffer *evbuf)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
259 {
260 return (decode_int_internal(pnumber, evbuf, 1) == -1 ? -1 : 0);
261 }
262
263 int
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
264 evtag_peek(struct evbuffer *evbuf, uint32_t *ptag)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
265 {
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
266 return (decode_tag_internal(ptag, evbuf, 0 /* dodrain */));
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
267 }
268
269 int
753ffa56 » provos
2007-06-30 convert u_int8_t types to uint8_t types
270 evtag_peek_length(struct evbuffer *evbuf, uint32_t *plength)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
271 {
272 struct evbuffer tmp;
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
273 int res, len;
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
274
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
275 len = decode_tag_internal(NULL, evbuf, 0 /* dodrain */);
276 if (len == -1)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
277 return (-1);
278
279 tmp = *evbuf;
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
280 tmp.buffer += len;
281 tmp.off -= len;
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
282
283 res = decode_int_internal(plength, &tmp, 0);
284 if (res == -1)
285 return (-1);
286
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
287 *plength += res + len;
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
288
289 return (0);
290 }
291
292 int
753ffa56 » provos
2007-06-30 convert u_int8_t types to uint8_t types
293 evtag_payload_length(struct evbuffer *evbuf, uint32_t *plength)
32acc283 » provos
2005-08-27 a few more bug fixes
294 {
295 struct evbuffer tmp;
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
296 int res, len;
32acc283 » provos
2005-08-27 a few more bug fixes
297
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
298 len = decode_tag_internal(NULL, evbuf, 0 /* dodrain */);
299 if (len == -1)
32acc283 » provos
2005-08-27 a few more bug fixes
300 return (-1);
301
302 tmp = *evbuf;
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
303 tmp.buffer += len;
304 tmp.off -= len;
32acc283 » provos
2005-08-27 a few more bug fixes
305
306 res = decode_int_internal(plength, &tmp, 0);
307 if (res == -1)
308 return (-1);
309
310 return (0);
311 }
312
313 int
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
314 evtag_consume(struct evbuffer *evbuf)
315 {
753ffa56 » provos
2007-06-30 convert u_int8_t types to uint8_t types
316 uint32_t len;
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
317 if (decode_tag_internal(NULL, evbuf, 1 /* dodrain */) == -1)
318 return (-1);
ffd606cd » provos
2007-12-13 prefix {encode,decode}_tag functions with evtag to avoid collisions
319 if (evtag_decode_int(&len, evbuf) == -1)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
320 return (-1);
321 evbuffer_drain(evbuf, len);
322
323 return (0);
324 }
325
326 /* Reads the data type from an event buffer */
327
328 int
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
329 evtag_unmarshal(struct evbuffer *src, uint32_t *ptag, struct evbuffer *dst)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
330 {
753ffa56 » provos
2007-06-30 convert u_int8_t types to uint8_t types
331 uint32_t len;
332 uint32_t integer;
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
333
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
334 if (decode_tag_internal(ptag, src, 1 /* dodrain */) == -1)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
335 return (-1);
ffd606cd » provos
2007-12-13 prefix {encode,decode}_tag functions with evtag to avoid collisions
336 if (evtag_decode_int(&integer, src) == -1)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
337 return (-1);
338 len = integer;
339
340 if (EVBUFFER_LENGTH(src) < len)
341 return (-1);
342
343 if (evbuffer_add(dst, EVBUFFER_DATA(src), len) == -1)
344 return (-1);
345
346 evbuffer_drain(src, len);
347
348 return (len);
349 }
350
351 /* Marshaling for integers */
352
353 int
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
354 evtag_unmarshal_int(struct evbuffer *evbuf, uint32_t need_tag,
753ffa56 » provos
2007-06-30 convert u_int8_t types to uint8_t types
355 uint32_t *pinteger)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
356 {
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
357 uint32_t tag;
753ffa56 » provos
2007-06-30 convert u_int8_t types to uint8_t types
358 uint32_t len;
359 uint32_t integer;
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
360
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
361 if (decode_tag_internal(&tag, evbuf, 1 /* dodrain */) == -1)
362 return (-1);
363 if (need_tag != tag)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
364 return (-1);
ffd606cd » provos
2007-12-13 prefix {encode,decode}_tag functions with evtag to avoid collisions
365 if (evtag_decode_int(&integer, evbuf) == -1)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
366 return (-1);
367 len = integer;
368
369 if (EVBUFFER_LENGTH(evbuf) < len)
370 return (-1);
371
372 evbuffer_drain(_buf, EVBUFFER_LENGTH(_buf));
373 if (evbuffer_add(_buf, EVBUFFER_DATA(evbuf), len) == -1)
374 return (-1);
375
376 evbuffer_drain(evbuf, len);
377
ffd606cd » provos
2007-12-13 prefix {encode,decode}_tag functions with evtag to avoid collisions
378 return (evtag_decode_int(pinteger, _buf));
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
379 }
380
381 /* Unmarshal a fixed length tag */
382
383 int
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
384 evtag_unmarshal_fixed(struct evbuffer *src, uint32_t need_tag, void *data,
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
385 size_t len)
386 {
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
387 uint32_t tag;
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
388
389 /* Initialize this event buffer so that we can read into it */
390 evbuffer_drain(_buf, EVBUFFER_LENGTH(_buf));
391
392 /* Now unmarshal a tag and check that it matches the tag we want */
393 if (evtag_unmarshal(src, &tag, _buf) == -1 || tag != need_tag)
394 return (-1);
395
396 if (EVBUFFER_LENGTH(_buf) != len)
397 return (-1);
398
399 memcpy(data, EVBUFFER_DATA(_buf), len);
400 return (0);
401 }
402
403 int
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
404 evtag_unmarshal_string(struct evbuffer *evbuf, uint32_t need_tag,
50f7aaef » provos
2005-09-09 make it compile on mac os x
405 char **pstring)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
406 {
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
407 uint32_t tag;
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
408
409 evbuffer_drain(_buf, EVBUFFER_LENGTH(_buf));
410
411 if (evtag_unmarshal(evbuf, &tag, _buf) == -1 || tag != need_tag)
412 return (-1);
413
7eb250e9 » Nick Mathewson
2007-11-25 r14939@tombo: nickm | 2007-11-25 11:59:26 -0500
414 *pstring = event_calloc(EVBUFFER_LENGTH(_buf) + 1, 1);
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
415 if (*pstring == NULL)
94af961f » provos
2006-07-18 get rid of err.h
416 event_err(1, "%s: calloc", __func__);
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
417 evbuffer_remove(_buf, *pstring, EVBUFFER_LENGTH(_buf));
418
419 return (0);
420 }
421
422 int
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
423 evtag_unmarshal_timeval(struct evbuffer *evbuf, uint32_t need_tag,
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
424 struct timeval *ptv)
425 {
ba487199 » provos
2007-12-12 support for 32-bit tag numbers in rpc structures
426 uint32_t tag;
753ffa56 » provos
2007-06-30 convert u_int8_t types to uint8_t types
427 uint32_t integer;
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
428
429 evbuffer_drain(_buf, EVBUFFER_LENGTH(_buf));
430 if (evtag_unmarshal(evbuf, &tag, _buf) == -1 || tag != need_tag)
431 return (-1);
432
ffd606cd » provos
2007-12-13 prefix {encode,decode}_tag functions with evtag to avoid collisions
433 if (evtag_decode_int(&integer, _buf) == -1)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
434 return (-1);
435 ptv->tv_sec = integer;
ffd606cd » provos
2007-12-13 prefix {encode,decode}_tag functions with evtag to avoid collisions
436 if (evtag_decode_int(&integer, _buf) == -1)
c4e60994 » provos
2005-08-22 including the tagging code that is required by event_rpcgen.py; test the
437 return (-1);
438 ptv->tv_usec = integer;
439
440 return (0);
441 }
Something went wrong with that request. Please try again.