41 static inline uint32_t prefix_len_mask(uint8_t len);
46 static size_t routing_table_len = 0;
55 routing_table_len = 1;
56 for (cr = config.
routes; cr != NULL; routing_table_len++, cr = cr->
next);
59 if ((routing_table = calloc(routing_table_len,
sizeof(*routing_table)))
62 fprintf(stderr,
"routing_init: allocating routing table failed\n");
68 routing_table[0].
dest_ip = config.
ip & mask;
73 for (i = 1, cr = config.
routes; cr != NULL; i++, cr = cr->
next) {
75 if ((mask & cr->
ip) != cr->
ip) {
76 fprintf(stderr,
"routing_init: mask removes non-0 bits " 96 fprintf(stderr,
"routing_resolve: routing failed\n");
110 static inline uint32_t prefix_len_mask(uint8_t len)
112 return ~((1ULL << (32 - len)) - 1);
119 for (i = 0; i < routing_table_len; i++) {
121 return &routing_table[i];
int arp_request(struct nicif_completion *comp, uint32_t ip, uint64_t *mac)
struct config_route * routes
struct config_route * next
int routing_resolve(struct nicif_completion *comp, uint32_t ip, uint64_t *mac)