Commit e8958dbf authored by Sven Eckelmann's avatar Sven Eckelmann
Browse files

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: default avatarSven Eckelmann <sven@narfation.org>
parent 3d222bba
Loading
Loading
Loading
Loading
+8 −6
Original line number Original line Diff line number Diff line
@@ -22,12 +22,14 @@
#ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_
#ifndef _NET_BATMAN_ADV_HARD_INTERFACE_H_
#define _NET_BATMAN_ADV_HARD_INTERFACE_H_
#define _NET_BATMAN_ADV_HARD_INTERFACE_H_


#define IF_NOT_IN_USE 0
enum hard_if_state {
#define IF_TO_BE_REMOVED 1
	IF_NOT_IN_USE,
#define IF_INACTIVE 2
	IF_TO_BE_REMOVED,
#define IF_ACTIVE 3
	IF_INACTIVE,
#define IF_TO_BE_ACTIVATED 4
	IF_ACTIVE,
#define IF_I_WANT_YOU 5
	IF_TO_BE_ACTIVATED,
	IF_I_WANT_YOU
};


extern struct notifier_block hard_if_notifier;
extern struct notifier_block hard_if_notifier;


+10 −7
Original line number Original line Diff line number Diff line
@@ -72,9 +72,11 @@
#define RESET_PROTECTION_MS 30000
#define RESET_PROTECTION_MS 30000
#define EXPECTED_SEQNO_RANGE	65536
#define EXPECTED_SEQNO_RANGE	65536


#define MESH_INACTIVE 0
enum mesh_state {
#define MESH_ACTIVE 1
	MESH_INACTIVE,
#define MESH_DEACTIVATING 2
	MESH_ACTIVE,
	MESH_DEACTIVATING
};


#define BCAST_QUEUE_LEN		256
#define BCAST_QUEUE_LEN		256
#define BATMAN_QUEUE_LEN	256
#define BATMAN_QUEUE_LEN	256
@@ -89,10 +91,11 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt


/* all messages related to routing / flooding / broadcasting / etc */
/* all messages related to routing / flooding / broadcasting / etc */
#define DBG_BATMAN 1
enum dbg_level {
/* route or tt entry added / changed / deleted */
	DBG_BATMAN = 1 << 0,
#define DBG_ROUTES 2
	DBG_ROUTES = 1 << 1, /* route added / changed / deleted */
#define DBG_ALL 3
	DBG_ALL    = 3
};




/*
/*
+29 −18
Original line number Original line Diff line number Diff line
@@ -24,33 +24,44 @@


#define ETH_P_BATMAN  0x4305	/* unofficial/not registered Ethertype */
#define ETH_P_BATMAN  0x4305	/* unofficial/not registered Ethertype */


#define BAT_PACKET       0x01
enum bat_packettype {
#define BAT_ICMP         0x02
	BAT_PACKET       = 0x01,
#define BAT_UNICAST      0x03
	BAT_ICMP         = 0x02,
#define BAT_BCAST        0x04
	BAT_UNICAST      = 0x03,
#define BAT_VIS          0x05
	BAT_BCAST        = 0x04,
#define BAT_UNICAST_FRAG 0x06
	BAT_VIS          = 0x05,
	BAT_UNICAST_FRAG = 0x06
};


/* this file is included by batctl which needs these defines */
/* this file is included by batctl which needs these defines */
#define COMPAT_VERSION 12
#define COMPAT_VERSION 12
#define DIRECTLINK 0x40

#define VIS_SERVER 0x20
enum batman_flags {
#define PRIMARIES_FIRST_HOP 0x10
	PRIMARIES_FIRST_HOP = 1 << 4,
	VIS_SERVER	    = 1 << 5,
	DIRECTLINK	    = 1 << 6
};


/* ICMP message types */
/* ICMP message types */
#define ECHO_REPLY 0
enum icmp_packettype {
#define DESTINATION_UNREACHABLE 3
	ECHO_REPLY		= 0,
#define ECHO_REQUEST 8
	DESTINATION_UNREACHABLE = 3,
#define TTL_EXCEEDED 11
	ECHO_REQUEST		= 8,
#define PARAMETER_PROBLEM 12
	TTL_EXCEEDED		= 11,
	PARAMETER_PROBLEM	= 12
};


/* vis defines */
/* vis defines */
#define VIS_TYPE_SERVER_SYNC		0
enum vis_packettype {
#define VIS_TYPE_CLIENT_UPDATE		1
	VIS_TYPE_SERVER_SYNC   = 0,
	VIS_TYPE_CLIENT_UPDATE = 1
};


/* fragmentation defines */
/* fragmentation defines */
#define UNI_FRAG_HEAD 0x01
enum unicast_frag_flags {
#define UNI_FRAG_LARGETAIL 0x02
	UNI_FRAG_HEAD	   = 1 << 0,
	UNI_FRAG_LARGETAIL = 1 << 1
};


struct batman_packet {
struct batman_packet {
	uint8_t  packet_type;
	uint8_t  packet_type;