From patchwork Sat May 28 11:46:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 1105 Return-Path: Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id CE10E1541CF for ; Sat, 28 May 2011 14:12:36 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@narfation.org; dkim-adsp=pass Received: from sven-desktop.home.narfation.org (i59F6C5F.versanet.de [89.246.197.15]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 62ED194049; Sat, 28 May 2011 14:13:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=narfation.org; s=mail; t=1306584780; bh=QzI3HIayKvAifJQsUPHoxDo7MP3wbyGj5Xs2rxs+Qno=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=TGzeL0Q7pFQSO5uguT8Bwqg7j1hhYZTwLj0z5+tB1lh00J2dIcGdriS6idlDtVqMT MhJh5oE6kDtr38WJ6LotpJO6tsVdGFH0inx1IKhXxP6/X5TxDT5/nT65XqShPR8tg4 iLR9Zk8NLAqzUikAlPKZpJpn0TUJX1H10/gluRfU= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 28 May 2011 13:46:27 +0200 Message-Id: <1306583187-5527-1-git-send-email-sven@narfation.org> X-Mailer: git-send-email 1.7.5.1 In-Reply-To: <1306572183-25950-1-git-send-email-sven@narfation.org> References: <1306572183-25950-1-git-send-email-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCHv2-sven] batman-adv: Unify the first 3 bytes in each packet X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 May 2011 12:12:36 -0000 From: Antonio Quartulli The amount of duplicated code in the receive and routing code can be reduced when all headers provide the packet type, version and ttl in the same first bytes. Signed-off-by: Antonio Quartulli --- * reduce to 3 bytes, but still keep alignments * corrected vis_packet packet.h | 28 ++++++++++++++++------------ 1 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packet.h b/packet.h index eda9965..ede441b 100644 --- a/packet.h +++ b/packet.h @@ -32,7 +32,7 @@ #define BAT_UNICAST_FRAG 0x06 /* this file is included by batctl which needs these defines */ -#define COMPAT_VERSION 12 +#define COMPAT_VERSION 14 #define DIRECTLINK 0x40 #define VIS_SERVER 0x20 #define PRIMARIES_FIRST_HOP 0x10 @@ -55,15 +55,15 @@ struct batman_packet { uint8_t packet_type; uint8_t version; /* batman version field */ + uint8_t ttl; uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ - uint8_t tq; uint32_t seqno; uint8_t orig[6]; uint8_t prev_sender[6]; - uint8_t ttl; - uint8_t num_tt; uint8_t gw_flags; /* flags related to gateway class */ - uint8_t align; + uint8_t tq; + uint8_t num_tt; + uint8_t reserved; } __packed; #define BAT_PACKET_LEN sizeof(struct batman_packet) @@ -71,12 +71,13 @@ 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 ttl; + uint8_t msg_type; /* see ICMP message types above */ uint8_t dst[6]; uint8_t orig[6]; uint16_t seqno; uint8_t uid; + uint8_t reserved; } __packed; #define BAT_RR_LEN 16 @@ -86,8 +87,8 @@ struct icmp_packet { struct icmp_packet_rr { uint8_t packet_type; uint8_t version; /* batman version field */ - uint8_t msg_type; /* see ICMP message types above */ uint8_t ttl; + uint8_t msg_type; /* see ICMP message types above */ uint8_t dst[6]; uint8_t orig[6]; uint16_t seqno; @@ -99,16 +100,17 @@ struct icmp_packet_rr { struct unicast_packet { uint8_t packet_type; uint8_t version; /* batman version field */ - uint8_t dest[6]; uint8_t ttl; + uint8_t reserved; + uint8_t dest[6]; } __packed; struct unicast_frag_packet { uint8_t packet_type; uint8_t version; /* batman version field */ - uint8_t dest[6]; uint8_t ttl; uint8_t flags; + uint8_t dest[6]; uint8_t orig[6]; uint16_t seqno; } __packed; @@ -116,18 +118,20 @@ struct unicast_frag_packet { struct bcast_packet { uint8_t packet_type; uint8_t version; /* batman version field */ - uint8_t orig[6]; uint8_t ttl; + uint8_t reserved; uint32_t seqno; + uint8_t orig[6]; } __packed; struct vis_packet { uint8_t packet_type; uint8_t version; /* batman version field */ + uint8_t ttl; /* TTL */ uint8_t vis_type; /* which type of vis-participant sent this? */ - uint8_t entries; /* number of entries behind this struct */ uint32_t seqno; /* sequence number */ - uint8_t ttl; /* TTL */ + uint8_t entries; /* number of entries behind this struct */ + uint8_t reserved; uint8_t vis_orig[6]; /* originator that announces its neighbors */ uint8_t target_orig[6]; /* who should receive this packet */ uint8_t sender_orig[6]; /* who sent or rebroadcasted this packet */