/*1* Copyright (C) 2007-2011 B.A.T.M.A.N. contributors:2*3* Marek Lindner, Simon Wunderlich4*5* This program is free software; you can redistribute it and/or6* modify it under the terms of version 2 of the GNU General Public7* License as published by the Free Software Foundation.8*9* This program is distributed in the hope that it will be useful, but10* WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU12* General Public License for more details.13*14* You should have received a copy of the GNU General Public License15* along with this program; if not, write to the Free Software16* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA17* 02110-1301, USA18*19*/2021#ifndef _NET_BATMAN_ADV_PACKET_H_22#define _NET_BATMAN_ADV_PACKET_H_2324#define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */2526#define BAT_PACKET 0x0127#define BAT_ICMP 0x0228#define BAT_UNICAST 0x0329#define BAT_BCAST 0x0430#define BAT_VIS 0x0531#define BAT_UNICAST_FRAG 0x063233/* this file is included by batctl which needs these defines */34#define COMPAT_VERSION 1235#define DIRECTLINK 0x4036#define VIS_SERVER 0x2037#define PRIMARIES_FIRST_HOP 0x103839/* ICMP message types */40#define ECHO_REPLY 041#define DESTINATION_UNREACHABLE 342#define ECHO_REQUEST 843#define TTL_EXCEEDED 1144#define PARAMETER_PROBLEM 124546/* vis defines */47#define VIS_TYPE_SERVER_SYNC 048#define VIS_TYPE_CLIENT_UPDATE 14950/* fragmentation defines */51#define UNI_FRAG_HEAD 0x0152#define UNI_FRAG_LARGETAIL 0x025354struct batman_packet {55uint8_t packet_type;56uint8_t version; /* batman version field */57uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */58uint8_t tq;59uint32_t seqno;60uint8_t orig[6];61uint8_t prev_sender[6];62uint8_t ttl;63uint8_t num_tt;64uint8_t gw_flags; /* flags related to gateway class */65uint8_t align;66} __packed;6768#define BAT_PACKET_LEN sizeof(struct batman_packet)6970struct icmp_packet {71uint8_t packet_type;72uint8_t version; /* batman version field */73uint8_t msg_type; /* see ICMP message types above */74uint8_t ttl;75uint8_t dst[6];76uint8_t orig[6];77uint16_t seqno;78uint8_t uid;79} __packed;8081#define BAT_RR_LEN 168283/* icmp_packet_rr must start with all fields from imcp_packet84* as this is assumed by code that handles ICMP packets */85struct icmp_packet_rr {86uint8_t packet_type;87uint8_t version; /* batman version field */88uint8_t msg_type; /* see ICMP message types above */89uint8_t ttl;90uint8_t dst[6];91uint8_t orig[6];92uint16_t seqno;93uint8_t uid;94uint8_t rr_cur;95uint8_t rr[BAT_RR_LEN][ETH_ALEN];96} __packed;9798struct unicast_packet {99uint8_t packet_type;100uint8_t version; /* batman version field */101uint8_t dest[6];102uint8_t ttl;103} __packed;104105struct unicast_frag_packet {106uint8_t packet_type;107uint8_t version; /* batman version field */108uint8_t dest[6];109uint8_t ttl;110uint8_t flags;111uint8_t orig[6];112uint16_t seqno;113} __packed;114115struct bcast_packet {116uint8_t packet_type;117uint8_t version; /* batman version field */118uint8_t orig[6];119uint8_t ttl;120uint32_t seqno;121} __packed;122123struct vis_packet {124uint8_t packet_type;125uint8_t version; /* batman version field */126uint8_t vis_type; /* which type of vis-participant sent this? */127uint8_t entries; /* number of entries behind this struct */128uint32_t seqno; /* sequence number */129uint8_t ttl; /* TTL */130uint8_t vis_orig[6]; /* originator that announces its neighbors */131uint8_t target_orig[6]; /* who should receive this packet */132uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */133} __packed;134135#endif /* _NET_BATMAN_ADV_PACKET_H_ */136137138