Skip to contentSkip to conversation

packet.h coding style cleanup

B.A.T.M.A.N. In review Andrew Lunn 2 participants 4 messages Jul 17, 2009

lore
Share & tools
lore
#0 lore raw

Make packet.h clean with respect to the 2.6.29 checkpatch script. Also adds one macro, BAT_PACKET_LEN, which is used in other patches to follow.

packet.h +18 -23
Index: batman-adv-kernelland/packet.h
===================================================================
@@ -17,8 +17,6 @@
  *
  */
 
-
-
 #define ETH_P_BATMAN  0x4305	/* unofficial/not registered Ethertype */
 
 #define BAT_PACKET    0x01
@@ -32,7 +30,6 @@
 #define DIRECTLINK 0x40
 #define VIS_SERVER 0x20
 
-
 /* ICMP message types */
 #define ECHO_REPLY 0
 #define DESTINATION_UNREACHABLE 3
@@ -40,13 +37,11 @@
 #define TTL_EXCEEDED 11
 #define PARAMETER_PROBLEM 12
 
-
 /* vis defines */
 #define VIS_TYPE_SERVER_SYNC		0
 #define VIS_TYPE_CLIENT_UPDATE		1
 
-struct batman_packet
-{
+struct batman_packet {
 	uint8_t  packet_type;
 	uint8_t  version;  /* batman version field */
 	uint8_t  flags;    /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
@@ -56,13 +51,15 @@
 	uint8_t  old_orig[6];
 	uint8_t  ttl;
 	uint8_t  num_hna;
+    uint16_t orig_interval;
 } __attribute__((packed));
 
-struct icmp_packet
-{
+#define BAT_PACKET_LEN sizeof(struct batman_packet)
+
+struct icmp_packet {
 	uint8_t  packet_type;
 	uint8_t  version;  /* batman version field */
-	uint8_t  msg_type;   /* see ICMP message types above */
+	uint8_t  msg_type; /* see ICMP message types above */
 	uint8_t  ttl;
 	uint8_t  dst[6];
 	uint8_t  orig[6];
@@ -70,31 +67,29 @@
 	uint8_t  uid;
 } __attribute__((packed));
 
-struct unicast_packet
-{
+struct unicast_packet {
 	uint8_t  packet_type;
 	uint8_t  version;  /* batman version field */
 	uint8_t  dest[6];
 	uint8_t  ttl;
 } __attribute__((packed));
 
-struct bcast_packet
-{
+struct bcast_packet {
 	uint8_t  packet_type;
 	uint8_t  version;  /* batman version field */
 	uint8_t  orig[6];
 	uint16_t seqno;
 } __attribute__((packed));
 
-struct vis_packet
-{
+struct vis_packet {
 	uint8_t  packet_type;
-	uint8_t  version;  			/* batman version field */
-	uint8_t  vis_type;			/* which type of vis-participant sent this? */
-	uint8_t  seqno;				/* sequence number */
-	uint8_t  entries;			/* number of entries behind this struct */
-	uint8_t  ttl;				/* TTL */
-	uint8_t  vis_orig[6];		/* originator that informs about its neighbours */
-	uint8_t  target_orig[6];	/* who should receive this packet */
-	uint8_t  sender_orig[6];	/* who sent or rebroadcasted this packet */
+	uint8_t  version;        /* batman version field */
+	uint8_t  vis_type;	 /* which type of vis-participant sent this? */
+	uint8_t  seqno;		 /* sequence number */
+	uint8_t  entries;	 /* number of entries behind this struct */
+	uint8_t  ttl;		 /* TTL */
+	uint8_t  vis_orig[6];	 /* originator that informs about its
+				  * neighbours */
+	uint8_t  target_orig[6]; /* who should receive this packet */
+	uint8_t  sender_orig[6]; /* who sent or rebroadcasted this packet */
 } __attribute__((packed));
#1 lore raw
Quoted 3 lines · Andrew Lunn

Make packet.h clean with respect to the 2.6.29 checkpatch script. Also adds one macro, BAT_PACKET_LEN, which is used in other patches to follow.

Arg, please ignore this patch. There is something extra in there which should not be.

Andrew

#2 lore raw

PATCH v2 1/1 packet.h coding style cleanup

In reply to Andrew Lunn

Make packet.h clean with respect to the 2.6.29 checkpatch script. Also adds one macro, BAT_PACKET_LEN, which is used in other patches to follow.

packet.h +17 -23
Index: packet.h
===================================================================
@@ -17,8 +17,6 @@
  *
  */
 
-
-
 #define ETH_P_BATMAN  0x4305	/* unofficial/not registered Ethertype */
 
 #define BAT_PACKET    0x01
@@ -32,7 +30,6 @@
 #define DIRECTLINK 0x40
 #define VIS_SERVER 0x20
 
-
 /* ICMP message types */
 #define ECHO_REPLY 0
 #define DESTINATION_UNREACHABLE 3
@@ -40,13 +37,11 @@
 #define TTL_EXCEEDED 11
 #define PARAMETER_PROBLEM 12
 
-
 /* vis defines */
 #define VIS_TYPE_SERVER_SYNC		0
 #define VIS_TYPE_CLIENT_UPDATE		1
 
-struct batman_packet
-{
+struct batman_packet {
 	uint8_t  packet_type;
 	uint8_t  version;  /* batman version field */
 	uint8_t  flags;    /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */
@@ -58,11 +53,12 @@
 	uint8_t  num_hna;
 } __attribute__((packed));
 
-struct icmp_packet
-{
+#define BAT_PACKET_LEN sizeof(struct batman_packet)
+
+struct icmp_packet {
 	uint8_t  packet_type;
 	uint8_t  version;  /* batman version field */
-	uint8_t  msg_type;   /* see ICMP message types above */
+	uint8_t  msg_type; /* see ICMP message types above */
 	uint8_t  ttl;
 	uint8_t  dst[6];
 	uint8_t  orig[6];
@@ -70,31 +66,29 @@
 	uint8_t  uid;
 } __attribute__((packed));
 
-struct unicast_packet
-{
+struct unicast_packet {
 	uint8_t  packet_type;
 	uint8_t  version;  /* batman version field */
 	uint8_t  dest[6];
 	uint8_t  ttl;
 } __attribute__((packed));
 
-struct bcast_packet
-{
+struct bcast_packet {
 	uint8_t  packet_type;
 	uint8_t  version;  /* batman version field */
 	uint8_t  orig[6];
 	uint16_t seqno;
 } __attribute__((packed));
 
-struct vis_packet
-{
+struct vis_packet {
 	uint8_t  packet_type;
-	uint8_t  version;  			/* batman version field */
-	uint8_t  vis_type;			/* which type of vis-participant sent this? */
-	uint8_t  seqno;				/* sequence number */
-	uint8_t  entries;			/* number of entries behind this struct */
-	uint8_t  ttl;				/* TTL */
-	uint8_t  vis_orig[6];		/* originator that informs about its neighbours */
-	uint8_t  target_orig[6];	/* who should receive this packet */
-	uint8_t  sender_orig[6];	/* who sent or rebroadcasted this packet */
+	uint8_t  version;        /* batman version field */
+	uint8_t  vis_type;	 /* which type of vis-participant sent this? */
+	uint8_t  seqno;		 /* sequence number */
+	uint8_t  entries;	 /* number of entries behind this struct */
+	uint8_t  ttl;		 /* TTL */
+	uint8_t  vis_orig[6];	 /* originator that informs about its
+				  * neighbours */
+	uint8_t  target_orig[6]; /* who should receive this packet */
+	uint8_t  sender_orig[6]; /* who sent or rebroadcasted this packet */
 } __attribute__((packed));
#3 lore raw
Quoted 3 lines · On Saturday 18 July 2009 02:46:14 Andrew Lunn wrote:

Make packet.h clean with respect to the 2.6.29 checkpatch script. Also adds one macro, BAT_PACKET_LEN, which is used in other patches to follow.

I comitted all your patches except the vis struct changes as there were some open issues.

Thanks for your effort,
Marek