aboutsummaryrefslogtreecommitdiffstats
path: root/net
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
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')
-rw-r--r--net/batman-adv/hard-interface.h14
-rw-r--r--net/batman-adv/main.h17
-rw-r--r--net/batman-adv/packet.h47
3 files changed, 47 insertions, 31 deletions
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index 79e25cbb8009..442eacbc9e3a 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -22,12 +22,14 @@
22#ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_ 22#ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_
23#define _NET_BATMAN_ADV_HARD_INTERFACE_H_ 23#define _NET_BATMAN_ADV_HARD_INTERFACE_H_
24 24
25#define IF_NOT_IN_USE 0 25enum hard_if_state {
26#define IF_TO_BE_REMOVED 1 26 IF_NOT_IN_USE,
27#define IF_INACTIVE 2 27 IF_TO_BE_REMOVED,
28#define IF_ACTIVE 3 28 IF_INACTIVE,
29#define IF_TO_BE_ACTIVATED 4 29 IF_ACTIVE,
30#define IF_I_WANT_YOU 5 30 IF_TO_BE_ACTIVATED,
31 IF_I_WANT_YOU
32};
31 33
32extern struct notifier_block hard_if_notifier; 34extern struct notifier_block hard_if_notifier;
33 35
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 610eaf0759ae..27ad734511a9 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -72,9 +72,11 @@
72#define RESET_PROTECTION_MS 30000 72#define RESET_PROTECTION_MS 30000
73#define EXPECTED_SEQNO_RANGE 65536 73#define EXPECTED_SEQNO_RANGE 65536
74 74
75#define MESH_INACTIVE 0 75enum mesh_state {
76#define MESH_ACTIVE 1 76 MESH_INACTIVE,
77#define MESH_DEACTIVATING 2 77 MESH_ACTIVE,
78 MESH_DEACTIVATING
79};
78 80
79#define BCAST_QUEUE_LEN 256 81#define BCAST_QUEUE_LEN 256
80#define BATMAN_QUEUE_LEN 256 82#define BATMAN_QUEUE_LEN 256
@@ -89,10 +91,11 @@
89#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 91#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
90 92
91/* all messages related to routing / flooding / broadcasting / etc */ 93/* all messages related to routing / flooding / broadcasting / etc */
92#define DBG_BATMAN 1 94enum dbg_level {
93/* route or tt entry added / changed / deleted */ 95 DBG_BATMAN = 1 << 0,
94#define DBG_ROUTES 2 96 DBG_ROUTES = 1 << 1, /* route added / changed / deleted */
95#define DBG_ALL 3 97 DBG_ALL = 3
98};
96 99
97 100
98/* 101/*
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;