Repository : ssh://git@diktynna/batctl On branches: main,main
commit 1979f34d1e490ea2cb37898ff726ae5360e18798 Author: Sven Eckelmann sven@narfation.org Date: Sun Oct 20 12:24:00 2024 +0200
batctl: Switch to kernel-style variable declarations
Signed-off-by: Sven Eckelmann sven@narfation.org
1979f34d1e490ea2cb37898ff726ae5360e18798 backbonetable.c | 3 +- bat-hosts.c | 23 ++++++---- bisect_iv.c | 124 ++++++++++++++++++++++++++++++++++++------------------ debug.c | 5 ++- event.c | 10 ++--- functions.c | 52 ++++++++++++----------- genl.c | 7 +-- genl_json.c | 2 +- gw_mode.c | 5 ++- hash.c | 12 +++--- icmp_helper.c | 9 ++-- interface.c | 13 +++--- loglevel.c | 3 +- mcast_flags.c | 5 ++- neighbors.c | 5 ++- netlink.c | 34 +++++++-------- originators.c | 6 ++- ping.c | 43 +++++++++++++------ routing_algo.c | 8 ++-- statistics.c | 13 ++++-- sys.c | 2 +- tcpdump.c | 65 +++++++++++++++++----------- throughputmeter.c | 21 ++++----- traceroute.c | 23 +++++++--- translate.c | 3 +- translocal.c | 14 ++++-- 26 files changed, 318 insertions(+), 192 deletions(-)
diff --git a/backbonetable.c b/backbonetable.c index 0408b45..f4a63be 100644 --- a/backbonetable.c +++ b/backbonetable.c @@ -33,11 +33,12 @@ static int bla_backbone_callback(struct nl_msg *msg, void *arg) { struct nlattr *attrs[BATADV_ATTR_MAX + 1]; struct nlmsghdr *nlh = nlmsg_hdr(msg); - int last_seen_msecs, last_seen_secs; struct print_opts *opts = arg; struct bat_host *bat_host; struct genlmsghdr *ghdr; uint16_t backbone_crc; + int last_seen_msecs; + int last_seen_secs; uint8_t *backbone; uint16_t vid;
diff --git a/bat-hosts.c b/bat-hosts.c index a422d85..6cc1ae4 100644 --- a/bat-hosts.c +++ b/bat-hosts.c @@ -30,8 +30,9 @@ static int compare_mac(void *data1, void *data2)
static int choose_mac(void *data, int32_t size) { + uint32_t m_size = sizeof(struct ether_addr); unsigned char *key = data; - uint32_t hash = 0, m_size = sizeof(struct ether_addr); + uint32_t hash = 0; size_t i;
for (i = 0; i < m_size; i++) { @@ -49,13 +50,14 @@ static int choose_mac(void *data, int32_t size)
static void parse_hosts_file(struct hashtable_t **hash, const char path[], int read_opt) { - FILE *fd; - char *line_ptr = NULL; - char name[HOST_NAME_MAX_LEN], mac_str[18]; + struct hashtable_t *swaphash; + char name[HOST_NAME_MAX_LEN]; struct ether_addr *mac_addr; struct bat_host *bat_host; - struct hashtable_t *swaphash; + char *line_ptr = NULL; + char mac_str[18]; size_t len = 0; + FILE *fd;
name[0] = mac_str[0] = '\0';
@@ -142,11 +144,13 @@ out:
void bat_hosts_init(int read_opt) { - unsigned int i, j, parse; - char confdir[CONF_DIR_LEN]; - char *homedir; size_t locations = sizeof(bat_hosts_path) / sizeof(char *); + char confdir[CONF_DIR_LEN]; + unsigned int parse; char *normalized; + unsigned int i; + unsigned int j; + char *homedir;
/*** * realpath could allocate the memory for us but some embedded libc @@ -206,8 +210,9 @@ out:
struct bat_host *bat_hosts_find_by_name(char *name) { + struct bat_host *bat_host = NULL; struct hash_it_t *hashit = NULL; - struct bat_host *bat_host = NULL, *tmp_bat_host; + struct bat_host *tmp_bat_host;
if (!host_hash) return NULL; diff --git a/bisect_iv.c b/bisect_iv.c index 3f9b24b..8817779 100644 --- a/bisect_iv.c +++ b/bisect_iv.c @@ -44,8 +44,9 @@ static int compare_name(void *data1, void *data2)
static int choose_name(void *data, int32_t size) { + uint32_t m_size = NAME_LEN - 1; unsigned char *key = data; - uint32_t hash = 0, m_size = NAME_LEN - 1; + uint32_t hash = 0; size_t i;
for (i = 0; i < m_size; i++) { @@ -110,8 +111,8 @@ static struct orig_event *orig_event_new(struct bat_node *bat_node, struct bat_n
static struct orig_event *orig_event_get_by_name(struct bat_node *bat_node, char *orig) { - struct bat_node *orig_node; struct orig_event *orig_event; + struct bat_node *orig_node;
if (!bat_node) return NULL; @@ -145,11 +146,15 @@ static struct orig_event *orig_event_get_by_ptr(struct bat_node *bat_node, struc
static void node_free(void *data) { - struct orig_event *orig_event, *orig_event_tmp; - struct seqno_event *seqno_event, *seqno_event_tmp; - struct rt_table *rt_table, *rt_table_tmp; - struct rt_hist *rt_hist, *rt_hist_tmp; struct bat_node *bat_node = (struct bat_node *)data; + struct seqno_event *seqno_event_tmp; + struct orig_event *orig_event_tmp; + struct seqno_event *seqno_event; + struct orig_event *orig_event; + struct rt_table *rt_table_tmp; + struct rt_hist *rt_hist_tmp; + struct rt_table *rt_table; + struct rt_hist *rt_hist;
list_for_each_entry_safe(orig_event, orig_event_tmp, &bat_node->orig_event_list, list) { list_for_each_entry_safe(seqno_event, seqno_event_tmp, &orig_event->event_list, list) { @@ -178,12 +183,14 @@ static void node_free(void *data)
static int routing_table_new(char *orig, char *next_hop, char *old_next_hop, char rt_flag) { + struct rt_table *prev_rt_table = NULL; + struct seqno_event *seqno_event; struct bat_node *next_hop_node; struct orig_event *orig_event; - struct seqno_event *seqno_event; - struct rt_table *rt_table, *prev_rt_table = NULL; + struct rt_table *rt_table; struct rt_hist *rt_hist; - int i, j = -1; + int j = -1; + int i;
if (!curr_bat_node) { fprintf(stderr, "Routing table change without preceding OGM - skipping"); @@ -373,9 +380,11 @@ err:
static int seqno_event_new(char *iface_addr, char *orig, char *prev_sender, char *neigh, long long seqno, int tq, int ttl) { - struct bat_node *orig_node, *neigh_node, *prev_sender_node; - struct orig_event *orig_event; + struct bat_node *prev_sender_node; struct seqno_event *seqno_event; + struct orig_event *orig_event; + struct bat_node *neigh_node; + struct bat_node *orig_node;
if (!iface_addr) { fprintf(stderr, "Invalid interface address found - skipping"); @@ -450,11 +459,23 @@ err:
static int parse_log_file(char *file_path) { - FILE *fd; - char line_buff[MAX_LINE], *start_ptr, *start_ptr_safe, *tok_ptr; - char *neigh, *iface_addr, *orig, *prev_sender, rt_flag; - int line_count = 0, tq, ttl, i, res, max; + char line_buff[MAX_LINE]; + char *start_ptr_safe; + int line_count = 0; + char *prev_sender; + char *iface_addr; + char *start_ptr; long long seqno; + char *tok_ptr; + char rt_flag; + char *neigh; + char *orig; + FILE *fd; + int ttl; + int res; + int max; + int tq; + int i;
fd = fopen(file_path, "r");
@@ -619,10 +640,10 @@ static struct rt_hist *get_rt_hist_by_node_seqno(struct bat_node *bat_node, stru static int print_rt_path_at_seqno(struct bat_node *src_node, struct bat_node *dst_node, struct bat_node *next_hop, long long seqno, long long seqno_rand, int read_opt) { + char curr_loop_magic[LOOP_MAGIC_LEN]; struct bat_node *next_hop_tmp; struct orig_event *orig_event; struct rt_hist *rt_hist; - char curr_loop_magic[LOOP_MAGIC_LEN];
snprintf(curr_loop_magic, sizeof(curr_loop_magic), "%s%s%lli%lli", src_node->name, dst_node->name, seqno, seqno_rand); @@ -681,11 +702,14 @@ static int find_rt_table_change(struct bat_node *src_node, struct bat_node *dst_ struct bat_node *curr_node, long long seqno_min, long long seqno_max, long long seqno_rand, int read_opt) { + char curr_loop_magic[LOOP_MAGIC_LEN]; + long long seqno_min_tmp = seqno_min; struct orig_event *orig_event; - struct rt_hist *rt_hist, *rt_hist_tmp; - char curr_loop_magic[LOOP_MAGIC_LEN], loop_check = 0; + struct rt_hist *rt_hist_tmp; + struct rt_hist *rt_hist; + char loop_check = 0; + long long seqno_tmp; int res; - long long seqno_tmp, seqno_min_tmp = seqno_min;
/* printf("%i: curr_node: %s ", bla, get_name_by_macstr(curr_node->name, read_opt)); @@ -805,13 +829,15 @@ loop:
static void loop_detection(char *loop_orig, long long seqno_min, long long seqno_max, char *filter_orig, int read_opt) { - struct bat_node *bat_node; - struct orig_event *orig_event; struct hash_it_t *hashit = NULL; - struct rt_hist *rt_hist, *prev_rt_hist; - long long last_seqno = -1, seqno_count = 0; - int res; + struct orig_event *orig_event; + struct rt_hist *prev_rt_hist; + struct bat_node *bat_node; + long long last_seqno = -1; + long long seqno_count = 0; char check_orig[NAME_LEN]; + struct rt_hist *rt_hist; + int res;
printf("\nAnalyzing routing tables ");
@@ -972,7 +998,8 @@ static void seqno_trace_print(struct list_head *trace_list, char *trace_orig, long long seqno_min, long long seqno_max, char *filter_orig, int read_opt) { struct seqno_trace *seqno_trace; - char head[MAX_LINE], check_orig[NAME_LEN]; + char check_orig[NAME_LEN]; + char head[MAX_LINE]; int i;
/* if no option was given filter_orig is empty */ @@ -1067,7 +1094,8 @@ err: static struct seqno_trace_neigh *seqno_trace_find_neigh(struct bat_node *neigh, struct bat_node *prev_sender, struct seqno_trace_neigh *seqno_trace_neigh) { - struct seqno_trace_neigh *seqno_trace_neigh_tmp, *seqno_trace_neigh_ret; + struct seqno_trace_neigh *seqno_trace_neigh_tmp; + struct seqno_trace_neigh *seqno_trace_neigh_ret; int i;
for (i = 0; i < seqno_trace_neigh->num_neighbors; i++) { @@ -1103,7 +1131,8 @@ static int seqno_trace_fix_leaf(struct seqno_trace_neigh *seqno_trace_mom, struct seqno_trace_neigh *seqno_trace_old_mom, struct seqno_trace_neigh *seqno_trace_child) { - struct seqno_trace_neigh **data_ptr, *seqno_trace_neigh; + struct seqno_trace_neigh *seqno_trace_neigh; + struct seqno_trace_neigh **data_ptr; int i, j = 0;
data_ptr = malloc((seqno_trace_old_mom->num_neighbors - 1) * sizeof(struct seqno_trace_neigh *)); @@ -1181,8 +1210,10 @@ static void seqno_trace_free(struct seqno_trace *seqno_trace) static int seqno_trace_add(struct list_head *trace_list, struct bat_node *bat_node, struct seqno_event *seqno_event, char print_trace) { - struct seqno_trace *seqno_trace = NULL, *seqno_trace_tmp = NULL, *seqno_trace_prev = NULL; + struct seqno_trace *seqno_trace_prev = NULL; struct seqno_trace_neigh *seqno_trace_neigh; + struct seqno_trace *seqno_trace_tmp = NULL; + struct seqno_trace *seqno_trace = NULL;
list_for_each_entry(seqno_trace_tmp, trace_list, list) { if (seqno_trace_tmp->seqno == seqno_event->seqno) { @@ -1235,13 +1266,15 @@ err:
static void trace_seqnos(char *trace_orig, long long seqno_min, long long seqno_max, char *filter_orig, int read_opt) { - struct bat_node *bat_node; - struct orig_event *orig_event; + struct seqno_trace *seqno_trace_tmp; + struct seqno_trace *seqno_trace; struct seqno_event *seqno_event; struct hash_it_t *hashit = NULL; + struct orig_event *orig_event; struct list_head trace_list; - struct seqno_trace *seqno_trace, *seqno_trace_tmp; - char check_orig[NAME_LEN], print_trace; + struct bat_node *bat_node; + char check_orig[NAME_LEN]; + char print_trace; int res;
/* if no option was given filter_orig is empty */ @@ -1300,9 +1333,9 @@ out:
static void print_rt_tables(char *rt_orig, long long seqno_min, long long seqno_max, char *filter_orig, int read_opt) { + struct seqno_event *seqno_event; struct bat_node *bat_node; struct rt_table *rt_table; - struct seqno_event *seqno_event; char check_orig[NAME_LEN]; int i;
@@ -1390,9 +1423,9 @@ out:
static int get_orig_addr(char *orig_name, char *orig_addr) { - struct bat_host *bat_host; - struct ether_addr *orig_mac; char *orig_name_tmp = orig_name; + struct ether_addr *orig_mac; + struct bat_host *bat_host;
bat_host = bat_hosts_find_by_name(orig_name_tmp);
@@ -1425,11 +1458,22 @@ err:
static int bisect_iv(struct state *state __maybe_unused, int argc, char **argv) { - int ret = EXIT_FAILURE, res, optchar, found_args = 1; - int read_opt = USE_BAT_HOSTS, num_parsed_files; - long long tmp_seqno, seqno_max = -1, seqno_min = -1; - char *trace_orig_ptr = NULL, *rt_orig_ptr = NULL, *loop_orig_ptr = NULL; - char orig[NAME_LEN], filter_orig[NAME_LEN], *dash_ptr, *filter_orig_ptr = NULL; + int read_opt = USE_BAT_HOSTS; + char *filter_orig_ptr = NULL; + char *trace_orig_ptr = NULL; + char *loop_orig_ptr = NULL; + char filter_orig[NAME_LEN]; + char *rt_orig_ptr = NULL; + long long seqno_max = -1; + long long seqno_min = -1; + int ret = EXIT_FAILURE; + int num_parsed_files; + long long tmp_seqno; + char orig[NAME_LEN]; + int found_args = 1; + char *dash_ptr; + int optchar; + int res;
memset(orig, 0, NAME_LEN); memset(filter_orig, 0, NAME_LEN); diff --git a/debug.c b/debug.c index 127129d..e1e67ca 100644 --- a/debug.c +++ b/debug.c @@ -44,10 +44,11 @@ static void debug_table_usage(struct state *state) int handle_debug_table(struct state *state, int argc, char **argv) { struct debug_table_data *debug_table = state->cmd->arg; - int optchar, read_opt = USE_BAT_HOSTS; - char *orig_iface = NULL; + int read_opt = USE_BAT_HOSTS; float orig_timeout = 0.0f; float watch_interval = 1; + char *orig_iface = NULL; + int optchar; int err;
while ((optchar = getopt(argc, argv, "hnw:t:Humi:")) != -1) { diff --git a/event.c b/event.c index c2e4941..33764e3 100644 --- a/event.c +++ b/event.c @@ -56,8 +56,8 @@ static void event_usage(void)
static int event_prepare(struct state *state) { - int ret; int mcid; + int ret;
if (!state->sock) return -EOPNOTSUPP; @@ -165,8 +165,8 @@ static void event_parse_set_mesh(struct nlattr **attrs) BATADV_ATTR_ALGO_NAME, }; char meshif_buf[IF_NAMESIZE]; - char *meshif_name; uint32_t mesh_ifindex; + char *meshif_name;
/* ignore entry when attributes are missing */ if (missing_mandatory_attrs(attrs, mesh_mandatory, @@ -299,10 +299,10 @@ static void event_parse_set_hardif(struct nlattr **attrs) }; char meshif_buf[IF_NAMESIZE]; char hardif_buf[IF_NAMESIZE]; - char *meshif_name; - char *hardif_name; uint32_t hardif_ifindex; uint32_t mesh_ifindex; + char *meshif_name; + char *hardif_name;
/* ignore entry when attributes are missing */ if (missing_mandatory_attrs(attrs, hardif_mandatory, @@ -355,8 +355,8 @@ static void event_parse_set_vlan(struct nlattr **attrs) BATADV_ATTR_VLANID, }; char meshif_buf[IF_NAMESIZE]; - char *meshif_name; uint32_t mesh_ifindex; + char *meshif_name; uint16_t vid;
/* ignore entry when attributes are missing */ diff --git a/functions.c b/functions.c index 1faba08..26f624e 100644 --- a/functions.c +++ b/functions.c @@ -57,7 +57,8 @@ void start_timer(void)
double end_timer(void) { - struct timespec end_time, diff; + struct timespec end_time; + struct timespec diff;
clock_gettime(CLOCK_MONOTONIC, &end_time); diff.tv_sec = end_time.tv_sec - start_time.tv_sec; @@ -173,9 +174,9 @@ int read_file(const char *full_path, int read_opt) struct ether_addr *translate_mac(struct state *state, const struct ether_addr *mac) { - struct ether_addr in_mac; static struct ether_addr out_mac; struct ether_addr *mac_result; + struct ether_addr in_mac;
/* input mac has to be copied because it could be in the shared * ether_aton buffer @@ -201,11 +202,11 @@ int get_algoname(struct state *state, unsigned int mesh_ifindex,
static int resolve_l3addr(int ai_family, const char *asc, void *l3addr) { - int ret; + struct sockaddr_in6 *inet6; + struct sockaddr_in *inet4; struct addrinfo hints; struct addrinfo *res; - struct sockaddr_in *inet4; - struct sockaddr_in6 *inet6; + int ret;
memset(&hints, 0, sizeof(hints)); hints.ai_family = ai_family; @@ -237,11 +238,11 @@ static int resolve_l3addr(int ai_family, const char *asc, void *l3addr) static void request_mac_resolve(int ai_family, const void *l3addr) { const struct sockaddr *sockaddr; - struct sockaddr_in inet4; struct sockaddr_in6 inet6; + struct sockaddr_in inet4; size_t sockaddr_len; - int sock; char t = 0; + int sock;
sock = socket(ai_family, SOCK_DGRAM, IPPROTO_UDP); if (sock < 0) @@ -289,13 +290,13 @@ static struct nla_policy neigh_policy[NDA_MAX + 1] = {
static int resolve_mac_from_parse(struct nl_msg *msg, void *arg) { + struct resolve_mac_nl_arg *nl_arg = arg; struct nlattr *tb[NDA_MAX + 1]; struct ndmsg *nm; - int ret; - int l3_len; - struct resolve_mac_nl_arg *nl_arg = arg; - uint8_t *mac; uint8_t *l3addr; + uint8_t *mac; + int l3_len; + int ret;
nm = nlmsg_data(nlmsg_hdr(msg)); ret = nlmsg_parse(nlmsg_hdr(msg), sizeof(*nm), tb, NDA_MAX, @@ -347,20 +348,20 @@ err: static struct ether_addr *resolve_mac_from_cache(int ai_family, const void *l3addr) { - struct nl_sock *sock; struct ether_addr *mac_result = NULL; static struct ether_addr mac_tmp; - int ret; - struct rtgenmsg gmsg = { - .rtgen_family = ai_family, - }; - struct nl_cb *cb = NULL; struct resolve_mac_nl_arg arg = { .ai_family = ai_family, .l3addr = l3addr, .mac_result = &mac_tmp, .found = 0, }; + struct rtgenmsg gmsg = { + .rtgen_family = ai_family, + }; + struct nl_cb *cb = NULL; + struct nl_sock *sock; + int ret;
sock = nl_socket_alloc(); if (!sock) @@ -398,12 +399,12 @@ err:
static struct ether_addr *resolve_mac_from_addr(int ai_family, const char *asc) { - uint8_t ipv4_addr[4]; + struct ether_addr *mac_result = NULL; uint8_t ipv6_addr[16]; + uint8_t ipv4_addr[4]; + int retries = 5; void *l3addr; int ret; - int retries = 5; - struct ether_addr *mac_result = NULL;
switch (ai_family) { case AF_INET: @@ -434,7 +435,10 @@ static struct ether_addr *resolve_mac_from_addr(int ai_family, const char *asc) struct ether_addr *resolve_mac(const char *asc) { struct ether_addr *mac_result = NULL; - static const int ai_families[] = {AF_INET, AF_INET6}; + static const int ai_families[] = { + AF_INET, + AF_INET6, + }; size_t i;
mac_result = ether_aton(asc); @@ -887,8 +891,8 @@ static int get_random_bytes_syscall(void *buf __maybe_unused,
static int get_random_bytes_urandom(void *buf, size_t buflen) { - int fd; ssize_t r; + int fd;
fd = open("/dev/urandom", O_RDONLY); if (fd < 0) @@ -907,10 +911,10 @@ static int get_random_bytes_urandom(void *buf, size_t buflen)
static int get_random_bytes_fallback(void *buf, size_t buflen) { - struct timespec now; static int initialized; - size_t i; + struct timespec now; uint8_t *bufc = buf; + size_t i;
/* this is not a good source for randomness */ if (!initialized) { diff --git a/genl.c b/genl.c index cd6c652..d2e54c1 100644 --- a/genl.c +++ b/genl.c @@ -79,13 +79,14 @@ static int mcast_family_handler(struct nl_msg *msg, void *arg) int nl_get_multicast_id(struct nl_sock *sock, const char *family, const char *group) { - struct nl_msg *msg; - struct nl_cb *cb; - int ret, ctrlid; struct mcast_handler_args grp = { .group = group, .id = -ENOENT, }; + struct nl_msg *msg; + struct nl_cb *cb; + int ctrlid; + int ret;
msg = nlmsg_alloc(); if (!msg) diff --git a/genl_json.c b/genl_json.c index 939e730..f86d158 100644 --- a/genl_json.c +++ b/genl_json.c @@ -558,13 +558,13 @@ static int netlink_print_query_json_attributes(struct nl_msg *msg, void *arg) static int netlink_print_query_json(struct state *state, struct json_query_data *json_query) { - int ret; struct json_opts json_opts = { .is_first = true, .query_opts = { .err = 0, }, }; + int ret;
if (json_query->nlm_flags & NLM_F_DUMP) putchar('['); diff --git a/gw_mode.c b/gw_mode.c index 5cde2ce..9b3e956 100644 --- a/gw_mode.c +++ b/gw_mode.c @@ -169,8 +169,8 @@ static int print_gw(struct nl_msg *msg, void *arg) int *result = arg; const char *algo; uint8_t gw_mode; - uint32_t val; uint32_t down; + uint32_t val; uint32_t up;
if (!genlmsg_valid_hdr(nlh, 0)) @@ -280,7 +280,8 @@ static int gw_write_setting(struct state *state)
static int gw_mode(struct state *state, int argc, char **argv) { - int optchar, res = EXIT_FAILURE; + int res = EXIT_FAILURE; + int optchar;
while ((optchar = getopt(argc, argv, "h")) != -1) { switch (optchar) { diff --git a/hash.c b/hash.c index ec54f4f..4e150e2 100644 --- a/hash.c +++ b/hash.c @@ -27,7 +27,8 @@ void hash_init(struct hashtable_t *hash) * if you don't remove the elements, memory might be leaked. */ void hash_delete(struct hashtable_t *hash, hashdata_free_cb free_cb) { - struct element_t *bucket, *last_bucket; + struct element_t *last_bucket; + struct element_t *bucket; int i;
for (i = 0; i < hash->size; i++) { @@ -50,8 +51,9 @@ void hash_delete(struct hashtable_t *hash, hashdata_free_cb free_cb) static int hash_add_bucket(struct hashtable_t *hash, void *data, struct element_t *bucket, int check_duplicate) { + struct element_t *prev_bucket = NULL; + struct element_t *bucket_it; int index; - struct element_t *bucket_it, *prev_bucket = NULL;
index = hash->choose(data, hash->size); bucket_it = hash->table[index]; @@ -198,8 +200,8 @@ struct hashtable_t *hash_new(int size, hashdata_compare_cb compare, /* adds data to the hashtable. returns 0 on success, -1 on error */ int hash_add(struct hashtable_t *hash, void *data) { - int ret; struct element_t *bucket; + int ret;
/* found the tail of the list, add new element */ bucket = debugMalloc(sizeof(struct element_t), 304); @@ -218,8 +220,8 @@ int hash_add(struct hashtable_t *hash, void *data) * or NULL on error */ void *hash_find(struct hashtable_t *hash, void *keydata) { - int index; struct element_t *bucket; + int index;
index = hash->choose(keydata, hash->size); bucket = hash->table[index]; @@ -316,8 +318,8 @@ struct hashtable_t *hash_resize(struct hashtable_t *hash, int size)
/* print the hash table for debugging */ /* void hash_debug(struct hashtable_t *hash) { - int i; struct element_t *bucket; + int i;
for (i = 0; i < hash->size; i++) { printf("[%d] ", i); diff --git a/icmp_helper.c b/icmp_helper.c index 9ee4fb1..a523f23 100644 --- a/icmp_helper.c +++ b/icmp_helper.c @@ -251,9 +251,9 @@ static int icmp_interface_update_parse(struct nl_msg *msg, void *arg) struct icmp_interface *iface; struct ifinfomsg *ifm; char *ifname; - int ret; - int master; uint8_t *mac; + int master; + int ret;
ifm = nlmsg_data(nlmsg_hdr(msg)); ret = nlmsg_parse(nlmsg_hdr(msg), sizeof(*ifm), attrs, IFLA_MAX, @@ -456,9 +456,9 @@ ssize_t icmp_interface_read(struct batadv_icmp_header *icmp_packet, size_t len, struct iovec vector[2]; fd_set read_sockets; size_t packet_len; - int max_sock; ssize_t read_len; int read_sock; + int max_sock; int res;
if (len < sizeof(*icmp_packet)) @@ -521,7 +521,8 @@ retry:
void icmp_interfaces_clean(void) { - struct icmp_interface *iface, *safe; + struct icmp_interface *iface; + struct icmp_interface *safe;
list_for_each_entry_safe(iface, safe, &interface_list, list) icmp_interface_destroy(iface); diff --git a/interface.c b/interface.c index 93a35da..9fbd144 100644 --- a/interface.c +++ b/interface.c @@ -117,9 +117,9 @@ static int print_interfaces_rtnl_parse(struct nl_msg *msg, void *arg) struct state *state = arg; struct ifinfomsg *ifm; unsigned int master; + const char *status; char *ifname; int ret; - const char *status;
ifm = nlmsg_data(nlmsg_hdr(msg)); ret = nlmsg_parse(nlmsg_hdr(msg), sizeof(*ifm), attrs, IFLA_MAX, @@ -407,16 +407,17 @@ err_free_msg: static int interface(struct state *state, int argc, char **argv) { struct interface_create_params create_params = {}; - int i, optchar; - int ret; - unsigned int ifindex; + bool manual_mode = false; unsigned int ifmaster; + unsigned int ifindex; unsigned int pre_cnt; const char *long_op; unsigned int cnt; - int rest_argc; char **rest_argv; - bool manual_mode = false; + int rest_argc; + int optchar; + int ret; + int i;
while ((optchar = getopt(argc, argv, "hM")) != -1) { switch (optchar) { diff --git a/loglevel.c b/loglevel.c index 7a88794..ccbfb7b 100644 --- a/loglevel.c +++ b/loglevel.c @@ -110,7 +110,8 @@ static int log_level_write_setting(struct state *state)
static int loglevel(struct state *state, int argc, char **argv) { - int optchar, res = EXIT_FAILURE; + int res = EXIT_FAILURE; + int optchar; int i;
log_level_globals.log_level = 0; diff --git a/mcast_flags.c b/mcast_flags.c index 819f767..4a1af98 100644 --- a/mcast_flags.c +++ b/mcast_flags.c @@ -98,8 +98,11 @@ static int netlink_print_mcast_flags(struct state *state, char *orig_iface, int read_opts, float orig_timeout, float watch_interval) { - char querier4, querier6, shadowing4, shadowing6; char *info_header; + char shadowing4; + char shadowing6; + char querier4; + char querier6; char *header; bool bridged; int ret; diff --git a/neighbors.c b/neighbors.c index f3de544..bed903d 100644 --- a/neighbors.c +++ b/neighbors.c @@ -31,11 +31,12 @@ static const int neighbors_mandatory[] = {
static int neighbors_callback(struct nl_msg *msg, void *arg) { - unsigned throughput_mbits, throughput_kbits; - struct nlattr *attrs[BATADV_ATTR_MAX+1]; + struct nlattr *attrs[BATADV_ATTR_MAX + 1]; struct nlmsghdr *nlh = nlmsg_hdr(msg); int last_seen_msecs, last_seen_secs; struct print_opts *opts = arg; + unsigned int throughput_mbits; + unsigned int throughput_kbits; char ifname_buf[IF_NAMESIZE]; struct bat_host *bat_host; struct genlmsghdr *ghdr; diff --git a/netlink.c b/netlink.c index 8e0162d..c74c15c 100644 --- a/netlink.c +++ b/netlink.c @@ -343,16 +343,16 @@ static int info_callback(struct nl_msg *msg, void *arg) struct nlmsghdr *nlh = nlmsg_hdr(msg); struct print_opts *opts = arg; const uint8_t *primary_mac; + uint16_t bla_group_id = 0; + const char *extra_header; + char *extra_info = NULL; struct genlmsghdr *ghdr; const uint8_t *mesh_mac; const char *primary_if; + const char *algo_name; const char *mesh_name; const char *version; - char *extra_info = NULL; uint8_t ttvn = 0; - uint16_t bla_group_id = 0; - const char *algo_name; - const char *extra_header; int ret;
if (!genlmsg_valid_hdr(nlh, 0)) { @@ -460,14 +460,14 @@ static int info_callback(struct nl_msg *msg, void *arg)
char *netlink_get_info(struct state *state, uint8_t nl_cmd, const char *header) { - struct nl_msg *msg; - struct nl_cb *cb; struct print_opts opts = { .read_opt = 0, .nl_cmd = nl_cmd, .remaining_header = NULL, .static_header = header, }; + struct nl_msg *msg; + struct nl_cb *cb; int ret;
msg = nlmsg_alloc(); @@ -689,10 +689,10 @@ struct translate_mac_netlink_opts {
static int translate_mac_netlink_cb(struct nl_msg *msg, void *arg) { - struct nlattr *attrs[BATADV_ATTR_MAX+1]; + struct nlattr *attrs[BATADV_ATTR_MAX + 1]; + struct translate_mac_netlink_opts *opts; struct nlmsghdr *nlh = nlmsg_hdr(msg); struct nlquery_opts *query_opts = arg; - struct translate_mac_netlink_opts *opts; struct genlmsghdr *ghdr; uint8_t *addr; uint8_t *orig; @@ -782,10 +782,10 @@ static int get_nexthop_netlink_cb(struct nl_msg *msg, void *arg) struct nlquery_opts *query_opts = arg; struct get_nexthop_netlink_opts *opts; struct genlmsghdr *ghdr; - const uint8_t *orig; const uint8_t *neigh; - uint32_t index; + const uint8_t *orig; const char *ifname; + uint32_t index;
opts = container_of(query_opts, struct get_nexthop_netlink_opts, query_opts); @@ -877,12 +877,12 @@ struct get_primarymac_netlink_opts {
static int get_primarymac_netlink_cb(struct nl_msg *msg, void *arg) { - struct nlattr *attrs[BATADV_ATTR_MAX+1]; + struct nlattr *attrs[BATADV_ATTR_MAX + 1]; + struct get_primarymac_netlink_opts *opts; struct nlmsghdr *nlh = nlmsg_hdr(msg); struct nlquery_opts *query_opts = arg; - struct get_primarymac_netlink_opts *opts; - struct genlmsghdr *ghdr; const uint8_t *primary_mac; + struct genlmsghdr *ghdr;
opts = container_of(query_opts, struct get_primarymac_netlink_opts, query_opts); @@ -950,13 +950,13 @@ struct get_algoname_netlink_opts {
static int get_algoname_netlink_cb(struct nl_msg *msg, void *arg) { - static const int mandatory[] = { - BATADV_ATTR_ALGO_NAME, - }; struct nlattr *attrs[BATADV_ATTR_MAX + 1]; + struct get_algoname_netlink_opts *opts; struct nlmsghdr *nlh = nlmsg_hdr(msg); struct nlquery_opts *query_opts = arg; - struct get_algoname_netlink_opts *opts; + static const int mandatory[] = { + BATADV_ATTR_ALGO_NAME, + }; struct genlmsghdr *ghdr; const char *algoname;
diff --git a/originators.c b/originators.c index e687078..1d31a16 100644 --- a/originators.c +++ b/originators.c @@ -34,14 +34,16 @@ static const int originators_mandatory[] = {
static int originators_callback(struct nl_msg *msg, void *arg) { - unsigned throughput_mbits, throughput_kbits; struct nlattr *attrs[BATADV_ATTR_MAX+1]; struct nlmsghdr *nlh = nlmsg_hdr(msg); - int last_seen_msecs, last_seen_secs; + unsigned int throughput_mbits; + unsigned int throughput_kbits; struct print_opts *opts = arg; char ifname_buf[IF_NAMESIZE]; struct bat_host *bat_host; struct genlmsghdr *ghdr; + int last_seen_msecs; + int last_seen_secs; uint32_t ifindex; float last_seen; uint8_t *neigh; diff --git a/ping.c b/ping.c index 52bce4d..27f698e 100644 --- a/ping.c +++ b/ping.c @@ -59,20 +59,39 @@ static void sig_handler(int sig)
static int ping(struct state *state, int argc, char **argv) { - struct batadv_icmp_packet_rr icmp_packet_out, icmp_packet_in; + struct batadv_icmp_packet_rr icmp_packet_out; + struct batadv_icmp_packet_rr icmp_packet_in; + uint8_t last_rr[BATADV_RR_LEN][ETH_ALEN]; + struct ether_addr *dst_mac = NULL; + struct ether_addr *rr_mac = NULL; + int disable_translate_mac = 0; + unsigned int seq_counter = 0; + unsigned int packets_out = 0; + unsigned int packets_in = 0; + unsigned int packets_loss; + struct bat_host *bat_host; + struct bat_host *rr_host; + uint8_t last_rr_cur = 0; + int ret = EXIT_FAILURE; + int loop_interval = 0; + int loop_count = -1; + int found_args = 1; + size_t packet_len; struct timeval tv; - struct ether_addr *dst_mac = NULL, *rr_mac = NULL; - struct bat_host *bat_host, *rr_host; - ssize_t read_len; - int ret = EXIT_FAILURE, res, optchar, found_args = 1; - int loop_count = -1, loop_interval = 0, timeout = 1, rr = 0, i; - unsigned int seq_counter = 0, packets_out = 0, packets_in = 0, packets_loss; - 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[BATADV_RR_LEN][ETH_ALEN]; - size_t packet_len; - int disable_translate_mac = 0; + float mdev = 0.0; + ssize_t read_len; + char *dst_string; + char *mac_string; + char *rr_string; + float min = 0.0; + float max = 0.0; + float avg = 0.0; + int timeout = 1; + int optchar; + int rr = 0; + int res; + int i;
while ((optchar = getopt(argc, argv, "hc:i:t:RT")) != -1) { switch (optchar) { diff --git a/routing_algo.c b/routing_algo.c index bff1e90..e93cd62 100644 --- a/routing_algo.c +++ b/routing_algo.c @@ -80,11 +80,11 @@ static int routing_algos_callback(struct nl_msg *msg, void *arg __maybe_unused)
static int print_routing_algos(struct state *state) { - struct nl_msg *msg; - struct nl_cb *cb; struct print_opts opts = { .callback = routing_algos_callback, }; + struct nl_msg *msg; + struct nl_cb *cb;
msg = nlmsg_alloc(); if (!msg) @@ -151,8 +151,8 @@ static int print_ra_interfaces_rtnl_parse(struct nl_msg *msg, void *arg) { struct print_ra_interfaces_rtnl_arg *print_arg = arg; struct nlattr *attrs[IFLA_MAX + 1]; - char algoname[256]; struct ifinfomsg *ifm; + char algoname[256]; char *mesh_iface; int ret;
@@ -264,8 +264,8 @@ err_free_sock:
static int routing_algo(struct state *state, int argc, char **argv) { - int optchar; int res = EXIT_FAILURE; + int optchar; int ret;
while ((optchar = getopt(argc, argv, "h")) != -1) { diff --git a/statistics.c b/statistics.c index b7b7637..2b63037 100644 --- a/statistics.c +++ b/statistics.c @@ -27,11 +27,15 @@ void check_root_or_die(const char *cmd); /* code borrowed from ethtool */ static int statistics_custom_get(int fd, struct ifreq *ifr) { - struct ethtool_drvinfo drvinfo; struct ethtool_gstrings *strings = NULL; struct ethtool_stats *stats = NULL; - unsigned int n_stats, sz_str, sz_stats, i; - int err, ret = EXIT_FAILURE; + struct ethtool_drvinfo drvinfo; + int ret = EXIT_FAILURE; + unsigned int sz_stats; + unsigned int n_stats; + unsigned int sz_str; + unsigned int i; + int err;
drvinfo.cmd = ETHTOOL_GDRVINFO; ifr->ifr_data = (void *)&drvinfo; @@ -91,8 +95,9 @@ out: static int statistics(struct state *state, int argc __maybe_unused, char **argv __maybe_unused) { + int ret = EXIT_FAILURE; struct ifreq ifr; - int fd = -1, ret = EXIT_FAILURE; + int fd = -1;
memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, state->mesh_iface, sizeof(ifr.ifr_name)); diff --git a/sys.c b/sys.c index f1dc275..7c39988 100644 --- a/sys.c +++ b/sys.c @@ -71,8 +71,8 @@ int sys_simple_nlquery(struct state *state, enum batadv_nl_commands nl_cmd, nl_recvmsg_msg_cb_t attribute_cb, nl_recvmsg_msg_cb_t callback) { - int result; struct nl_msg *msg; + int result; int ret;
if (!state->sock) diff --git a/tcpdump.c b/tcpdump.c index bed0243..b60922b 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -153,10 +153,11 @@ 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; - unsigned short num_vlan, num_entry; + unsigned short num_entry; + unsigned short num_vlan; const char *type; size_t vlan_len; + int i;
LEN_CHECK(buff_len, sizeof(*tvlv), "TVLV TTv1")
@@ -378,8 +379,10 @@ static void dump_batman_ucast_tvlv(unsigned char *packet_buff, ssize_t buff_len, { struct batadv_unicast_tvlv_packet *tvlv_packet; struct ether_header *ether_header; - struct ether_addr *src, *dst; - ssize_t check_len, tvlv_len; + struct ether_addr *src; + struct ether_addr *dst; + ssize_t check_len; + ssize_t tvlv_len;
check_len = (size_t)buff_len - sizeof(struct ether_header);
@@ -414,7 +417,8 @@ static int dump_bla2_claim(struct ether_header *eth_hdr, uint8_t bla_claim_magic[3] = {0xff, 0x43, 0x05}; struct batadv_bla_claim_dst *bla_dst; int arp_is_bla2_claim = 0; - uint8_t *hw_src, *hw_dst; + uint8_t *hw_src; + uint8_t *hw_dst;
if (arphdr->ea_hdr.ar_hrd != htons(ARPHRD_ETHER)) goto out; @@ -570,14 +574,14 @@ static void dump_udp(const char ip_string[], unsigned char *packet_buff, static void dump_ipv6(unsigned char *packet_buff, ssize_t buff_len, int time_printed) { - struct ip6_hdr *iphdr; - struct icmp6_hdr *icmphdr; - - char ipsrc[INET6_ADDRSTRLEN], ipdst[INET6_ADDRSTRLEN]; struct nd_neighbor_solicit *nd_neigh_sol; struct nd_neighbor_advert *nd_advert; char nd_nas_target[INET6_ADDRSTRLEN]; const char ip_string[] = "IP6"; + char ipsrc[INET6_ADDRSTRLEN]; + char ipdst[INET6_ADDRSTRLEN]; + struct icmp6_hdr *icmphdr; + struct ip6_hdr *iphdr;
iphdr = (struct ip6_hdr *)packet_buff; LEN_CHECK((size_t)buff_len, (size_t)(sizeof(struct ip6_hdr)), ip_string); @@ -691,11 +695,13 @@ static void dump_ipv6(unsigned char *packet_buff, ssize_t buff_len, static void dump_ip(unsigned char *packet_buff, ssize_t buff_len, int time_printed) { - char ipsrc[INET_ADDRSTRLEN], ipdst[INET_ADDRSTRLEN]; - struct iphdr *iphdr, *tmp_iphdr; const char ip_string[] = "IP"; + char ipsrc[INET_ADDRSTRLEN]; + char ipdst[INET_ADDRSTRLEN]; struct udphdr *tmp_udphdr; struct icmphdr *icmphdr; + struct iphdr *tmp_iphdr; + struct iphdr *iphdr;
iphdr = (struct iphdr *)packet_buff; LEN_CHECK((size_t)buff_len, sizeof(*iphdr), ip_string); @@ -813,7 +819,8 @@ static void dump_batman_iv_ogm(unsigned char *packet_buff, ssize_t buff_len, int { struct ether_header *ether_header; struct batadv_ogm_packet *batman_ogm_packet; - ssize_t tvlv_len, check_len; + ssize_t check_len; + ssize_t tvlv_len;
check_len = (size_t)buff_len - sizeof(struct ether_header); LEN_CHECK(check_len, sizeof(struct batadv_ogm_packet), "BAT IV OGM"); @@ -849,8 +856,9 @@ static void dump_batman_ogm2(unsigned char *packet_buff, ssize_t buff_len, struct batadv_ogm2_packet *batman_ogm2; struct ether_header *ether_header; struct ether_addr *ether_addr; - ssize_t tvlv_len, check_len; uint32_t throughput; + ssize_t check_len; + ssize_t tvlv_len; char thr_str[20];
check_len = (size_t)buff_len - sizeof(struct ether_header); @@ -976,8 +984,8 @@ 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 batadv_unicast_packet *unicast_packet; + struct ether_header *ether_header;
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), @@ -1027,8 +1035,8 @@ static void dump_batman_ucast_frag(unsigned char *packet_buff, ssize_t buff_len,
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 batadv_bcast_packet *bcast_packet; + struct ether_header *ether_header;
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), @@ -1131,8 +1139,8 @@ static void dump_batman_coded(unsigned char *packet_buff, ssize_t buff_len, int
static void dump_batman_4addr(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed) { - struct ether_header *ether_header; struct batadv_unicast_4addr_packet *unicast_4addr_packet; + struct ether_header *ether_header;
LEN_CHECK((size_t)buff_len - sizeof(struct ether_header), sizeof(struct batadv_unicast_4addr_packet), "BAT 4ADDR"); LEN_CHECK((size_t)buff_len - sizeof(struct ether_header) - sizeof(struct batadv_unicast_4addr_packet), @@ -1258,6 +1266,7 @@ static void parse_eth_hdr(unsigned char *packet_buff, ssize_t buff_len, int read static int monitor_header_length(unsigned char *packet_buff, ssize_t buff_len, int32_t hw_type) { struct radiotap_header *radiotap_hdr; + switch (hw_type) { case ARPHRD_IEEE80211_PRISM: if (buff_len <= (ssize_t)PRISM_HEADER_LEN) @@ -1281,9 +1290,10 @@ static int monitor_header_length(unsigned char *packet_buff, ssize_t buff_len, i
static void parse_wifi_hdr(unsigned char *packet_buff, ssize_t buff_len, int read_opt, int time_printed) { - struct ether_header *eth_hdr; struct ieee80211_hdr *wifi_hdr; - unsigned char *shost, *dhost; + struct ether_header *eth_hdr; + unsigned char *shost; + unsigned char *dhost; uint16_t fc; int hdr_len;
@@ -1434,15 +1444,22 @@ static void sig_handler(int sig)
static int tcpdump(struct state *state __maybe_unused, int argc, char **argv) { - struct timeval tv; - struct dump_if *dump_if, *dump_if_tmp; + unsigned char packet_buff[2000]; struct list_head dump_if_list; - fd_set wait_sockets, tmp_wait_sockets; - ssize_t read_len; - int ret = EXIT_FAILURE, res, optchar, found_args = 1, max_sock = 0, tmp; int read_opt = USE_BAT_HOSTS; - unsigned char packet_buff[2000]; int monitor_header_len = -1; + struct dump_if *dump_if_tmp; + struct dump_if *dump_if; + fd_set tmp_wait_sockets; + int ret = EXIT_FAILURE; + fd_set wait_sockets; + int found_args = 1; + struct timeval tv; + int max_sock = 0; + ssize_t read_len; + int optchar; + int res; + int tmp;
dump_level = dump_level_all;
diff --git a/throughputmeter.c b/throughputmeter.c index 16016e7..e5562e5 100644 --- a/throughputmeter.c +++ b/throughputmeter.c @@ -116,9 +116,9 @@ static int tp_meter_result_callback(struct nl_msg *msg, void *arg)
static int tp_meter_cookie_callback(struct nl_msg *msg, void *arg) { - struct tp_cookie *cookie = arg; - struct nlmsghdr *nlh = nlmsg_hdr(msg); struct nlattr *attrs[NUM_BATADV_ATTR]; + struct nlmsghdr *nlh = nlmsg_hdr(msg); + struct tp_cookie *cookie = arg; struct genlmsghdr *ghdr;
if (!genlmsg_valid_hdr(nlh, 0)) { @@ -197,8 +197,8 @@ static int no_seq_check(struct nl_msg *msg __maybe_unused,
static int tp_recv_result(struct nl_sock *sock, struct tp_result *result) { - int err = 0; struct nl_cb *cb; + int err = 0;
cb = nl_cb_alloc(NL_CB_DEFAULT); nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL); @@ -310,14 +310,8 @@ static void tp_meter_usage(void)
static int throughputmeter(struct state *state, int argc, char **argv) { - struct bat_host *bat_host; - uint64_t throughput; - char *dst_string; - int ret = EXIT_FAILURE; - int found_args = 1, read_opt = USE_BAT_HOSTS; - uint32_t time = 0; - int optchar; struct nl_sock *listen_sock = NULL; + int read_opt = USE_BAT_HOSTS; struct tp_result result = { .error = 0, .return_value = 0, @@ -330,6 +324,13 @@ static int throughputmeter(struct state *state, int argc, char **argv) .cookie = 0, .found = false, }; + struct bat_host *bat_host; + int ret = EXIT_FAILURE; + uint64_t throughput; + int found_args = 1; + uint32_t time = 0; + char *dst_string; + int optchar;
while ((optchar = getopt(argc, argv, "t:n")) != -1) { switch (optchar) { diff --git a/traceroute.c b/traceroute.c index d63ae87..63519d5 100644 --- a/traceroute.c +++ b/traceroute.c @@ -42,16 +42,25 @@ static void traceroute_usage(void)
static int traceroute(struct state *state, int argc, char **argv) { - struct batadv_icmp_packet icmp_packet_out, icmp_packet_in; - struct bat_host *bat_host; + struct batadv_icmp_packet icmp_packet_out; + struct batadv_icmp_packet icmp_packet_in; struct ether_addr *dst_mac = NULL; - struct timeval tv; - ssize_t read_len; - char *dst_string, *mac_string, *return_mac, dst_reached = 0; - int ret = EXIT_FAILURE, res, i; - int found_args = 1, optchar, seq_counter = 0, read_opt = USE_BAT_HOSTS; double time_delta[NUM_PACKETS]; int disable_translate_mac = 0; + int read_opt = USE_BAT_HOSTS; + struct bat_host *bat_host; + int ret = EXIT_FAILURE; + char dst_reached = 0; + int seq_counter = 0; + int found_args = 1; + struct timeval tv; + ssize_t read_len; + char *dst_string; + char *mac_string; + char *return_mac; + int optchar; + int res; + int i;
while ((optchar = getopt(argc, argv, "hnT")) != -1) { switch (optchar) { diff --git a/translate.c b/translate.c index 92451c9..ada6ba8 100644 --- a/translate.c +++ b/translate.c @@ -24,7 +24,8 @@ static int translate(struct state *state, int argc, char **argv) struct ether_addr *dst_mac = NULL; struct bat_host *bat_host; int ret = EXIT_FAILURE; - char *dst_string, *mac_string; + char *dst_string; + char *mac_string;
if (argc <= 1) { fprintf(stderr, "Error - destination not specified\n"); diff --git a/translocal.c b/translocal.c index 2fbae01..eb4682e 100644 --- a/translocal.c +++ b/translocal.c @@ -31,17 +31,23 @@ static const int translocal_mandatory[] = {
static int translocal_callback(struct nl_msg *msg, void *arg) { - int last_seen_msecs = 0, last_seen_secs = 0; struct nlattr *attrs[BATADV_ATTR_MAX+1]; struct nlmsghdr *nlh = nlmsg_hdr(msg); struct print_opts *opts = arg; struct bat_host *bat_host; struct genlmsghdr *ghdr; - char r, p, n, x, w, i; - uint8_t *addr; - int16_t vid; + int last_seen_msecs = 0; + int last_seen_secs = 0; uint32_t crc32; uint32_t flags; + uint8_t *addr; + int16_t vid; + char r; + char p; + char n; + char x; + char w; + char i;
if (!genlmsg_valid_hdr(nlh, 0)) { fputs("Received invalid data from kernel.\n", stderr);