Hello community, here is the log from the commit of package batctl for openSUSE:Factory checked in at 2015-04-02 16:03:10 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/batctl (Old) and /work/SRC/openSUSE:Factory/.batctl.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "batctl" Changes: -------- --- /work/SRC/openSUSE:Factory/batctl/batctl.changes 2014-12-25 23:19:58.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.batctl.new/batctl.changes 2015-04-02 16:03:18.000000000 +0200 @@ -1,0 +2,6 @@ +Mon Mar 30 14:29:47 UTC 2015 - p.drouand@gmail.com + +- Update to version 2014.4.0 + * No ChangeLog available + +------------------------------------------------------------------- Old: ---- batctl-2014.3.0.tar.gz New: ---- batctl-2014.4.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ batctl.spec ++++++ --- /var/tmp/diff_new_pack.bNYZXh/_old 2015-04-02 16:03:19.000000000 +0200 +++ /var/tmp/diff_new_pack.bNYZXh/_new 2015-04-02 16:03:19.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package batctl # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -22,7 +22,7 @@ Name: batctl Summary: B.A.T.M.A.N. advanced control and management tool -Version: 2014.3.0 +Version: 2014.4.0 Release: 2 License: GPL-2.0 Group: Productivity/Networking/Other @@ -43,7 +43,7 @@ %setup -n %{name}-%{version} %build -export CFLAgS='%{optflags}' +export CFLAGS='%{optflags}' make %{?_smp_mflags} %install ++++++ batctl-2014.3.0.tar.gz -> batctl-2014.4.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2014.3.0/README new/batctl-2014.4.0/README --- old/batctl-2014.3.0/README 2014-06-14 03:53:50.000000000 +0200 +++ new/batctl-2014.4.0/README 2014-11-16 06:41:28.000000000 +0100 @@ -161,6 +161,7 @@ 2 - batman icmp packets 4 - batman unicast packets 8 - batman broadcast packets + 16 - batman unicast tvlv packets 32 - batman fragmented packets 64 - batman tt / roaming packets 128 - non batman packets diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2014.3.0/main.h new/batctl-2014.4.0/main.h --- old/batctl-2014.3.0/main.h 2014-06-14 03:53:50.000000000 +0200 +++ new/batctl-2014.4.0/main.h 2014-11-16 06:41:28.000000000 +0100 @@ -23,7 +23,7 @@ #define _BATCTL_MAIN_H #ifndef SOURCE_VERSION -#define SOURCE_VERSION "2014.3.0" +#define SOURCE_VERSION "2014.4.0" #endif #define SOCKET_PATH_FMT "%s/batman_adv/%s/socket" @@ -49,4 +49,11 @@ extern char module_ver_path[]; +#ifndef VLAN_VID_MASK +#define VLAN_VID_MASK 0xfff +#endif + +#define BATADV_PRINT_VID(vid) (vid & BATADV_VLAN_HAS_TAG ? \ + (int)(vid & VLAN_VID_MASK) : -1) + #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2014.3.0/man/batctl.8 new/batctl-2014.4.0/man/batctl.8 --- old/batctl-2014.3.0/man/batctl.8 2014-06-14 03:53:50.000000000 +0200 +++ new/batctl-2014.4.0/man/batctl.8 2014-11-16 06:41:28.000000000 +0100 @@ -61,7 +61,7 @@ .br .IP "\fBap_isolation\fP|\fBap\fP [\fB0\fP|\fB1\fP]" If no parameter is given the current ap isolation setting is displayed. Otherwise the parameter is used to enable or -disable ap isolation. This command can be used in conjunction with "-m" option to target per VLAN configurations. +disable ap isolation. This command can be used in conjunction with "\-m" option to target per VLAN configurations. .br .IP "\fBbridge_loop_avoidance\fP|\fBbl\fP [\fB0\fP|\fB1\fP]" If no parameter is given the current bridge loop avoidance setting is displayed. Otherwise the parameter is used to enable @@ -288,6 +288,9 @@ 8 - batman broadcast packets .RE .RS 16 +16 - batman unicast tvlv packets +.RE +.RS 16 32 - batman fragmented packets .RE .RS 16 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2014.3.0/tcpdump.c new/batctl-2014.4.0/tcpdump.c --- old/batctl-2014.3.0/tcpdump.c 2014-06-14 03:53:50.000000000 +0200 +++ new/batctl-2014.4.0/tcpdump.c 2014-11-16 06:41:28.000000000 +0100 @@ -63,7 +63,7 @@ } static unsigned short dump_level_all = DUMP_TYPE_BATOGM | DUMP_TYPE_BATICMP | DUMP_TYPE_BATUCAST | - DUMP_TYPE_BATBCAST | DUMP_TYPE_BATFRAG | DUMP_TYPE_NONBAT; + DUMP_TYPE_BATBCAST | DUMP_TYPE_BATUTVLV | DUMP_TYPE_BATFRAG | DUMP_TYPE_NONBAT; static unsigned short dump_level; static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed); @@ -83,6 +83,7 @@ fprintf(stderr, " \t\t%3d - batman unicast packets\n", DUMP_TYPE_BATUCAST); fprintf(stderr, " \t\t%3d - batman broadcast packets\n", DUMP_TYPE_BATBCAST); fprintf(stderr, " \t\t%3d - batman fragmented packets\n", DUMP_TYPE_BATFRAG); + fprintf(stderr, " \t\t%3d - batman unicast tvlv packets\n", DUMP_TYPE_BATUTVLV); fprintf(stderr, " \t\t%3d - non batman packets\n", DUMP_TYPE_NONBAT); fprintf(stderr, " \t\t%3d - batman ogm & non batman packets\n", DUMP_TYPE_BATOGM | DUMP_TYPE_NONBAT); } @@ -99,6 +100,209 @@ return 1; } +static void batctl_tvlv_parse_gw_v1(void *buff, ssize_t buff_len) +{ + struct batadv_tvlv_gateway_data *tvlv = buff; + uint32_t down, up; + + if (buff_len != sizeof(*tvlv)) { + fprintf(stderr, "Warning - dropping received %s packet as it is not the correct size (%zu): %zu\n", + "TVLV GWv1", sizeof(*tvlv), buff_len); + return; + } + + down = ntohl(tvlv->bandwidth_down); + up = ntohl(tvlv->bandwidth_up); + + printf("\tTVLV GWv1: down %d.%.1dMbps, up %d.%1dMbps\n", + down / 10, down % 10, up / 10, up % 10); +} + +static void batctl_tvlv_parse_dat_v1(void (*buff)__attribute__((unused)), + ssize_t buff_len) +{ + if (buff_len != 0) { + fprintf(stderr, "Warning - dropping received %s packet as it is not the correct size (0): %zu\n", + "TVLV DATv1", buff_len); + return; + } + + printf("\tTVLV DATv1: enabled\n"); +} + +static void batctl_tvlv_parse_nc_v1(void (*buff)__attribute__((unused)), + ssize_t buff_len) +{ + if (buff_len != 0) { + fprintf(stderr, "Warning - dropping received %s packet as it is not the correct size (0): %zu\n", + "TVLV NCv1", buff_len); + return; + } + + printf("\tTVLV NCv1: enabled\n"); +} + +static void batctl_tvlv_parse_tt_v1(void *buff, ssize_t buff_len) +{ + struct batadv_tvlv_tt_data *tvlv = buff; + struct batadv_tvlv_tt_vlan_data *vlan; + int i, num_vlan, num_entry; + const char *type; + size_t vlan_len; + + LEN_CHECK(buff_len, sizeof(*tvlv), "TVLV TTv1") + + if (tvlv->flags & BATADV_TT_OGM_DIFF) + type = "OGM DIFF"; + else if (tvlv->flags & BATADV_TT_REQUEST) + type = "TT REQUEST"; + else if (tvlv->flags & BATADV_TT_RESPONSE) + type = "TT RESPONSE"; + else + type = "UNKNOWN"; + + num_vlan = ntohs(tvlv->num_vlan); + vlan_len = sizeof(*tvlv) + sizeof(*vlan) * num_vlan; + LEN_CHECK(buff_len, vlan_len, "TVLV TTv1 VLAN") + + buff_len -= vlan_len; + num_entry = buff_len / sizeof(struct batadv_tvlv_tt_change); + + printf("\tTVLV TTv1: %s [%c] ttvn=%hhu vlan_num=%hu entry_num=%hu\n", + type, tvlv->flags & BATADV_TT_FULL_TABLE ? 'F' : '.', + tvlv->ttvn, num_vlan, num_entry); + + vlan = (struct batadv_tvlv_tt_vlan_data *)(tvlv + 1); + for (i = 0; i < num_vlan; i++) { + printf("\t\tVLAN ID %hd, crc %#.8x\n", + BATADV_PRINT_VID(ntohs(vlan->vid)), + ntohl(vlan->crc)); + vlan++; + } +} + +static void batctl_tvlv_parse_roam_v1(void *buff, ssize_t buff_len) +{ + struct batadv_tvlv_roam_adv *tvlv = buff; + + if (buff_len != sizeof(*tvlv)) { + fprintf(stderr, "Warning - dropping received %s packet as it is not the correct size (%zu): %zu\n", + "TVLV ROAMv1", sizeof(*tvlv), buff_len); + return; + } + + printf("\tTVLV ROAMv1: client %s, VLAN ID %d\n", + get_name_by_macaddr((struct ether_addr *)tvlv->client, NO_FLAGS), + BATADV_PRINT_VID(ntohs(tvlv->vid))); +} + +typedef void (*batctl_tvlv_parser_t)(void *buff, ssize_t buff_len); + +static batctl_tvlv_parser_t tvlv_parser_get(uint8_t type, uint8_t version) +{ + switch (type) { + case BATADV_TVLV_GW: + switch (version) { + case 1: + return batctl_tvlv_parse_gw_v1; + default: + return NULL; + } + + case BATADV_TVLV_DAT: + switch (version) { + case 1: + return batctl_tvlv_parse_dat_v1; + default: + return NULL; + } + + case BATADV_TVLV_NC: + switch (version) { + case 1: + return batctl_tvlv_parse_nc_v1; + default: + return NULL; + } + + case BATADV_TVLV_TT: + switch (version) { + case 1: + return batctl_tvlv_parse_tt_v1; + default: + return NULL; + } + + case BATADV_TVLV_ROAM: + switch (version) { + case 1: + return batctl_tvlv_parse_roam_v1; + default: + return NULL; + } + + default: + return NULL; + } +} + +static void dump_batman_ucast_tvlv(unsigned char *packet_buff, ssize_t buff_len, + int read_opt, int time_printed) +{ + struct batadv_unicast_tvlv_packet *tvlv_packet; + struct batadv_tvlv_hdr *tvlv_hdr; + struct ether_header *ether_header; + struct ether_addr *src, *dst; + batctl_tvlv_parser_t parser; + ssize_t check_len, tvlv_len, len; + uint8_t *ptr; + + check_len = (size_t)buff_len - sizeof(struct ether_header); + + LEN_CHECK(check_len, sizeof(*tvlv_packet), "BAT TVLV"); + check_len -= sizeof(*tvlv_packet); + + ether_header = (struct ether_header *)packet_buff; + tvlv_packet = (struct batadv_unicast_tvlv_packet *)(ether_header + 1); + + LEN_CHECK(check_len, (size_t)ntohs(tvlv_packet->tvlv_len), + "BAT TVLV (containers)"); + + if (!time_printed) + time_printed = print_time(); + + src = (struct ether_addr *)tvlv_packet->src; + printf("BAT %s > ", get_name_by_macaddr(src, read_opt)); + + dst = (struct ether_addr *)tvlv_packet->dst; + tvlv_len = ntohs(tvlv_packet->tvlv_len); + printf("%s: TVLV, len %zu, tvlv_len %zu, ttl %hhu\n", + get_name_by_macaddr(dst, read_opt), + buff_len - sizeof(struct ether_header), tvlv_len, + tvlv_packet->ttl); + + ptr = (uint8_t *)(tvlv_packet + 1); + + while (tvlv_len >= (ssize_t)sizeof(*tvlv_hdr)) { + tvlv_hdr = (struct batadv_tvlv_hdr *)ptr; + + /* data after TVLV header */ + ptr = (uint8_t *)(tvlv_hdr + 1); + tvlv_len -= sizeof(*tvlv_hdr); + + len = ntohs(tvlv_hdr->len); + LEN_CHECK(tvlv_len, (size_t)len, "BAT UCAST TVLV"); + + parser = tvlv_parser_get(tvlv_hdr->type, tvlv_hdr->version); + if (parser) + parser(ptr, len); + + /* go to the next container */ + ptr += len; + tvlv_len -= len; + } +} + static int dump_bla2_claim(struct ether_header *eth_hdr, struct ether_arp *arphdr, int read_opt) { @@ -148,7 +352,7 @@ break; case BATADV_CLAIM_TYPE_REQUEST: printf("BLA REQUEST, src backbone %s, ", - get_name_by_macaddr((struct ether_addr *)hw_src, read_opt)); + get_name_by_macaddr((struct ether_addr *)eth_hdr->ether_shost, read_opt)); printf("dst backbone %s\n", get_name_by_macaddr((struct ether_addr *)eth_hdr->ether_dhost, read_opt)); break; @@ -482,8 +686,13 @@ { struct ether_header *ether_header; struct batadv_ogm_packet *batman_ogm_packet; + struct batadv_tvlv_hdr *tvlv_hdr; + ssize_t tvlv_len, len, check_len; + batctl_tvlv_parser_t parser; + uint8_t *ptr; - LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct batadv_ogm_packet), "BAT IV OGM"); + check_len = (size_t)buff_len - sizeof(struct ether_header); + LEN_CHECK(check_len, sizeof(struct batadv_ogm_packet), "BAT IV OGM"); ether_header = (struct ether_header *)packet_buff; batman_ogm_packet = (struct batadv_ogm_packet *)(packet_buff + sizeof(struct ether_header)); @@ -494,14 +703,39 @@ printf("BAT %s: ", get_name_by_macaddr((struct ether_addr *)batman_ogm_packet->orig, read_opt)); - printf("OGM IV via neigh %s, seq %u, tq %3d, ttl %2d, v %d, flags [%c%c%c], length %zu\n", + tvlv_len = ntohs(batman_ogm_packet->tvlv_len); + printf("OGM IV via neigh %s, seq %u, tq %3d, ttl %2d, v %d, flags [%c%c%c], length %zu, tvlv_len %zu\n", 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->ttl, batman_ogm_packet->version, (batman_ogm_packet->flags & BATADV_NOT_BEST_NEXT_HOP ? 'N' : '.'), (batman_ogm_packet->flags & BATADV_DIRECTLINK ? 'D' : '.'), (batman_ogm_packet->flags & BATADV_PRIMARIES_FIRST_HOP ? 'F' : '.'), - (size_t)buff_len - sizeof(struct ether_header)); + check_len, tvlv_len); + + check_len -= sizeof(struct batadv_ogm_packet); + LEN_CHECK(check_len, (size_t)tvlv_len, "BAT OGM TVLV (containers)"); + + ptr = (uint8_t *)(batman_ogm_packet + 1); + + while (tvlv_len >= (ssize_t)sizeof(*tvlv_hdr)) { + tvlv_hdr = (struct batadv_tvlv_hdr *)ptr; + + /* data after TVLV header */ + ptr = (uint8_t *)(tvlv_hdr + 1); + tvlv_len -= sizeof(*tvlv_hdr); + + len = ntohs(tvlv_hdr->len); + LEN_CHECK(tvlv_len, (size_t)len, "BAT IV OGM TVLV"); + + parser = tvlv_parser_get(tvlv_hdr->type, tvlv_hdr->version); + if (parser) + parser(ptr, len); + + /* go to the next container */ + ptr += len; + tvlv_len -= len; + } } static void dump_batman_icmp(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed) @@ -684,6 +918,12 @@ if (dump_level & DUMP_TYPE_BATUCAST) dump_batman_4addr(packet_buff, buff_len, read_opt, time_printed); break; + case BATADV_UNICAST_TVLV: + if ((dump_level & DUMP_TYPE_BATUCAST) || + (dump_level & DUMP_TYPE_BATUTVLV)) + dump_batman_ucast_tvlv(packet_buff, buff_len, + read_opt, time_printed); + break; default: fprintf(stderr, "Warning - packet contains unknown batman packet type: 0x%02x\n", batman_ogm_packet->packet_type); break; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/batctl-2014.3.0/tcpdump.h new/batctl-2014.4.0/tcpdump.h --- old/batctl-2014.3.0/tcpdump.h 2014-06-14 03:53:50.000000000 +0200 +++ new/batctl-2014.4.0/tcpdump.h 2014-11-16 06:41:28.000000000 +0100 @@ -41,6 +41,7 @@ #define DUMP_TYPE_BATICMP 2 #define DUMP_TYPE_BATUCAST 4 #define DUMP_TYPE_BATBCAST 8 +#define DUMP_TYPE_BATUTVLV 16 #define DUMP_TYPE_BATFRAG 32 #define DUMP_TYPE_NONBAT 128