1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2015 Joyent, Inc. All rights reserved. 14 */ 15 16 /* 17 * Decode VXLAN encapsulated packets. 18 */ 19 20 #include <sys/vxlan.h> 21 #include "snoop.h" 22 23 extern interpreter_fn_t interpret_ether; 24 25 int 26 interpret_vxlan(int flags, char *data, int fraglen) 27 { 28 vxlan_hdr_t *vxlan = (vxlan_hdr_t *)data; 29 uint32_t id, vxf; 30 31 if (fraglen < sizeof (vxlan_hdr_t)) { 32 if (flags & F_SUM) 33 (void) snprintf(get_sum_line(), MAXLINE, 34 "VXLAN RUNT"); 35 if (flags & F_DTAIL) 36 show_header("VXLAN RUNT: ", "Short packet", fraglen); 37 38 return (fraglen); 39 } 40 41 id = ntohl(vxlan->vxlan_id) >> VXLAN_ID_SHIFT; 42 vxf = ntohl(vxlan->vxlan_flags); 43 44 if (flags & F_SUM) { 45 (void) snprintf(get_sum_line(), MAXLINE, 46 "VXLAN VNI=%d", id); 47 } 48 49 if (flags & F_DTAIL) { 50 show_header("VXLAN: ", "VXLAN Header", sizeof (vxlan_hdr_t)); 51 show_space(); 52 (void) snprintf(get_line(0, 0), get_line_remain(), 53 "Flags = 0x%08x", vxf); 54 (void) snprintf(get_line(0, 0), get_line_remain(), " %s", 55 getflag(vxf >> 24, VXLAN_F_VDI >> 24, "vni present", 56 "vni missing")); 57 (void) snprintf(get_line(0, 0), get_line_remain(), 58 "VXLAN network id (VNI) = %d", id); 59 show_space(); 60 } 61 62 if (flags & (F_DTAIL | F_ALLSUM)) { 63 fraglen -= sizeof (vxlan_hdr_t); 64 data += sizeof (vxlan_hdr_t); 65 66 return (interpret_ether(flags, data, fraglen, fraglen)); 67 } 68 69 return (0); 70 } 71