The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
vmps.c
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
15 */
16
17/**
18 * $Id: 137ce952f0a67ac2cf61160d71d7106d8604d396 $
19 *
20 * @file src/protocols/vmps/vmps.c
21 * @brief Functions to send/receive VQP packets.
22 *
23 * @copyright 2007 Alan DeKok (aland@deployingradius.com)
24 */
25
26RCSID("$Id: 137ce952f0a67ac2cf61160d71d7106d8604d396 $")
27
28#include <freeradius-devel/io/test_point.h>
29#include <freeradius-devel/protocol/vmps/vmps.h>
30#include <freeradius-devel/util/dbuff.h>
31#include <freeradius-devel/util/proto.h>
32#include <freeradius-devel/util/udp.h>
33
34#include "vmps.h"
35#include "attrs.h"
36
37/** Used as the decoder ctx
38 *
39 */
40typedef struct {
43
44/*
45 * http://www.openbsd.org/cgi-bin/cvsweb/src/usr.sbin/tcpdump/print-vqp.c
46 *
47 * Chapter 12 of Hacking Cisco Networks Exposed (Vladimirov, Gavrilenko,
48 * and Mikhailovsky, McGraw-Hill 2005) describes some of how it works.
49 *
50 * VLAN Query Protocol (VQP)
51 *
52 * 0 1 2 3
53 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
54 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
55 * | Version | Opcode | Response Code | Data Count |
56 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
57 * | Transaction ID |
58 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
59 * | Type (1) |
60 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61 * | Length | Data /
62 * / /
63 * / /
64 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
65 * | Type (n) |
66 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
67 * | Length | Data /
68 * / /
69 * / /
70 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
71 *
72 * VQP is layered over UDP. The default destination port is 1589.
73 *
74 */
76 [FR_PACKET_TYPE_VALUE_JOIN_REQUEST] = "Join-Request",
77 [FR_PACKET_TYPE_VALUE_JOIN_RESPONSE] = "Join-Response",
78 [FR_PACKET_TYPE_VALUE_RECONFIRM_REQUEST] = "Reconfirm-Request",
79 [FR_PACKET_TYPE_VALUE_RECONFIRM_RESPONSE] = "Reconfirm-Response",
80};
81
82
83bool fr_vmps_ok(uint8_t const *packet, size_t *packet_len)
84{
85 uint8_t const *ptr;
86 ssize_t data_len;
87 int attrlen;
88
89 if (*packet_len == FR_VQP_HDR_LEN) return true;
90
91 /*
92 * Skip the header.
93 */
94 ptr = packet + FR_VQP_HDR_LEN;
95 data_len = *packet_len - FR_VQP_HDR_LEN;
96
97 while (data_len > 0) {
98 if (data_len < 7) {
99 fr_strerror_const("Packet contains malformed attribute");
100 return false;
101 }
102
103 /*
104 * Attributes are 4 bytes
105 * 0x00000c01 ... 0x00000c08
106 */
107 if ((ptr[0] != 0) || (ptr[1] != 0) ||
108 (ptr[2] != 0x0c) || (ptr[3] < 1) || (ptr[3] > 8)) {
109 fr_strerror_const("Packet contains invalid attribute");
110 return false;
111 }
112
113 /*
114 * Length is 2 bytes
115 */
116 attrlen = fr_nbo_to_uint16(ptr + 4);
117
118 /*
119 * Total of attribute lengths shouldn't exceed *packet_len - header length,
120 * which happens iff at some point, attrlen exceeds data_lan.
121 */
122 if (attrlen > data_len) {
123 fr_strerror_printf("Packet attributes cause total length "
124 "plus header length to exceed packet length %lx",
125 *packet_len);
126 return false;
127 }
128
129 /*
130 * We support short lengths, as there's no reason
131 * for bigger lengths to exist... admins won't be
132 * typing in a 32K vlan name.
133 *
134 * It's OK for ethernet frames to be longer.
135 */
136 if ((ptr[3] != 5) && (attrlen > 250)) {
137 fr_strerror_printf("Packet contains attribute with invalid length %02x %02x", ptr[4], ptr[5]);
138 return false;
139 }
140
141 ptr += 6 + attrlen;
142 data_len -= (6 + attrlen);
143 }
144
145 /*
146 * UDP reads may return too much data, so we truncate it.
147 */
148 *packet_len = ptr - packet;
149
150 return true;
151}
152
153
154int fr_vmps_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, unsigned int *code)
155{
156 uint8_t const *ptr, *end;
157 int attr;
158 size_t attr_len;
159 fr_pair_t *vp;
160
161 if (data_len < FR_VQP_HDR_LEN) return -1;
162
164 if (!vp) {
165 oom:
166 fr_strerror_const("Out of Memory");
167 return -1;
168 }
169 vp->vp_uint32 = data[1];
170 if (code) *code = data[1];
171 vp->vp_tainted = true;
173
175 if (!vp) goto oom;
176 vp->vp_uint32 = data[2];
177 vp->vp_tainted = true;
179
181 if (!vp) goto oom;
182
183 vp->vp_uint32 = fr_nbo_to_uint32(data + 4);
184 vp->vp_tainted = true;
186
187 ptr = data + FR_VQP_HDR_LEN;
188 end = data + data_len;
189
190 /*
191 * Note that vmps_recv() MUST ensure that the packet is
192 * formatted in a way we expect, and that vmps_recv() MUST
193 * be called before vmps_decode().
194 */
195 while (ptr < end) {
196 if ((end - ptr) < 6) {
197 fr_strerror_printf("Packet is too small. (%ld < 6)", (end - ptr));
198 return -1;
199 }
200
201 attr = fr_nbo_to_uint16(ptr + 2);
202 attr_len = fr_nbo_to_uint16(ptr + 4);
203 ptr += 6;
204
205 /*
206 * fr_vmps_ok() should have checked this already,
207 * but it doesn't hurt to do it again.
208 */
209 if (attr_len > (size_t) (end - ptr)) {
210 fr_strerror_const("Attribute length exceeds received data");
211 return -1;
212 }
213
214 /*
215 * Create the VP.
216 */
218 if (!vp) {
219 fr_strerror_const("No memory");
220 return -1;
221 }
222
223 /*
224 * Rely on value_box to do the work.
225 *
226 * @todo - if the attribute is malformed, create a "raw" one.
227 */
228 if (fr_value_box_from_network(vp, &vp->data, vp->vp_type, vp->da,
229 &FR_DBUFF_TMP(ptr, attr_len), attr_len, true) < 0) {
231 return -1;
232 }
233
234 ptr += attr_len;
235 vp->vp_tainted = true;
237 }
238
239 /*
240 * FIXME: Map attributes to Calling-Station-Id, etc...
241 */
242
243 return data_len;
244}
245
246#if 0
247/*
248 * These are the MUST HAVE contents for a VQP packet.
249 *
250 * We don't allow the caller to give less than these, because
251 * it won't work. We don't encode more than these, because the
252 * clients will ignore it.
253 *
254 * FIXME: Be more generous? Look for CISCO + VQP attributes?
255 *
256 * @todo - actually use these again...
257 */
258static int contents[5][VQP_MAX_ATTRIBUTES] = {
259 { 0, 0, 0, 0, 0, 0 },
260 { 0x0c01, 0x0c02, 0x0c03, 0x0c04, 0x0c07, 0x0c05 }, /* Join request */
261 { 0x0c03, 0x0c08, 0, 0, 0, 0 }, /* Join Response */
262 { 0x0c01, 0x0c02, 0x0c03, 0x0c04, 0x0c07, 0x0c08 }, /* Reconfirm */
263 { 0x0c03, 0x0c08, 0, 0, 0, 0 }
264};
265#endif
266
267ssize_t fr_vmps_encode(fr_dbuff_t *dbuff, uint8_t const *original,
268 int code, uint32_t seq_no, fr_dcursor_t *cursor)
269{
270 fr_dbuff_t work_dbuff = FR_DBUFF(dbuff);
271 fr_pair_t *vp;
272 fr_dbuff_marker_t hdr, m;
273 uint8_t data_count = 0;
274
275 /*
276 * Let's keep a reference for packet header, and another
277 * to let us write to to the encoding as needed.
278 */
279 fr_dbuff_marker(&hdr, &work_dbuff);
280 fr_dbuff_marker(&m, &work_dbuff);
281
282 /*
283 * Create the header
284 */
285 FR_DBUFF_IN_BYTES_RETURN(&work_dbuff, FR_VQP_VERSION, /* Version */
286 code, /* Opcode */
287 FR_ERROR_CODE_VALUE_NO_ERROR, /* Response Code */
288 data_count); /* Data Count */
289
290 if (original) {
291 FR_DBUFF_IN_MEMCPY_RETURN(&work_dbuff, original + 4, 4);
292 } else {
293 FR_DBUFF_IN_RETURN(&work_dbuff, seq_no);
294 }
295
296 /*
297 * Encode the VP's.
298 */
299 while ((vp = fr_dcursor_current(cursor))) {
300 ssize_t slen;
301
302 if (vp->da == attr_packet_type) {
303 fr_dbuff_set(&m, fr_dbuff_current(&hdr) + 1);
304 FR_DBUFF_IN_RETURN(&m, (uint8_t)vp->vp_uint32);
305 fr_dcursor_next(cursor);
306 continue;
307 }
308
309 if (vp->da == attr_error_code) {
310 fr_dbuff_set(&m, fr_dbuff_current(&hdr) + 2);
311 FR_DBUFF_IN_RETURN(&m, vp->vp_uint8);
312 fr_dcursor_next(cursor);
313 continue;
314 }
315
316 if (!original && (vp->da == attr_sequence_number)) {
317 fr_dbuff_set(&m, fr_dbuff_current(&hdr) + 4);
318 FR_DBUFF_IN_RETURN(&m, vp->vp_uint32);
319 fr_dcursor_next(cursor);
320 continue;
321 }
322
323 if (!fr_type_is_leaf(vp->vp_type)) continue;
324
325 /*
326 * Type. Note that we look at only the lower 8
327 * bits, as the upper 8 bits have been hacked.
328 * See also dictionary.vmps
329 */
330
331 /* Type */
332 FR_DBUFF_IN_BYTES_RETURN(&work_dbuff, 0x00, 0x00, 0x0c, (vp->da->attr & 0xff));
333
334 /* Length */
335 fr_dbuff_set(&m, fr_dbuff_current(&work_dbuff));
336 FR_DBUFF_IN_RETURN(&work_dbuff, (uint16_t) 0);
337
338 /* Data */
339 slen = fr_value_box_to_network(&work_dbuff, &vp->data);
340 if (slen < 0) return slen;
341
342 FR_DBUFF_IN_RETURN(&m, (uint16_t) slen);
343
344 data_count++;
345
346 fr_dcursor_next(cursor);
347 }
348
349 /*
350 * Update the Data Count
351 */
352 fr_dbuff_set(&m, fr_dbuff_current(&hdr) + 3);
353 FR_DBUFF_IN_RETURN(&m, data_count);
354
355 return fr_dbuff_set(dbuff, &work_dbuff);
356}
357
358
359/** See how big of a packet is in the buffer.
360 *
361 * Packet is not 'const * const' because we may update data_len, if there's more data
362 * in the UDP packet than in the VMPS packet.
363 *
364 * @param data pointer to the packet buffer
365 * @param data_len length of the packet buffer
366 * @return
367 * <= 0 packet is bad.
368 * >0 how much of the data is a packet (can be larger than data_len)
369 */
370ssize_t fr_vmps_packet_size(uint8_t const *data, size_t data_len)
371{
372 int attributes;
373 uint8_t const *ptr, *end;
374
375 if (data_len < FR_VQP_HDR_LEN) return FR_VQP_HDR_LEN;
376
377 /*
378 * No attributes.
379 */
380 if (data[3] == 0) return FR_VQP_HDR_LEN;
381
382 /*
383 * Too many attributes. Return an error indicating that
384 * there's a problem with octet 3.
385 */
386 if (data[3] > 30) return -3;
387
388 /*
389 * Look for attributes.
390 */
391 ptr = data + FR_VQP_HDR_LEN;
392 attributes = data[3];
393
394 end = data + data_len;
395
396 while (attributes > 0) {
397 size_t attr_len;
398
399 /*
400 * Not enough room for the attribute headers, we
401 * want at least those.
402 */
403 if ((end - ptr) < 6) {
404 return 6 * attributes;
405 }
406
407 /*
408 * Length of the data NOT including the header.
409 */
410 attr_len = fr_nbo_to_uint16(ptr + 4);
411
412 ptr += 6 + attr_len;
413
414 /*
415 * We don't want to read infinite amounts of data.
416 *
417 * Return an error indicating that there's a
418 * problem with the final octet
419 */
420 if ((ptr - data) > 4096) {
421 return -(ptr - data);
422 }
423
424 /*
425 * This attribute has been checked.
426 */
427 attributes--;
428
429 /*
430 * The packet we want is larger than the input
431 * buffer, so we return the length of the current
432 * attribute, plus the length of the remaining
433 * headers.
434 */
435 if (ptr > end) return (6 * attributes) + ptr - data;
436 }
437
438 /*
439 * We've reached the end of the packet.
440 */
441 return ptr - data;
442}
443
444static void print_hex_data(uint8_t const *ptr, int attrlen, int depth)
445{
446 int i;
447 static char const tabs[] = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
448
449 for (i = 0; i < attrlen; i++) {
450 if ((i > 0) && ((i & 0x0f) == 0x00))
451 fprintf(fr_log_fp, "%.*s", depth, tabs);
452 fprintf(fr_log_fp, "%02x ", ptr[i]);
453 if ((i & 0x0f) == 0x0f) fprintf(fr_log_fp, "\n");
454 }
455 if ((i & 0x0f) != 0) fprintf(fr_log_fp, "\n");
456}
457
458
459/** Print a raw VMPS packet as hex.
460 *
461 */
462void fr_vmps_print_hex(FILE *fp, uint8_t const *packet, size_t packet_len)
463{
464 uint32_t length;
465 uint8_t const *attr, *end;
466 uint32_t id;
467
468 if (packet_len < 8) return;
469
470 fprintf(fp, " Version:\t\t%u\n", packet[0]);
471
472 if ((packet[1] > 0) && (packet[1] < FR_VMPS_CODE_MAX) && fr_vmps_packet_names[packet[1]]) {
473 fprintf(fp, " OpCode:\t\t%s\n", fr_vmps_packet_names[packet[1]]);
474 } else {
475 fprintf(fp, " OpCode:\t\t%u\n", packet[1]);
476 }
477
478 if ((packet[2] > 0) && (packet[2] < FR_VMPS_CODE_MAX) && fr_vmps_packet_names[packet[2]]) {
479 fprintf(fp, " OpCode:\t\t%s\n", fr_vmps_packet_names[packet[2]]);
480 } else {
481 fprintf(fp, " OpCode:\t\t%u\n", packet[2]);
482 }
483
484 fprintf(fp, " Data Count:\t\t%u\n", packet[3]);
485
486 memcpy(&id, packet + 4, 4);
487 id = ntohl(id);
488
489 fprintf(fp, " ID:\t%08x\n", id);
490
491 if (packet_len == 8) return;
492
493 for (attr = packet + 8, end = packet + packet_len;
494 attr < end;
495 attr += length) {
496 memcpy(&id, attr, 4);
497 id = ntohl(id);
498
499 length = fr_nbo_to_uint16(attr + 4);
500 if (length > (end - attr)) break;
501
502 fprintf(fp, "\t\t%08x %04x ", id, length);
503
504 print_hex_data(attr + 6, length - 6, 3);
505 }
506}
507
508/*
509 * Test points for protocol decode
510 */
512 uint8_t const *data, size_t data_len, void *proto_ctx)
513{
514 return fr_vmps_decode(ctx, out, data, data_len, proto_ctx);
515}
516
518{
520
521 return 0;
522}
523
524static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
525{
526 fr_vmps_ctx_t *test_ctx;
527
528 if (fr_vmps_global_init() < 0) return -1;
529
530 test_ctx = talloc_zero(ctx, fr_vmps_ctx_t);
531 if (!test_ctx) return -1;
532
533 talloc_set_destructor(test_ctx, _decode_test_ctx);
534
535 *out = test_ctx;
536
537 return 0;
538}
539
545
546/*
547 * Test points for protocol encode
548 */
549static ssize_t fr_vmps_encode_proto(UNUSED TALLOC_CTX *ctx, fr_pair_list_t *vps, uint8_t *data, size_t data_len, UNUSED void *proto_ctx)
550{
551 fr_dcursor_t cursor;
552
554
555 return fr_vmps_encode(&FR_DBUFF_TMP(data, data_len), NULL, -1, -1, &cursor);
556}
557
559{
561
562 return 0;
563}
564
565static int encode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
566{
567 fr_vmps_ctx_t *test_ctx;
568
569 if (fr_vmps_global_init() < 0) return -1;
570
571 test_ctx = talloc_zero(ctx, fr_vmps_ctx_t);
572 if (!test_ctx) return -1;
573
574 talloc_set_destructor(test_ctx, _encode_test_ctx);
575
576 *out = test_ctx;
577
578 return 0;
579}
580
#define RCSID(id)
Definition build.h:483
#define UNUSED
Definition build.h:315
static const char * tabs
Definition command.c:1581
struct fr_dbuff_marker_s fr_dbuff_marker_t
A position marker associated with a dbuff.
Definition dbuff.h:81
#define fr_dbuff_current(_dbuff_or_marker)
Return the 'current' position of a dbuff or marker.
Definition dbuff.h:911
#define fr_dbuff_set(_dst, _src)
Set the 'current' position in a dbuff or marker using another dbuff or marker, a char pointer,...
Definition dbuff.h:1004
static uint8_t * fr_dbuff_marker(fr_dbuff_marker_t *m, fr_dbuff_t *dbuff)
Initialises a new marker pointing to the 'current' position of the dbuff.
Definition dbuff.h:1192
#define FR_DBUFF_IN_MEMCPY_RETURN(_dbuff_or_marker, _in, _inlen)
Copy exactly _inlen bytes into dbuff or marker returning if there's insufficient space.
Definition dbuff.h:1382
#define FR_DBUFF_IN_RETURN(_dbuff_or_marker, _in)
Copy data from a fixed sized C type into a dbuff returning if there is insufficient space.
Definition dbuff.h:1585
#define FR_DBUFF(_dbuff_or_marker)
Create a new dbuff pointing to the same underlying buffer.
Definition dbuff.h:222
#define FR_DBUFF_IN_BYTES_RETURN(_dbuff_or_marker,...)
Copy a byte sequence into a dbuff or marker returning if there's insufficient space.
Definition dbuff.h:1472
#define FR_DBUFF_TMP(_start, _len_or_end)
Creates a compound literal to pass into functions which accept a dbuff.
Definition dbuff.h:514
static void * fr_dcursor_next(fr_dcursor_t *cursor)
Advanced the cursor to the next item.
Definition dcursor.h:288
static void * fr_dcursor_current(fr_dcursor_t *cursor)
Return the item the cursor current points to.
Definition dcursor.h:337
static fr_dict_attr_t const * attr_packet_type
Definition dhcpclient.c:89
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
Definition dict_util.c:2400
talloc_free(reap)
FILE * fr_log_fp
Definition log.c:42
unsigned short uint16_t
unsigned int uint32_t
long int ssize_t
unsigned char uint8_t
static uint8_t depth(fr_minmax_heap_index_t i)
Definition minmax_heap.c:83
static uint16_t fr_nbo_to_uint16(uint8_t const data[static sizeof(uint16_t)])
Read an unsigned 16bit integer from wire format (big endian)
Definition nbo.h:146
static uint32_t fr_nbo_to_uint32(uint8_t const data[static sizeof(uint32_t)])
Read an unsigned 32bit integer from wire format (big endian)
Definition nbo.h:167
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
Definition pair.c:1345
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
Definition pair.c:283
fr_pair_t * fr_pair_afrom_child_num(TALLOC_CTX *ctx, fr_dict_attr_t const *parent, unsigned int attr)
Create a new valuepair.
Definition pair.c:371
void * fr_proto_next_encodable(fr_dlist_head_t *list, void *current, void *uctx)
Implements the default iterator to encode pairs belonging to a specific dictionary that are not inter...
Definition proto.c:100
static fr_dict_t const * dict_vmps
Definition proto_vmps.c:74
VQP attributes.
HIDDEN fr_dict_attr_t const * attr_error_code
Definition base.c:42
HIDDEN fr_dict_attr_t const * attr_sequence_number
Definition base.c:44
int fr_vmps_global_init(void)
Definition base.c:55
void fr_vmps_global_free(void)
Definition base.c:79
fr_pair_t * vp
Stores an attribute, a value and various bits of other data.
Definition pair.h:68
fr_dict_attr_t const *_CONST da
Dictionary attribute defines the attribute number, vendor and type of the pair.
Definition pair.h:69
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
Definition test_point.h:75
fr_test_point_ctx_alloc_t test_ctx
Allocate a test ctx for the encoder.
Definition test_point.h:67
Entry point for protocol decoders.
Definition test_point.h:66
Entry point for protocol encoders.
Definition test_point.h:74
#define fr_pair_dcursor_iter_init(_cursor, _list, _iter, _uctx)
Initialises a special dcursor with callbacks that will maintain the attr sublists correctly.
Definition pair.h:569
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
Definition strerror.h:64
#define fr_strerror_const(_msg)
Definition strerror.h:223
#define fr_type_is_leaf(_x)
Definition types.h:372
ssize_t fr_value_box_from_network(TALLOC_CTX *ctx, fr_value_box_t *dst, fr_type_t type, fr_dict_attr_t const *enumv, fr_dbuff_t *dbuff, size_t len, bool tainted)
Decode a fr_value_box_t from serialized binary data.
Definition value.c:1754
ssize_t fr_value_box_to_network(fr_dbuff_t *dbuff, fr_value_box_t const *value)
Encode a single value box, serializing its contents in generic network format.
Definition value.c:1404
static fr_slen_t data
Definition value.h:1265
static size_t char ** out
Definition value.h:997
static ssize_t fr_vmps_decode_proto(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, void *proto_ctx)
Definition vmps.c:511
static void print_hex_data(uint8_t const *ptr, int attrlen, int depth)
Definition vmps.c:444
static int decode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
Definition vmps.c:524
int nothing
Definition vmps.c:41
int fr_vmps_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, uint8_t const *data, size_t data_len, unsigned int *code)
Definition vmps.c:154
ssize_t fr_vmps_encode(fr_dbuff_t *dbuff, uint8_t const *original, int code, uint32_t seq_no, fr_dcursor_t *cursor)
Definition vmps.c:267
static int _encode_test_ctx(UNUSED fr_vmps_ctx_t *proto_ctx)
Definition vmps.c:558
char const * fr_vmps_packet_names[FR_VMPS_CODE_MAX]
Definition vmps.c:75
static int encode_test_ctx(void **out, TALLOC_CTX *ctx, UNUSED fr_dict_t const *dict)
Definition vmps.c:565
static int _decode_test_ctx(UNUSED fr_vmps_ctx_t *proto_ctx)
Definition vmps.c:517
static ssize_t fr_vmps_encode_proto(UNUSED TALLOC_CTX *ctx, fr_pair_list_t *vps, uint8_t *data, size_t data_len, UNUSED void *proto_ctx)
Definition vmps.c:549
bool fr_vmps_ok(uint8_t const *packet, size_t *packet_len)
Definition vmps.c:83
ssize_t fr_vmps_packet_size(uint8_t const *data, size_t data_len)
See how big of a packet is in the buffer.
Definition vmps.c:370
fr_test_point_proto_decode_t vmps_tp_decode_proto
Definition vmps.c:541
void fr_vmps_print_hex(FILE *fp, uint8_t const *packet, size_t packet_len)
Print a raw VMPS packet as hex.
Definition vmps.c:462
fr_test_point_proto_encode_t vmps_tp_encode_proto
Definition vmps.c:582
Used as the decoder ctx.
Definition vmps.c:40
Structures and prototypes for Cisco's VLAN Query Protocol.
@ FR_VMPS_CODE_MAX
Definition vmps.h:54
#define FR_VQP_VERSION
Definition vmps.h:35
#define FR_VQP_HDR_LEN
Definition vmps.h:34