aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/packet.h
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2011-06-04 05:26:00 -0400
committerSven Eckelmann <sven@narfation.org>2011-06-09 14:40:38 -0400
commite8958dbf0da377e11f385a9888da3f72e827ab26 (patch)
treebf2c84c423ebdfba4b88afad1fcb7d9a96070902 /net/batman-adv/packet.h
parent3d222bbaa7329e8ef45129e1bd6801000d7e05e4 (diff)
batman-adv: Use enums for related constants
CodingStyle "Chapter 12: Macros, Enums and RTL" recommends to use enums for several related constants. Internal states can be used without defining the actual value, but all values which are visible to the outside must be defined as before. Normal values are assigned as usual and flags are defined by shifts of a bit. Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/packet.h')
-rw-r--r--net/batman-adv/packet.h47
1 files changed, 29 insertions, 18 deletions
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index eda99650e9f8..9f77086a5461 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -24,33 +24,44 @@
24 24
25#define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */ 25#define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
26 26
27#define BAT_PACKET 0x01 27enum bat_packettype {
28#define BAT_ICMP 0x02 28 BAT_PACKET = 0x01,
29#define BAT_UNICAST 0x03 29 BAT_ICMP = 0x02,
30#define BAT_BCAST 0x04 30 BAT_UNICAST = 0x03,
31#define BAT_VIS 0x05 31 BAT_BCAST = 0x04,
32#define BAT_UNICAST_FRAG 0x06 32 BAT_VIS = 0x05,
33 BAT_UNICAST_FRAG = 0x06
34};
33 35
34/* this file is included by batctl which needs these defines */ 36/* this file is included by batctl which needs these defines */
35#define COMPAT_VERSION 12 37#define COMPAT_VERSION 12
36#define DIRECTLINK 0x40 38
37#define VIS_SERVER 0x20 39enum batman_flags {
38#define PRIMARIES_FIRST_HOP 0x10 40 PRIMARIES_FIRST_HOP = 1 << 4,
41 VIS_SERVER = 1 << 5,
42 DIRECTLINK = 1 << 6
43};
39 44
40/* ICMP message types */ 45/* ICMP message types */
41#define ECHO_REPLY 0 46enum icmp_packettype {
42#define DESTINATION_UNREACHABLE 3 47 ECHO_REPLY = 0,
43#define ECHO_REQUEST 8 48 DESTINATION_UNREACHABLE = 3,
44#define TTL_EXCEEDED 11 49 ECHO_REQUEST = 8,
45#define PARAMETER_PROBLEM 12 50 TTL_EXCEEDED = 11,
51 PARAMETER_PROBLEM = 12
52};
46 53
47/* vis defines */ 54/* vis defines */
48#define VIS_TYPE_SERVER_SYNC 0 55enum vis_packettype {
49#define VIS_TYPE_CLIENT_UPDATE 1 56 VIS_TYPE_SERVER_SYNC = 0,
57 VIS_TYPE_CLIENT_UPDATE = 1
58};
50 59
51/* fragmentation defines */ 60/* fragmentation defines */
52#define UNI_FRAG_HEAD 0x01 61enum unicast_frag_flags {
53#define UNI_FRAG_LARGETAIL 0x02 62 UNI_FRAG_HEAD = 1 << 0,
63 UNI_FRAG_LARGETAIL = 1 << 1
64};
54 65
55struct batman_packet { 66struct batman_packet {
56 uint8_t packet_type; 67 uint8_t packet_type;