+/* extract my own tq to neighbor from the elp packet */ +static uint8_t bat_v_elp_fetch_tq(uint8_t *my_iface_addr,
struct batman_elp_packet *elp_packet,
int elp_packet_len)
+{
- struct elp_neigh_entry *elp_neigh_entry;
- uint8_t tq = 0;
- int i;
- elp_neigh_entry = (struct elp_neigh_entry *)(elp_packet + 1);
- elp_packet_len -= BATMAN_ELP_HLEN;
- for (i = 0; i < elp_packet->num_neighbors; i++) {
if (!compare_eth(my_iface_addr, elp_neigh_entry->addr))
goto next;
tq = elp_neigh_entry->rq;
break;
- next:
elp_packet_len -= sizeof(struct elp_neigh_entry);
if (elp_packet_len < 0)
break;
elp_neigh_entry++;
- }
Hi Marek
I'm personally not a fan of using goto like this. Reminds me of BASIC.
Could this be changed? Maybe first validate elp_packet->num_neighbors matches the packet length, and then skip elp_packet_len check in each iteration of the loop. A normal if then else should then be possible.
Thanks Andrew