From patchwork Sat May 28 11:45:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1057 Return-Path: Received: from nm12-vm0.bullet.mail.ukl.yahoo.com (nm12-vm0.bullet.mail.ukl.yahoo.com [217.146.183.246]) by open-mesh.org (Postfix) with SMTP id 2A90F154412 for ; Sat, 28 May 2011 13:46:48 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.212] by nm12.bullet.mail.ukl.yahoo.com with NNFMP; 28 May 2011 11:46:47 -0000 Received: from [217.146.183.162] by tm5.bullet.mail.ukl.yahoo.com with NNFMP; 28 May 2011 11:46:47 -0000 Received: from [127.0.0.1] by omp1003.mail.ukl.yahoo.com with NNFMP; 28 May 2011 11:46:47 -0000 X-Yahoo-Newman-Id: 306118.77390.bm@omp1003.mail.ukl.yahoo.com Received: (qmail 2441 invoked from network); 28 May 2011 11:46:47 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; h=DKIM-Signature:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=dENDur3d+BGbLQ8dgo1/O4ja1rLA8FaE5jIxeWoFKzfPfNRIMgCtIEW9sOwiaGSx6KR09yvB53HXO7DaeC+0mv0DeEQB8bjhVohN688IZb50ZfJ3ghlmlVsQG4CWk2SY0PFzuvIwG4xkdcLqDkH+QXg8HV/+gRJIc3tooz91+qs= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1306583207; bh=oWD/f20RZpff8zghz+t0DGGmTrqXnlYSD9cAPW5xLGY=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=Y9MEil2oAu9OjSpQ69vIWKZmvQVMicZgPNi9e04UauWC/ZtAxPW+qC00hTRDHzfvsSnrP3AsQNPgdawSI/uxoVBdgKZjsZu4KUbSzwwTPTSEZ9w8F+cTPdtE3ELuK6ijSAj6ug46FCNWJISnou0GeRIUZtyG+qspJQzD+Ct+N7Y= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: lvKjhQsVM1m1BDpLMzC1NFvw7EsXYcUdW68BCZsE1hSnU78 o7dYGUJA1_ltm7GO5kkQr7CuDIWEziIKkTEoEl5G3fyj06fp6TrJcEvkqdYh AA76QR0OFS.bXwZBZLCGaWH4yO_U4L7mZR7GN9g4osKxFld3HSyZhw6NRkfL cupKo9UyUBy04zSL0.z8.6qmYgFyTP3Dg2l65rQ3XQIqIJK.61nQ3IgZKx5z QkTOYOqD6oEG0FeGr00aLOQ6LTViJCMTx54xSqS3xEkjrpKcWV01GIJXsvHq S1lMTScqEzk19Puf5N44QDoCau53EWeEIyJqGMTHLmJLoHZxAji6.oZQBi2H g X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@90.35.97.226 with plain) by smtp128.mail.ukl.yahoo.com with SMTP; 28 May 2011 11:46:46 +0000 GMT From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 28 May 2011 13:45:29 +0200 Message-Id: <1306583129-4854-1-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.2.3 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.] [PATCH-marek] 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 11:46:48 -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 --- * Only the first 3 bytes have to be the same. * vis_packet was not changed yet. packet.h | 30 ++++++++++++++++++------------ 1 files changed, 18 insertions(+), 12 deletions(-) diff --git a/packet.h b/packet.h index eda9965..36a3aad 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,19 @@ 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 reserved; + uint8_t dest[6]; uint8_t flags; + uint8_t align; uint8_t orig[6]; uint16_t seqno; } __packed; @@ -116,18 +120,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; + uint8_t orig[6]; uint32_t seqno; } __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 */