Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- packet.h | 12 ++++++------ ping.c | 16 ++++++++-------- tcpdump.c | 8 ++++---- traceroute.c | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/packet.h b/packet.h index c90219c..e562414 100644 --- a/packet.h +++ b/packet.h @@ -20,7 +20,7 @@ #ifndef _NET_BATMAN_ADV_PACKET_H_ #define _NET_BATMAN_ADV_PACKET_H_
-#define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */ +#define BATADV_ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
enum bat_packettype { BAT_IV_OGM = 0x01, @@ -34,7 +34,7 @@ enum bat_packettype { };
/* this file is included by batctl which needs these defines */ -#define COMPAT_VERSION 14 +#define BATADV_COMPAT_VERSION 14
enum batman_iv_flags { NOT_BEST_NEXT_HOP = 1 << 3, @@ -65,7 +65,7 @@ enum unicast_frag_flags { };
/* TT_QUERY subtypes */ -#define TT_QUERY_TYPE_MASK 0x3 +#define BATADV_TT_QUERY_TYPE_MASK 0x3
enum tt_query_packettype { TT_REQUEST = 0, @@ -126,7 +126,7 @@ struct batman_ogm_packet { __be16 tt_crc; } __packed;
-#define BATMAN_OGM_HLEN sizeof(struct batman_ogm_packet) +#define BATADV_OGM_HLEN sizeof(struct batman_ogm_packet)
struct icmp_packet { struct batman_header header; @@ -138,7 +138,7 @@ struct icmp_packet { uint8_t reserved; } __packed;
-#define BAT_RR_LEN 16 +#define BATADV_RR_LEN 16
/* icmp_packet_rr must start with all fields from imcp_packet * as this is assumed by code that handles ICMP packets @@ -151,7 +151,7 @@ struct icmp_packet_rr { __be16 seqno; uint8_t uid; uint8_t rr_cur; - uint8_t rr[BAT_RR_LEN][ETH_ALEN]; + uint8_t rr[BATADV_RR_LEN][ETH_ALEN]; } __packed;
struct unicast_packet { diff --git a/ping.c b/ping.c index 791cfb7..213f1e3 100644 --- a/ping.c +++ b/ping.c @@ -79,7 +79,7 @@ int ping(char *mesh_iface, int argc, char **argv) char *dst_string, *mac_string, *rr_string; double time_delta; float min = 0.0, max = 0.0, avg = 0.0, mdev = 0.0; - uint8_t last_rr_cur = 0, last_rr[BAT_RR_LEN][ETH_ALEN]; + uint8_t last_rr_cur = 0, last_rr[BATADV_RR_LEN][ETH_ALEN]; size_t packet_len; char *debugfs_mnt; char icmp_socket[MAX_PATH+1]; @@ -164,7 +164,7 @@ int ping(char *mesh_iface, int argc, char **argv)
memcpy(&icmp_packet_out.dst, dst_mac, ETH_ALEN); icmp_packet_out.header.packet_type = BAT_ICMP; - icmp_packet_out.header.version = COMPAT_VERSION; + icmp_packet_out.header.version = BATADV_COMPAT_VERSION; icmp_packet_out.msg_type = ECHO_REQUEST; icmp_packet_out.header.ttl = 50; icmp_packet_out.seqno = 0; @@ -172,8 +172,8 @@ int ping(char *mesh_iface, int argc, char **argv) if (rr) { packet_len = sizeof(struct icmp_packet_rr); icmp_packet_out.rr_cur = 1; - memset(&icmp_packet_out.rr, 0, BAT_RR_LEN * ETH_ALEN); - memset(last_rr, 0, BAT_RR_LEN * ETH_ALEN); + memset(&icmp_packet_out.rr, 0, BATADV_RR_LEN * ETH_ALEN); + memset(last_rr, 0, BATADV_RR_LEN * ETH_ALEN); }
printf("PING %s (%s) %zu(%zu) bytes of data\n", dst_string, mac_string, @@ -243,14 +243,14 @@ read_packet:
if (read_len == sizeof(struct icmp_packet_rr)) { if (last_rr_cur == icmp_packet_in.rr_cur - && !memcmp(last_rr, icmp_packet_in.rr, BAT_RR_LEN * ETH_ALEN)) { + && !memcmp(last_rr, icmp_packet_in.rr, BATADV_RR_LEN * ETH_ALEN)) {
printf("\t(same route)");
} else { printf("\nRR: ");
- for (i = 0; i < BAT_RR_LEN + for (i = 0; i < BATADV_RR_LEN && i < icmp_packet_in.rr_cur; i++) {
rr_mac = (struct ether_addr *)&icmp_packet_in.rr[i]; @@ -266,7 +266,7 @@ read_packet: }
last_rr_cur = icmp_packet_in.rr_cur; - memcpy(last_rr, icmp_packet_in.rr, BAT_RR_LEN * ETH_ALEN); + memcpy(last_rr, icmp_packet_in.rr, BATADV_RR_LEN * ETH_ALEN); } }
@@ -288,7 +288,7 @@ read_packet: break; case PARAMETER_PROBLEM: printf("Error - the batman adv kernel module version (%d) differs from ours (%d)\n", - icmp_packet_in.header.version, COMPAT_VERSION); + icmp_packet_in.header.version, BATADV_COMPAT_VERSION); printf("Please make sure to use compatible versions!\n"); goto out; default: diff --git a/tcpdump.c b/tcpdump.c index 6672cf1..1ead780 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -61,7 +61,7 @@ static void tcpdump_usage(void) { printf("Usage: batctl tcpdump [options] interface [interface]\n"); printf("options:\n"); - printf(" \t -c compat filter - only display packets matching own compat version (%i)\n", COMPAT_VERSION); + printf(" \t -c compat filter - only display packets matching own compat version (%i)\n", BATADV_COMPAT_VERSION); printf(" \t -h print this help\n"); printf(" \t -n don't convert addresses to bat-host names\n"); printf(" \t -p dump specific packet type\n"); @@ -264,7 +264,7 @@ static void dump_batman_tt(unsigned char *packet_buff, ssize_t buff_len, int rea if (!time_printed) print_time();
- switch (tt_query_packet->flags & TT_QUERY_TYPE_MASK) { + switch (tt_query_packet->flags & BATADV_TT_QUERY_TYPE_MASK) { case TT_REQUEST: tt_desc = "request"; tt_data = "crc"; @@ -489,11 +489,11 @@ static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read if ((dump_level & DUMP_TYPE_NONBAT) || (time_printed)) dump_vlan(packet_buff, buff_len, read_opt, time_printed); break; - case ETH_P_BATMAN: + case BATADV_ETH_P_BATMAN: batman_ogm_packet = (struct batman_ogm_packet *)(packet_buff + ETH_HLEN);
if ((read_opt & COMPAT_FILTER) && - (batman_ogm_packet->header.version != COMPAT_VERSION)) + (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION)) return;
switch (batman_ogm_packet->header.packet_type) { diff --git a/traceroute.c b/traceroute.c index fdc9e4a..da0ba60 100644 --- a/traceroute.c +++ b/traceroute.c @@ -121,7 +121,7 @@ int traceroute(char *mesh_iface, int argc, char **argv) }
memcpy(&icmp_packet_out.dst, dst_mac, ETH_ALEN); - icmp_packet_out.header.version = COMPAT_VERSION; + icmp_packet_out.header.version = BATADV_COMPAT_VERSION; icmp_packet_out.header.packet_type = BAT_ICMP; icmp_packet_out.msg_type = ECHO_REQUEST; icmp_packet_out.seqno = 0; @@ -193,7 +193,7 @@ read_packet: goto out; case PARAMETER_PROBLEM: printf("Error - the batman adv kernel module version (%d) differs from ours (%d)\n", - icmp_packet_in.header.version, COMPAT_VERSION); + icmp_packet_in.header.version, BATADV_COMPAT_VERSION); printf("Please make sure to use compatible versions!\n"); goto out; default:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- packet.h | 86 +++++++++++++++++++++++++++++----------------------------- ping.c | 12 ++++---- tcpdump.c | 42 ++++++++++++++-------------- traceroute.c | 12 ++++---- 4 files changed, 76 insertions(+), 76 deletions(-)
diff --git a/packet.h b/packet.h index e562414..2ca6819 100644 --- a/packet.h +++ b/packet.h @@ -22,80 +22,80 @@
#define BATADV_ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
-enum bat_packettype { - BAT_IV_OGM = 0x01, - BAT_ICMP = 0x02, - BAT_UNICAST = 0x03, - BAT_BCAST = 0x04, - BAT_VIS = 0x05, - BAT_UNICAST_FRAG = 0x06, - BAT_TT_QUERY = 0x07, - BAT_ROAM_ADV = 0x08 +enum batadv_packettype { + BATADV_IV_OGM = 0x01, + BATADV_ICMP = 0x02, + BATADV_UNICAST = 0x03, + BATADV_BCAST = 0x04, + BATADV_VIS = 0x05, + BATADV_UNICAST_FRAG = 0x06, + BATADV_TT_QUERY = 0x07, + BATADV_ROAM_ADV = 0x08, };
/* this file is included by batctl which needs these defines */ #define BATADV_COMPAT_VERSION 14
-enum batman_iv_flags { - NOT_BEST_NEXT_HOP = 1 << 3, - PRIMARIES_FIRST_HOP = 1 << 4, - VIS_SERVER = 1 << 5, - DIRECTLINK = 1 << 6 +enum batadv_iv_flags { + BATADV_NOT_BEST_NEXT_HOP = 1 << 3, + BATADV_PRIMARIES_FIRST_HOP = 1 << 4, + BATADV_VIS_SERVER = 1 << 5, + BATADV_DIRECTLINK = 1 << 6, };
/* ICMP message types */ -enum icmp_packettype { - ECHO_REPLY = 0, - DESTINATION_UNREACHABLE = 3, - ECHO_REQUEST = 8, - TTL_EXCEEDED = 11, - PARAMETER_PROBLEM = 12 +enum batadv_icmp_packettype { + BATADV_ECHO_REPLY = 0, + BATADV_DESTINATION_UNREACHABLE = 3, + BATADV_ECHO_REQUEST = 8, + BATADV_TTL_EXCEEDED = 11, + BATADV_PARAMETER_PROBLEM = 12, };
/* vis defines */ -enum vis_packettype { - VIS_TYPE_SERVER_SYNC = 0, - VIS_TYPE_CLIENT_UPDATE = 1 +enum batadv_vis_packettype { + BATADV_VIS_TYPE_SERVER_SYNC = 0, + BATADV_VIS_TYPE_CLIENT_UPDATE = 1, };
/* fragmentation defines */ -enum unicast_frag_flags { - UNI_FRAG_HEAD = 1 << 0, - UNI_FRAG_LARGETAIL = 1 << 1 +enum batadv_unicast_frag_flags { + BATADV_UNI_FRAG_HEAD = 1 << 0, + BATADV_UNI_FRAG_LARGETAIL = 1 << 1, };
/* TT_QUERY subtypes */ #define BATADV_TT_QUERY_TYPE_MASK 0x3
-enum tt_query_packettype { - TT_REQUEST = 0, - TT_RESPONSE = 1 +enum batadv_tt_query_packettype { + BATADV_TT_REQUEST = 0, + BATADV_TT_RESPONSE = 1, };
/* TT_QUERY flags */ -enum tt_query_flags { - TT_FULL_TABLE = 1 << 2 +enum batadv_tt_query_flags { + BATADV_TT_FULL_TABLE = 1 << 2, };
/* TT_CLIENT flags. * Flags from 1 to 1 << 7 are sent on the wire, while flags from 1 << 8 to * 1 << 15 are used for local computation only */ -enum tt_client_flags { - TT_CLIENT_DEL = 1 << 0, - TT_CLIENT_ROAM = 1 << 1, - TT_CLIENT_WIFI = 1 << 2, - TT_CLIENT_NOPURGE = 1 << 8, - TT_CLIENT_NEW = 1 << 9, - TT_CLIENT_PENDING = 1 << 10 +enum batadv_tt_client_flags { + BATADV_TT_CLIENT_DEL = 1 << 0, + BATADV_TT_CLIENT_ROAM = 1 << 1, + BATADV_TT_CLIENT_WIFI = 1 << 2, + BATADV_TT_CLIENT_NOPURGE = 1 << 8, + BATADV_TT_CLIENT_NEW = 1 << 9, + BATADV_TT_CLIENT_PENDING = 1 << 10, };
/* claim frame types for the bridge loop avoidance */ -enum bla_claimframe { - CLAIM_TYPE_ADD = 0x00, - CLAIM_TYPE_DEL = 0x01, - CLAIM_TYPE_ANNOUNCE = 0x02, - CLAIM_TYPE_REQUEST = 0x03 +enum batadv_bla_claimframe { + BATADV_CLAIM_TYPE_ADD = 0x00, + BATADV_CLAIM_TYPE_DEL = 0x01, + BATADV_CLAIM_TYPE_ANNOUNCE = 0x02, + BATADV_CLAIM_TYPE_REQUEST = 0x03, };
/* the destination hardware field in the ARP frame is used to diff --git a/ping.c b/ping.c index 213f1e3..a4d579f 100644 --- a/ping.c +++ b/ping.c @@ -163,9 +163,9 @@ int ping(char *mesh_iface, int argc, char **argv) packet_len = sizeof(struct icmp_packet);
memcpy(&icmp_packet_out.dst, dst_mac, ETH_ALEN); - icmp_packet_out.header.packet_type = BAT_ICMP; + icmp_packet_out.header.packet_type = BATADV_ICMP; icmp_packet_out.header.version = BATADV_COMPAT_VERSION; - icmp_packet_out.msg_type = ECHO_REQUEST; + icmp_packet_out.msg_type = BATADV_ECHO_REQUEST; icmp_packet_out.header.ttl = 50; icmp_packet_out.seqno = 0;
@@ -235,7 +235,7 @@ read_packet: goto read_packet;
switch (icmp_packet_in.msg_type) { - case ECHO_REPLY: + case BATADV_ECHO_REPLY: time_delta = end_timer(); printf("%zd bytes from %s icmp_seq=%hu ttl=%d time=%.2f ms", read_len, dst_string, ntohs(icmp_packet_in.seqno), @@ -280,13 +280,13 @@ read_packet: mdev += time_delta * time_delta; packets_in++; break; - case DESTINATION_UNREACHABLE: + case BATADV_DESTINATION_UNREACHABLE: printf("From %s: Destination Host Unreachable (icmp_seq %hu)\n", dst_string, ntohs(icmp_packet_in.seqno)); break; - case TTL_EXCEEDED: + case BATADV_TTL_EXCEEDED: printf("From %s: Time to live exceeded (icmp_seq %hu)\n", dst_string, ntohs(icmp_packet_in.seqno)); break; - case PARAMETER_PROBLEM: + case BATADV_PARAMETER_PROBLEM: printf("Error - the batman adv kernel module version (%d) differs from ours (%d)\n", icmp_packet_in.header.version, BATADV_COMPAT_VERSION); printf("Please make sure to use compatible versions!\n"); diff --git a/tcpdump.c b/tcpdump.c index 1ead780..ba012a7 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -265,12 +265,12 @@ static void dump_batman_tt(unsigned char *packet_buff, ssize_t buff_len, int rea print_time();
switch (tt_query_packet->flags & BATADV_TT_QUERY_TYPE_MASK) { - case TT_REQUEST: + case BATADV_TT_REQUEST: tt_desc = "request"; tt_data = "crc"; tt_type = 'Q'; break; - case TT_RESPONSE: + case BATADV_TT_RESPONSE: tt_desc = "response"; tt_data = "entries"; tt_type = 'P'; @@ -289,7 +289,7 @@ static void dump_batman_tt(unsigned char *packet_buff, ssize_t buff_len, int rea get_name_by_macaddr((struct ether_addr *)tt_query_packet->dst, read_opt), tt_desc, tt_query_packet->ttvn, tt_data, ntohs(tt_query_packet->tt_data), tt_query_packet->header.ttl, tt_query_packet->header.version, - tt_type, (tt_query_packet->flags & TT_FULL_TABLE ? 'F' : '.'), + tt_type, (tt_query_packet->flags & BATADV_TT_FULL_TABLE ? 'F' : '.'), (size_t)buff_len - sizeof(struct ether_header)); }
@@ -336,10 +336,10 @@ static void dump_batman_iv_ogm(unsigned char *packet_buff, ssize_t buff_len, int get_name_by_macaddr((struct ether_addr *)ether_header->ether_shost, read_opt), ntohl(batman_ogm_packet->seqno), batman_ogm_packet->tq, batman_ogm_packet->ttvn, ntohs(batman_ogm_packet->tt_crc), batman_ogm_packet->header.ttl, batman_ogm_packet->header.version, - (batman_ogm_packet->flags & NOT_BEST_NEXT_HOP ? 'N' : '.'), - (batman_ogm_packet->flags & DIRECTLINK ? 'D' : '.'), - (batman_ogm_packet->flags & VIS_SERVER ? 'V' : '.'), - (batman_ogm_packet->flags & PRIMARIES_FIRST_HOP ? 'F' : '.'), + (batman_ogm_packet->flags & BATADV_NOT_BEST_NEXT_HOP ? 'N' : '.'), + (batman_ogm_packet->flags & BATADV_DIRECTLINK ? 'D' : '.'), + (batman_ogm_packet->flags & BATADV_VIS_SERVER ? 'V' : '.'), + (batman_ogm_packet->flags & BATADV_PRIMARIES_FIRST_HOP ? 'F' : '.'), (batman_ogm_packet->gw_flags ? 'G' : '.'), (size_t)buff_len - sizeof(struct ether_header)); } @@ -361,19 +361,19 @@ static void dump_batman_icmp(unsigned char *packet_buff, ssize_t buff_len, int r name = get_name_by_macaddr((struct ether_addr *)icmp_packet->dst, read_opt);
switch (icmp_packet->msg_type) { - case ECHO_REPLY: + case BATADV_ECHO_REPLY: printf("%s: ICMP echo reply, id %hhu, seq %hu, ttl %2d, v %d, length %zu\n", name, icmp_packet->uid, ntohs(icmp_packet->seqno), icmp_packet->header.ttl, icmp_packet->header.version, (size_t)buff_len - sizeof(struct ether_header)); break; - case ECHO_REQUEST: + case BATADV_ECHO_REQUEST: printf("%s: ICMP echo request, id %hhu, seq %hu, ttl %2d, v %d, length %zu\n", name, icmp_packet->uid, ntohs(icmp_packet->seqno), icmp_packet->header.ttl, icmp_packet->header.version, (size_t)buff_len - sizeof(struct ether_header)); break; - case TTL_EXCEEDED: + case BATADV_TTL_EXCEEDED: printf("%s: ICMP time exceeded in-transit, id %hhu, seq %hu, ttl %2d, v %d, length %zu\n", name, icmp_packet->uid, ntohs(icmp_packet->seqno), icmp_packet->header.ttl, icmp_packet->header.version, @@ -458,10 +458,10 @@ static void dump_batman_frag(unsigned char *packet_buff, ssize_t buff_len, int r printf("%s: FRAG, seq %hu, ttvn %d, ttl %hhu, flags [%c%c], ", get_name_by_macaddr((struct ether_addr *)unicast_frag_packet->dest, read_opt), ntohs(unicast_frag_packet->seqno), unicast_frag_packet->ttvn, unicast_frag_packet->header.ttl, - (unicast_frag_packet->flags & UNI_FRAG_HEAD ? 'H' : '.'), - (unicast_frag_packet->flags & UNI_FRAG_LARGETAIL ? 'L' : '.')); + (unicast_frag_packet->flags & BATADV_UNI_FRAG_HEAD ? 'H' : '.'), + (unicast_frag_packet->flags & BATADV_UNI_FRAG_LARGETAIL ? 'L' : '.'));
- if (unicast_frag_packet->flags & UNI_FRAG_HEAD) + if (unicast_frag_packet->flags & BATADV_UNI_FRAG_HEAD) parse_eth_hdr(packet_buff + ETH_HLEN + sizeof(struct unicast_frag_packet), buff_len - ETH_HLEN - sizeof(struct unicast_frag_packet), read_opt, time_printed); @@ -497,35 +497,35 @@ static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read return;
switch (batman_ogm_packet->header.packet_type) { - case BAT_IV_OGM: + case BATADV_IV_OGM: if (dump_level & DUMP_TYPE_BATOGM) dump_batman_iv_ogm(packet_buff, buff_len, read_opt, time_printed); break; - case BAT_ICMP: + case BATADV_ICMP: if (dump_level & DUMP_TYPE_BATICMP) dump_batman_icmp(packet_buff, buff_len, read_opt, time_printed); break; - case BAT_UNICAST: + case BATADV_UNICAST: if (dump_level & DUMP_TYPE_BATUCAST) dump_batman_ucast(packet_buff, buff_len, read_opt, time_printed); break; - case BAT_BCAST: + case BATADV_BCAST: if (dump_level & DUMP_TYPE_BATBCAST) dump_batman_bcast(packet_buff, buff_len, read_opt, time_printed); break; - case BAT_VIS: + case BATADV_VIS: if (dump_level & DUMP_TYPE_BATVIS) printf("Warning - batman vis packet received: function not implemented yet\n"); break; - case BAT_UNICAST_FRAG: + case BATADV_UNICAST_FRAG: if (dump_level & DUMP_TYPE_BATFRAG) dump_batman_frag(packet_buff, buff_len, read_opt, time_printed); break; - case BAT_TT_QUERY: + case BATADV_TT_QUERY: if (dump_level & DUMP_TYPE_BATTT) dump_batman_tt(packet_buff, buff_len, read_opt, time_printed); break; - case BAT_ROAM_ADV: + case BATADV_ROAM_ADV: if (dump_level & DUMP_TYPE_BATTT) dump_batman_roam(packet_buff, buff_len, read_opt, time_printed); break; diff --git a/traceroute.c b/traceroute.c index da0ba60..9ef70e8 100644 --- a/traceroute.c +++ b/traceroute.c @@ -122,8 +122,8 @@ int traceroute(char *mesh_iface, int argc, char **argv)
memcpy(&icmp_packet_out.dst, dst_mac, ETH_ALEN); icmp_packet_out.header.version = BATADV_COMPAT_VERSION; - icmp_packet_out.header.packet_type = BAT_ICMP; - icmp_packet_out.msg_type = ECHO_REQUEST; + icmp_packet_out.header.packet_type = BATADV_ICMP; + icmp_packet_out.msg_type = BATADV_ECHO_REQUEST; icmp_packet_out.seqno = 0;
printf("traceroute to %s (%s), %d hops max, %zu byte packets\n", @@ -174,10 +174,10 @@ read_packet: goto read_packet;
switch (icmp_packet_in.msg_type) { - case ECHO_REPLY: + case BATADV_ECHO_REPLY: dst_reached = 1; /* fall through */ - case TTL_EXCEEDED: + case BATADV_TTL_EXCEEDED: time_delta[i] = end_timer();
if (!return_mac) { @@ -188,10 +188,10 @@ read_packet: }
break; - case DESTINATION_UNREACHABLE: + case BATADV_DESTINATION_UNREACHABLE: printf("%s: Destination Host Unreachable\n", dst_string); goto out; - case PARAMETER_PROBLEM: + case BATADV_PARAMETER_PROBLEM: printf("Error - the batman adv kernel module version (%d) differs from ours (%d)\n", icmp_packet_in.header.version, BATADV_COMPAT_VERSION); printf("Please make sure to use compatible versions!\n");
On Wednesday, June 06, 2012 19:17:26 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
packet.h | 86 +++++++++++++++++++++++++++++----------------------------- ping.c | 12 ++++---- tcpdump.c | 42 ++++++++++++++-------------- traceroute.c | 12 ++++---- 4 files changed, 76 insertions(+), 76 deletions(-)
Applied in revision 58865d6.
Thanks, Marek
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org --- packet.h | 44 +++++++++++++++++++-------------------- ping.c | 8 +++---- tcpdump.c | 66 +++++++++++++++++++++++++++++----------------------------- traceroute.c | 2 +- 4 files changed, 60 insertions(+), 60 deletions(-)
diff --git a/packet.h b/packet.h index 2ca6819..c0ed5b4 100644 --- a/packet.h +++ b/packet.h @@ -101,20 +101,20 @@ enum batadv_bla_claimframe { /* the destination hardware field in the ARP frame is used to * transport the claim type and the group id */ -struct bla_claim_dst { +struct batadv_bla_claim_dst { uint8_t magic[3]; /* FF:43:05 */ uint8_t type; /* bla_claimframe */ __be16 group; /* group id */ } __packed;
-struct batman_header { +struct batadv_header { uint8_t packet_type; uint8_t version; /* batman version field */ uint8_t ttl; } __packed;
-struct batman_ogm_packet { - struct batman_header header; +struct batadv_ogm_packet { + struct batadv_header header; uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ __be32 seqno; uint8_t orig[ETH_ALEN]; @@ -126,10 +126,10 @@ struct batman_ogm_packet { __be16 tt_crc; } __packed;
-#define BATADV_OGM_HLEN sizeof(struct batman_ogm_packet) +#define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
-struct icmp_packet { - struct batman_header header; +struct batadv_icmp_packet { + struct batadv_header header; uint8_t msg_type; /* see ICMP message types above */ uint8_t dst[ETH_ALEN]; uint8_t orig[ETH_ALEN]; @@ -143,8 +143,8 @@ struct icmp_packet { /* icmp_packet_rr must start with all fields from imcp_packet * as this is assumed by code that handles ICMP packets */ -struct icmp_packet_rr { - struct batman_header header; +struct batadv_icmp_packet_rr { + struct batadv_header header; uint8_t msg_type; /* see ICMP message types above */ uint8_t dst[ETH_ALEN]; uint8_t orig[ETH_ALEN]; @@ -154,14 +154,14 @@ struct icmp_packet_rr { uint8_t rr[BATADV_RR_LEN][ETH_ALEN]; } __packed;
-struct unicast_packet { - struct batman_header header; +struct batadv_unicast_packet { + struct batadv_header header; uint8_t ttvn; /* destination translation table version number */ uint8_t dest[ETH_ALEN]; } __packed;
-struct unicast_frag_packet { - struct batman_header header; +struct batadv_unicast_frag_packet { + struct batadv_header header; uint8_t ttvn; /* destination translation table version number */ uint8_t dest[ETH_ALEN]; uint8_t flags; @@ -170,15 +170,15 @@ struct unicast_frag_packet { __be16 seqno; } __packed;
-struct bcast_packet { - struct batman_header header; +struct batadv_bcast_packet { + struct batadv_header header; uint8_t reserved; __be32 seqno; uint8_t orig[ETH_ALEN]; } __packed;
-struct vis_packet { - struct batman_header header; +struct batadv_vis_packet { + struct batadv_header header; uint8_t vis_type; /* which type of vis-participant sent this? */ __be32 seqno; /* sequence number */ uint8_t entries; /* number of entries behind this struct */ @@ -188,8 +188,8 @@ struct vis_packet { uint8_t sender_orig[ETH_ALEN]; /* who sent or forwarded this packet */ } __packed;
-struct tt_query_packet { - struct batman_header header; +struct batadv_tt_query_packet { + struct batadv_header header; /* the flag field is a combination of: * - TT_REQUEST or TT_RESPONSE * - TT_FULL_TABLE @@ -212,15 +212,15 @@ struct tt_query_packet { __be16 tt_data; } __packed;
-struct roam_adv_packet { - struct batman_header header; +struct batadv_roam_adv_packet { + struct batadv_header header; uint8_t reserved; uint8_t dst[ETH_ALEN]; uint8_t src[ETH_ALEN]; uint8_t client[ETH_ALEN]; } __packed;
-struct tt_change { +struct batadv_tt_change { uint8_t flags; uint8_t addr[ETH_ALEN]; } __packed; diff --git a/ping.c b/ping.c index a4d579f..85b4137 100644 --- a/ping.c +++ b/ping.c @@ -67,7 +67,7 @@ void sig_handler(int sig)
int ping(char *mesh_iface, int argc, char **argv) { - struct icmp_packet_rr icmp_packet_out, icmp_packet_in; + struct batadv_icmp_packet_rr icmp_packet_out, icmp_packet_in; struct timeval tv; struct ether_addr *dst_mac = NULL, *rr_mac = NULL; struct bat_host *bat_host, *rr_host; @@ -160,7 +160,7 @@ int ping(char *mesh_iface, int argc, char **argv) goto out; }
- packet_len = sizeof(struct icmp_packet); + packet_len = sizeof(struct batadv_icmp_packet);
memcpy(&icmp_packet_out.dst, dst_mac, ETH_ALEN); icmp_packet_out.header.packet_type = BATADV_ICMP; @@ -170,7 +170,7 @@ int ping(char *mesh_iface, int argc, char **argv) icmp_packet_out.seqno = 0;
if (rr) { - packet_len = sizeof(struct icmp_packet_rr); + packet_len = sizeof(struct batadv_icmp_packet_rr); icmp_packet_out.rr_cur = 1; memset(&icmp_packet_out.rr, 0, BATADV_RR_LEN * ETH_ALEN); memset(last_rr, 0, BATADV_RR_LEN * ETH_ALEN); @@ -241,7 +241,7 @@ read_packet: read_len, dst_string, ntohs(icmp_packet_in.seqno), icmp_packet_in.header.ttl, time_delta);
- if (read_len == sizeof(struct icmp_packet_rr)) { + if (read_len == sizeof(struct batadv_icmp_packet_rr)) { if (last_rr_cur == icmp_packet_in.rr_cur && !memcmp(last_rr, icmp_packet_in.rr, BATADV_RR_LEN * ETH_ALEN)) {
diff --git a/tcpdump.c b/tcpdump.c index ba012a7..302085b 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -254,12 +254,12 @@ static void dump_vlan(unsigned char *packet_buff, ssize_t buff_len, int read_opt
static void dump_batman_tt(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed) { - struct tt_query_packet *tt_query_packet; + struct batadv_tt_query_packet *tt_query_packet; char *tt_desc, *tt_data, tt_type;
- LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct tt_query_packet), "BAT TT"); + LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct batadv_tt_query_packet), "BAT TT");
- tt_query_packet = (struct tt_query_packet *)(packet_buff + sizeof(struct ether_header)); + tt_query_packet = (struct batadv_tt_query_packet *)(packet_buff + sizeof(struct ether_header));
if (!time_printed) print_time(); @@ -295,11 +295,11 @@ static void dump_batman_tt(unsigned char *packet_buff, ssize_t buff_len, int rea
static void dump_batman_roam(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed) { - struct roam_adv_packet *roam_adv_packet; + struct batadv_roam_adv_packet *roam_adv_packet;
- LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct roam_adv_packet), "BAT ROAM"); + LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct batadv_roam_adv_packet), "BAT ROAM");
- roam_adv_packet = (struct roam_adv_packet *)(packet_buff + sizeof(struct ether_header)); + roam_adv_packet = (struct batadv_roam_adv_packet *)(packet_buff + sizeof(struct ether_header));
if (!time_printed) print_time(); @@ -319,12 +319,12 @@ static void dump_batman_roam(unsigned char *packet_buff, ssize_t buff_len, int r static void dump_batman_iv_ogm(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed) { struct ether_header *ether_header; - struct batman_ogm_packet *batman_ogm_packet; + struct batadv_ogm_packet *batman_ogm_packet;
- LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct batman_ogm_packet), "BAT IV OGM"); + LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct batadv_ogm_packet), "BAT IV OGM");
ether_header = (struct ether_header *)packet_buff; - batman_ogm_packet = (struct batman_ogm_packet *)(packet_buff + sizeof(struct ether_header)); + batman_ogm_packet = (struct batadv_ogm_packet *)(packet_buff + sizeof(struct ether_header));
if (!time_printed) print_time(); @@ -346,12 +346,12 @@ static void dump_batman_iv_ogm(unsigned char *packet_buff, ssize_t buff_len, int
static void dump_batman_icmp(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed) { - struct icmp_packet *icmp_packet; + struct batadv_icmp_packet *icmp_packet; char *name;
- LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct icmp_packet), "BAT ICMP"); + LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct batadv_icmp_packet), "BAT ICMP");
- icmp_packet = (struct icmp_packet *)(packet_buff + sizeof(struct ether_header)); + icmp_packet = (struct batadv_icmp_packet *)(packet_buff + sizeof(struct ether_header));
if (!time_printed) print_time(); @@ -389,14 +389,14 @@ static void dump_batman_icmp(unsigned char *packet_buff, ssize_t buff_len, int r static void dump_batman_ucast(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed) { struct ether_header *ether_header; - struct unicast_packet *unicast_packet; + struct batadv_unicast_packet *unicast_packet;
- LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct unicast_packet), "BAT UCAST"); - LEN_CHECK((size_t)buff_len - sizeof(struct ether_header) - sizeof(struct unicast_packet), + LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct batadv_unicast_packet), "BAT UCAST"); + LEN_CHECK((size_t)buff_len - sizeof(struct ether_header) - sizeof(struct batadv_unicast_packet), sizeof(struct ether_header), "BAT UCAST (unpacked)");
ether_header = (struct ether_header *)packet_buff; - unicast_packet = (struct unicast_packet *)(packet_buff + sizeof(struct ether_header)); + unicast_packet = (struct batadv_unicast_packet *)(packet_buff + sizeof(struct ether_header));
if (!time_printed) time_printed = print_time(); @@ -408,22 +408,22 @@ static void dump_batman_ucast(unsigned char *packet_buff, ssize_t buff_len, int get_name_by_macaddr((struct ether_addr *)unicast_packet->dest, read_opt), unicast_packet->ttvn, unicast_packet->header.ttl);
- parse_eth_hdr(packet_buff + ETH_HLEN + sizeof(struct unicast_packet), - buff_len - ETH_HLEN - sizeof(struct unicast_packet), + parse_eth_hdr(packet_buff + ETH_HLEN + sizeof(struct batadv_unicast_packet), + buff_len - ETH_HLEN - sizeof(struct batadv_unicast_packet), read_opt, time_printed); }
static void dump_batman_bcast(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed) { struct ether_header *ether_header; - struct bcast_packet *bcast_packet; + struct batadv_bcast_packet *bcast_packet;
- LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct bcast_packet), "BAT BCAST"); - LEN_CHECK((size_t)buff_len - sizeof(struct ether_header) - sizeof(struct bcast_packet), + LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct batadv_bcast_packet), "BAT BCAST"); + LEN_CHECK((size_t)buff_len - sizeof(struct ether_header) - sizeof(struct batadv_bcast_packet), sizeof(struct ether_header), "BAT BCAST (unpacked)");
ether_header = (struct ether_header *)packet_buff; - bcast_packet = (struct bcast_packet *)(packet_buff + sizeof(struct ether_header)); + bcast_packet = (struct batadv_bcast_packet *)(packet_buff + sizeof(struct ether_header));
if (!time_printed) time_printed = print_time(); @@ -435,19 +435,19 @@ static void dump_batman_bcast(unsigned char *packet_buff, ssize_t buff_len, int get_name_by_macaddr((struct ether_addr *)bcast_packet->orig, read_opt), ntohl(bcast_packet->seqno));
- parse_eth_hdr(packet_buff + ETH_HLEN + sizeof(struct bcast_packet), - buff_len - ETH_HLEN - sizeof(struct bcast_packet), + parse_eth_hdr(packet_buff + ETH_HLEN + sizeof(struct batadv_bcast_packet), + buff_len - ETH_HLEN - sizeof(struct batadv_bcast_packet), read_opt, time_printed); }
static void dump_batman_frag(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed) { - struct unicast_frag_packet *unicast_frag_packet; + struct batadv_unicast_frag_packet *unicast_frag_packet;
- LEN_CHECK((size_t)buff_len - ETH_HLEN, sizeof(struct unicast_frag_packet), "BAT FRAG"); - LEN_CHECK((size_t)buff_len - ETH_HLEN - sizeof(struct unicast_frag_packet), (size_t)ETH_HLEN, "BAT FRAG (unpacked)"); + LEN_CHECK((size_t)buff_len - ETH_HLEN, sizeof(struct batadv_unicast_frag_packet), "BAT FRAG"); + LEN_CHECK((size_t)buff_len - ETH_HLEN - sizeof(struct batadv_unicast_frag_packet), (size_t)ETH_HLEN, "BAT FRAG (unpacked)");
- unicast_frag_packet = (struct unicast_frag_packet *)(packet_buff + ETH_HLEN); + unicast_frag_packet = (struct batadv_unicast_frag_packet *)(packet_buff + ETH_HLEN);
if (!time_printed) time_printed = print_time(); @@ -462,16 +462,16 @@ static void dump_batman_frag(unsigned char *packet_buff, ssize_t buff_len, int r (unicast_frag_packet->flags & BATADV_UNI_FRAG_LARGETAIL ? 'L' : '.'));
if (unicast_frag_packet->flags & BATADV_UNI_FRAG_HEAD) - parse_eth_hdr(packet_buff + ETH_HLEN + sizeof(struct unicast_frag_packet), - buff_len - ETH_HLEN - sizeof(struct unicast_frag_packet), + parse_eth_hdr(packet_buff + ETH_HLEN + sizeof(struct batadv_unicast_frag_packet), + buff_len - ETH_HLEN - sizeof(struct batadv_unicast_frag_packet), read_opt, time_printed); else - printf("length %zu\n", (size_t)buff_len - ETH_HLEN - sizeof(struct unicast_frag_packet)); + printf("length %zu\n", (size_t)buff_len - ETH_HLEN - sizeof(struct batadv_unicast_frag_packet)); }
static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed) { - struct batman_ogm_packet *batman_ogm_packet; + struct batadv_ogm_packet *batman_ogm_packet; struct ether_header *eth_hdr;
eth_hdr = (struct ether_header *)packet_buff; @@ -490,7 +490,7 @@ static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read dump_vlan(packet_buff, buff_len, read_opt, time_printed); break; case BATADV_ETH_P_BATMAN: - batman_ogm_packet = (struct batman_ogm_packet *)(packet_buff + ETH_HLEN); + batman_ogm_packet = (struct batadv_ogm_packet *)(packet_buff + ETH_HLEN);
if ((read_opt & COMPAT_FILTER) && (batman_ogm_packet->header.version != BATADV_COMPAT_VERSION)) diff --git a/traceroute.c b/traceroute.c index 9ef70e8..31f77b0 100644 --- a/traceroute.c +++ b/traceroute.c @@ -51,7 +51,7 @@ void traceroute_usage(void)
int traceroute(char *mesh_iface, int argc, char **argv) { - struct icmp_packet icmp_packet_out, icmp_packet_in; + struct batadv_icmp_packet icmp_packet_out, icmp_packet_in; struct bat_host *bat_host; struct ether_addr *dst_mac = NULL; struct timeval tv;
On Wednesday, June 06, 2012 19:17:27 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
packet.h | 44 +++++++++++++++++++-------------------- ping.c | 8 +++---- tcpdump.c | 66 +++++++++++++++++++++++++++++----------------------------- traceroute.c | 2 +- 4 files changed, 60 insertions(+), 60 deletions(-)
Applied in revision 203b107.
Thanks, Marek
On Wednesday, June 06, 2012 19:17:25 Sven Eckelmann wrote:
Reported-by: Martin Hundebøll martin@hundeboll.net Signed-off-by: Sven Eckelmann sven@narfation.org
packet.h | 12 ++++++------ ping.c | 16 ++++++++-------- tcpdump.c | 8 ++++---- traceroute.c | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-)
Applied in revision 9498c64.
Thanks, Marek
b.a.t.m.a.n@lists.open-mesh.org