1251127Sdelphij/*
2251127Sdelphij * Redistribution and use in source and binary forms, with or without
3251127Sdelphij * modification, are permitted provided that: (1) source code
4251127Sdelphij * distributions retain the above copyright notice and this paragraph
5251127Sdelphij * in its entirety, and (2) distributions including binary code include
6251127Sdelphij * the above copyright notice and this paragraph in its entirety in
7251127Sdelphij * the documentation or other materials provided with the distribution.
8251127Sdelphij * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
9251127Sdelphij * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
10251127Sdelphij * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
11251127Sdelphij * FOR A PARTICULAR PURPOSE.
12251127Sdelphij *
13251127Sdelphij * Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com)
14251127Sdelphij */
15251127Sdelphij
16251127Sdelphij#ifdef HAVE_CONFIG_H
17251127Sdelphij#include "config.h"
18251127Sdelphij#endif
19251127Sdelphij
20251127Sdelphij#include <tcpdump-stdinc.h>
21251127Sdelphij
22251127Sdelphij#include <stdio.h>
23251127Sdelphij#include <stdlib.h>
24251127Sdelphij
25251127Sdelphij#include "interface.h"
26251127Sdelphij#include "extract.h"
27251127Sdelphij#include "addrtoname.h"
28251127Sdelphij
29251127Sdelphij#include "udp.h"
30251127Sdelphij
31251127Sdelphij/*
32251127Sdelphij * OTV header, draft-hasmit-otv-04
33251127Sdelphij *
34251127Sdelphij *     0                   1                   2                   3
35251127Sdelphij *     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
36251127Sdelphij *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37251127Sdelphij *     |R|R|R|R|I|R|R|R|           Overlay ID                          |
38251127Sdelphij *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39251127Sdelphij *     |          Instance ID                          | Reserved      |
40251127Sdelphij *     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41251127Sdelphij */
42251127Sdelphij
43251127Sdelphijvoid
44251158Sdelphijotv_print(const u_char *bp, u_int len)
45251127Sdelphij{
46251127Sdelphij    u_int8_t flags;
47251127Sdelphij    u_int32_t overlay_id;
48251127Sdelphij    u_int32_t instance_id;
49251127Sdelphij
50251127Sdelphij    if (len < 8) {
51251127Sdelphij        printf("[|OTV]");
52251127Sdelphij        return;
53251127Sdelphij    }
54251127Sdelphij
55251127Sdelphij    flags = *bp;
56251127Sdelphij    bp += 1;
57251127Sdelphij
58251127Sdelphij    overlay_id = EXTRACT_24BITS(bp);
59251127Sdelphij    bp += 3;
60251127Sdelphij
61251127Sdelphij    instance_id = EXTRACT_24BITS(bp);
62251127Sdelphij    bp += 4;
63251127Sdelphij
64251127Sdelphij    printf("OTV, ");
65251127Sdelphij
66251127Sdelphij    fputs("flags [", stdout);
67251127Sdelphij    if (flags & 0x08)
68251127Sdelphij        fputs("I", stdout);
69251127Sdelphij    else
70251127Sdelphij        fputs(".", stdout);
71251127Sdelphij    fputs("] ", stdout);
72251127Sdelphij
73251127Sdelphij    printf("(0x%02x), ", flags);
74251127Sdelphij    printf("overlay %u, ", overlay_id);
75251127Sdelphij    printf("instance %u\n", instance_id);
76251127Sdelphij
77251127Sdelphij    ether_print(gndo, bp, len - 8, len - 8, NULL, NULL);
78251127Sdelphij    return;
79251127Sdelphij}
80