Lines 29-34
Link Here
|
29 |
#include <sys/socket.h> |
29 |
#include <sys/socket.h> |
30 |
#include <arpa/inet.h> |
30 |
#include <arpa/inet.h> |
31 |
|
31 |
|
|
|
32 |
#include "private.h" |
32 |
#include "util.h" |
33 |
#include "util.h" |
33 |
#include "netlink.h" |
34 |
#include "netlink.h" |
34 |
#include "log.h" |
35 |
#include "log.h" |
Lines 132-138
static void l_rtnl_route_extract(const struct rtmsg *rtmsg, uint32_t len,
Link Here
|
132 |
} |
133 |
} |
133 |
} |
134 |
} |
134 |
|
135 |
|
135 |
uint32_t l_rtnl_set_linkmode_and_operstate(struct l_netlink *rtnl, int ifindex, |
136 |
LIB_EXPORT uint32_t l_rtnl_set_linkmode_and_operstate(struct l_netlink *rtnl, int ifindex, |
136 |
uint8_t linkmode, uint8_t operstate, |
137 |
uint8_t linkmode, uint8_t operstate, |
137 |
l_netlink_command_func_t cb, |
138 |
l_netlink_command_func_t cb, |
138 |
void *user_data, |
139 |
void *user_data, |
Lines 165-171
uint32_t l_rtnl_set_linkmode_and_operstate(struct l_netlink *rtnl, int ifindex,
Link Here
|
165 |
return id; |
166 |
return id; |
166 |
} |
167 |
} |
167 |
|
168 |
|
168 |
uint32_t l_rtnl_set_mac(struct l_netlink *rtnl, int ifindex, |
169 |
LIB_EXPORT uint32_t l_rtnl_set_mac(struct l_netlink *rtnl, int ifindex, |
169 |
const uint8_t addr[static 6], |
170 |
const uint8_t addr[static 6], |
170 |
bool power_up, |
171 |
bool power_up, |
171 |
l_netlink_command_func_t cb, |
172 |
l_netlink_command_func_t cb, |
Lines 202-208
uint32_t l_rtnl_set_mac(struct l_netlink *rtnl, int ifindex,
Link Here
|
202 |
return id; |
203 |
return id; |
203 |
} |
204 |
} |
204 |
|
205 |
|
205 |
uint32_t l_rtnl_set_powered(struct l_netlink *rtnl, int ifindex, bool powered, |
206 |
LIB_EXPORT uint32_t l_rtnl_set_powered(struct l_netlink *rtnl, int ifindex, bool powered, |
206 |
l_netlink_command_func_t cb, void *user_data, |
207 |
l_netlink_command_func_t cb, void *user_data, |
207 |
l_netlink_destroy_func_t destroy) |
208 |
l_netlink_destroy_func_t destroy) |
208 |
{ |
209 |
{ |
Lines 227-233
uint32_t l_rtnl_set_powered(struct l_netlink *rtnl, int ifindex, bool powered,
Link Here
|
227 |
return id; |
228 |
return id; |
228 |
} |
229 |
} |
229 |
|
230 |
|
230 |
void l_rtnl_ifaddr4_extract(const struct ifaddrmsg *ifa, int bytes, |
231 |
LIB_EXPORT void l_rtnl_ifaddr4_extract(const struct ifaddrmsg *ifa, int bytes, |
231 |
char **label, char **ip, char **broadcast) |
232 |
char **label, char **ip, char **broadcast) |
232 |
{ |
233 |
{ |
233 |
struct in_addr in_addr; |
234 |
struct in_addr in_addr; |
Lines 262-268
void l_rtnl_ifaddr4_extract(const struct ifaddrmsg *ifa, int bytes,
Link Here
|
262 |
} |
263 |
} |
263 |
} |
264 |
} |
264 |
|
265 |
|
265 |
uint32_t l_rtnl_ifaddr4_dump(struct l_netlink *rtnl, l_netlink_command_func_t cb, |
266 |
LIB_EXPORT uint32_t l_rtnl_ifaddr4_dump(struct l_netlink *rtnl, l_netlink_command_func_t cb, |
266 |
void *user_data, |
267 |
void *user_data, |
267 |
l_netlink_destroy_func_t destroy) |
268 |
l_netlink_destroy_func_t destroy) |
268 |
{ |
269 |
{ |
Lines 283-289
uint32_t l_rtnl_ifaddr4_dump(struct l_netlink *rtnl, l_netlink_command_func_t cb
Link Here
|
283 |
return id; |
284 |
return id; |
284 |
} |
285 |
} |
285 |
|
286 |
|
286 |
static uint32_t l_rtnl_ifaddr4_change(struct l_netlink *rtnl, uint16_t nlmsg_type, |
287 |
LIB_EXPORT static uint32_t l_rtnl_ifaddr4_change(struct l_netlink *rtnl, uint16_t nlmsg_type, |
287 |
int ifindex, uint8_t prefix_len, |
288 |
int ifindex, uint8_t prefix_len, |
288 |
const char *ip, const char *broadcast, |
289 |
const char *ip, const char *broadcast, |
289 |
l_netlink_command_func_t |
290 |
l_netlink_command_func_t |
Lines 340-346
static uint32_t l_rtnl_ifaddr4_change(struct l_netlink *rtnl, uint16_t nlmsg_typ
Link Here
|
340 |
return id; |
341 |
return id; |
341 |
} |
342 |
} |
342 |
|
343 |
|
343 |
uint32_t l_rtnl_ifaddr4_add(struct l_netlink *rtnl, int ifindex, |
344 |
LIB_EXPORT uint32_t l_rtnl_ifaddr4_add(struct l_netlink *rtnl, int ifindex, |
344 |
uint8_t prefix_len, const char *ip, |
345 |
uint8_t prefix_len, const char *ip, |
345 |
const char *broadcast, |
346 |
const char *broadcast, |
346 |
l_netlink_command_func_t cb, void *user_data, |
347 |
l_netlink_command_func_t cb, void *user_data, |
Lines 350-356
uint32_t l_rtnl_ifaddr4_add(struct l_netlink *rtnl, int ifindex,
Link Here
|
350 |
broadcast, cb, user_data, destroy); |
351 |
broadcast, cb, user_data, destroy); |
351 |
} |
352 |
} |
352 |
|
353 |
|
353 |
uint32_t l_rtnl_ifaddr4_delete(struct l_netlink *rtnl, int ifindex, |
354 |
LIB_EXPORT uint32_t l_rtnl_ifaddr4_delete(struct l_netlink *rtnl, int ifindex, |
354 |
uint8_t prefix_len, const char *ip, |
355 |
uint8_t prefix_len, const char *ip, |
355 |
const char *broadcast, |
356 |
const char *broadcast, |
356 |
l_netlink_command_func_t cb, void *user_data, |
357 |
l_netlink_command_func_t cb, void *user_data, |
Lines 360-366
uint32_t l_rtnl_ifaddr4_delete(struct l_netlink *rtnl, int ifindex,
Link Here
|
360 |
broadcast, cb, user_data, destroy); |
361 |
broadcast, cb, user_data, destroy); |
361 |
} |
362 |
} |
362 |
|
363 |
|
363 |
void l_rtnl_route4_extract(const struct rtmsg *rtmsg, uint32_t len, |
364 |
LIB_EXPORT void l_rtnl_route4_extract(const struct rtmsg *rtmsg, uint32_t len, |
364 |
uint32_t *table, uint32_t *ifindex, |
365 |
uint32_t *table, uint32_t *ifindex, |
365 |
char **dst, char **gateway, char **src) |
366 |
char **dst, char **gateway, char **src) |
366 |
{ |
367 |
{ |
Lines 368-374
void l_rtnl_route4_extract(const struct rtmsg *rtmsg, uint32_t len,
Link Here
|
368 |
NULL, NULL, dst, gateway, src); |
369 |
NULL, NULL, dst, gateway, src); |
369 |
} |
370 |
} |
370 |
|
371 |
|
371 |
uint32_t l_rtnl_route4_dump(struct l_netlink *rtnl, |
372 |
LIB_EXPORT uint32_t l_rtnl_route4_dump(struct l_netlink *rtnl, |
372 |
l_netlink_command_func_t cb, void *user_data, |
373 |
l_netlink_command_func_t cb, void *user_data, |
373 |
l_netlink_destroy_func_t destroy) |
374 |
l_netlink_destroy_func_t destroy) |
374 |
{ |
375 |
{ |
Lines 382-388
uint32_t l_rtnl_route4_dump(struct l_netlink *rtnl,
Link Here
|
382 |
destroy); |
383 |
destroy); |
383 |
} |
384 |
} |
384 |
|
385 |
|
385 |
static uint32_t l_rtnl_route4_add(struct l_netlink *rtnl, int ifindex, |
386 |
LIB_EXPORT static uint32_t l_rtnl_route4_add(struct l_netlink *rtnl, int ifindex, |
386 |
uint8_t scope, uint8_t dst_len, |
387 |
uint8_t scope, uint8_t dst_len, |
387 |
const char *dst, const char *gateway, |
388 |
const char *dst, const char *gateway, |
388 |
const char *src, |
389 |
const char *src, |
Lines 456-462
static uint32_t l_rtnl_route4_add(struct l_netlink *rtnl, int ifindex,
Link Here
|
456 |
destroy); |
457 |
destroy); |
457 |
} |
458 |
} |
458 |
|
459 |
|
459 |
uint32_t l_rtnl_route4_add_connected(struct l_netlink *rtnl, int ifindex, |
460 |
LIB_EXPORT uint32_t l_rtnl_route4_add_connected(struct l_netlink *rtnl, int ifindex, |
460 |
uint8_t dst_len, const char *dst, |
461 |
uint8_t dst_len, const char *dst, |
461 |
const char *src, uint8_t proto, |
462 |
const char *src, uint8_t proto, |
462 |
l_netlink_command_func_t cb, |
463 |
l_netlink_command_func_t cb, |
Lines 467-473
uint32_t l_rtnl_route4_add_connected(struct l_netlink *rtnl, int ifindex,
Link Here
|
467 |
src, 0, proto, cb, user_data, destroy); |
468 |
src, 0, proto, cb, user_data, destroy); |
468 |
} |
469 |
} |
469 |
|
470 |
|
470 |
uint32_t l_rtnl_route4_add_gateway(struct l_netlink *rtnl, int ifindex, |
471 |
LIB_EXPORT uint32_t l_rtnl_route4_add_gateway(struct l_netlink *rtnl, int ifindex, |
471 |
const char *gateway, const char *src, |
472 |
const char *gateway, const char *src, |
472 |
uint32_t priority_offset, |
473 |
uint32_t priority_offset, |
473 |
uint8_t proto, |
474 |
uint8_t proto, |
Lines 480-486
uint32_t l_rtnl_route4_add_gateway(struct l_netlink *rtnl, int ifindex,
Link Here
|
480 |
user_data, destroy); |
481 |
user_data, destroy); |
481 |
} |
482 |
} |
482 |
|
483 |
|
483 |
void l_rtnl_ifaddr6_extract(const struct ifaddrmsg *ifa, int len, char **ip) |
484 |
LIB_EXPORT void l_rtnl_ifaddr6_extract(const struct ifaddrmsg *ifa, int len, char **ip) |
484 |
{ |
485 |
{ |
485 |
struct in6_addr in6_addr; |
486 |
struct in6_addr in6_addr; |
486 |
struct rtattr *attr; |
487 |
struct rtattr *attr; |
Lines 510-516
void l_rtnl_ifaddr6_extract(const struct ifaddrmsg *ifa, int len, char **ip)
Link Here
|
510 |
} |
511 |
} |
511 |
} |
512 |
} |
512 |
|
513 |
|
513 |
uint32_t l_rtnl_ifaddr6_dump(struct l_netlink *rtnl, |
514 |
LIB_EXPORT uint32_t l_rtnl_ifaddr6_dump(struct l_netlink *rtnl, |
514 |
l_netlink_command_func_t cb, void *user_data, |
515 |
l_netlink_command_func_t cb, void *user_data, |
515 |
l_netlink_destroy_func_t destroy) |
516 |
l_netlink_destroy_func_t destroy) |
516 |
{ |
517 |
{ |
Lines 531-537
uint32_t l_rtnl_ifaddr6_dump(struct l_netlink *rtnl,
Link Here
|
531 |
return id; |
532 |
return id; |
532 |
} |
533 |
} |
533 |
|
534 |
|
534 |
static uint32_t l_rtnl_ifaddr6_change(struct l_netlink *rtnl, |
535 |
LIB_EXPORT static uint32_t l_rtnl_ifaddr6_change(struct l_netlink *rtnl, |
535 |
uint16_t nlmsg_type, |
536 |
uint16_t nlmsg_type, |
536 |
int ifindex, uint8_t prefix_len, |
537 |
int ifindex, uint8_t prefix_len, |
537 |
const char *ip, |
538 |
const char *ip, |
Lines 575-581
static uint32_t l_rtnl_ifaddr6_change(struct l_netlink *rtnl,
Link Here
|
575 |
return id; |
576 |
return id; |
576 |
} |
577 |
} |
577 |
|
578 |
|
578 |
uint32_t l_rtnl_ifaddr6_add(struct l_netlink *rtnl, int ifindex, |
579 |
LIB_EXPORT uint32_t l_rtnl_ifaddr6_add(struct l_netlink *rtnl, int ifindex, |
579 |
uint8_t prefix_len, const char *ip, |
580 |
uint8_t prefix_len, const char *ip, |
580 |
l_netlink_command_func_t cb, void *user_data, |
581 |
l_netlink_command_func_t cb, void *user_data, |
581 |
l_netlink_destroy_func_t destroy) |
582 |
l_netlink_destroy_func_t destroy) |
Lines 584-590
uint32_t l_rtnl_ifaddr6_add(struct l_netlink *rtnl, int ifindex,
Link Here
|
584 |
ip, cb, user_data, destroy); |
585 |
ip, cb, user_data, destroy); |
585 |
} |
586 |
} |
586 |
|
587 |
|
587 |
uint32_t l_rtnl_ifaddr6_delete(struct l_netlink *rtnl, int ifindex, |
588 |
LIB_EXPORT uint32_t l_rtnl_ifaddr6_delete(struct l_netlink *rtnl, int ifindex, |
588 |
uint8_t prefix_len, const char *ip, |
589 |
uint8_t prefix_len, const char *ip, |
589 |
l_netlink_command_func_t cb, |
590 |
l_netlink_command_func_t cb, |
590 |
void *user_data, |
591 |
void *user_data, |
Lines 594-600
uint32_t l_rtnl_ifaddr6_delete(struct l_netlink *rtnl, int ifindex,
Link Here
|
594 |
ip, cb, user_data, destroy); |
595 |
ip, cb, user_data, destroy); |
595 |
} |
596 |
} |
596 |
|
597 |
|
597 |
void l_rtnl_route6_extract(const struct rtmsg *rtmsg, uint32_t len, |
598 |
LIB_EXPORT void l_rtnl_route6_extract(const struct rtmsg *rtmsg, uint32_t len, |
598 |
uint32_t *table, uint32_t *ifindex, |
599 |
uint32_t *table, uint32_t *ifindex, |
599 |
char **dst, char **gateway, char **src) |
600 |
char **dst, char **gateway, char **src) |
600 |
{ |
601 |
{ |
Lines 602-608
void l_rtnl_route6_extract(const struct rtmsg *rtmsg, uint32_t len,
Link Here
|
602 |
NULL, NULL, dst, gateway, src); |
603 |
NULL, NULL, dst, gateway, src); |
603 |
} |
604 |
} |
604 |
|
605 |
|
605 |
uint32_t l_rtnl_route6_dump(struct l_netlink *rtnl, |
606 |
LIB_EXPORT uint32_t l_rtnl_route6_dump(struct l_netlink *rtnl, |
606 |
l_netlink_command_func_t cb, void *user_data, |
607 |
l_netlink_command_func_t cb, void *user_data, |
607 |
l_netlink_destroy_func_t destroy) |
608 |
l_netlink_destroy_func_t destroy) |
608 |
{ |
609 |
{ |
Lines 616-622
uint32_t l_rtnl_route6_dump(struct l_netlink *rtnl,
Link Here
|
616 |
destroy); |
617 |
destroy); |
617 |
} |
618 |
} |
618 |
|
619 |
|
619 |
static uint32_t l_rtnl_route6_change(struct l_netlink *rtnl, |
620 |
LIB_EXPORT static uint32_t l_rtnl_route6_change(struct l_netlink *rtnl, |
620 |
uint16_t nlmsg_type, int ifindex, |
621 |
uint16_t nlmsg_type, int ifindex, |
621 |
const char *gateway, |
622 |
const char *gateway, |
622 |
uint32_t priority_offset, |
623 |
uint32_t priority_offset, |
Lines 670-676
static uint32_t l_rtnl_route6_change(struct l_netlink *rtnl,
Link Here
|
670 |
destroy); |
671 |
destroy); |
671 |
} |
672 |
} |
672 |
|
673 |
|
673 |
uint32_t l_rtnl_route6_add_gateway(struct l_netlink *rtnl, int ifindex, |
674 |
LIB_EXPORT uint32_t l_rtnl_route6_add_gateway(struct l_netlink *rtnl, int ifindex, |
674 |
const char *gateway, |
675 |
const char *gateway, |
675 |
uint32_t priority_offset, |
676 |
uint32_t priority_offset, |
676 |
uint8_t proto, |
677 |
uint8_t proto, |
Lines 683-689
uint32_t l_rtnl_route6_add_gateway(struct l_netlink *rtnl, int ifindex,
Link Here
|
683 |
user_data, destroy); |
684 |
user_data, destroy); |
684 |
} |
685 |
} |
685 |
|
686 |
|
686 |
uint32_t l_rtnl_route6_delete_gateway(struct l_netlink *rtnl, int ifindex, |
687 |
LIB_EXPORT uint32_t l_rtnl_route6_delete_gateway(struct l_netlink *rtnl, int ifindex, |
687 |
const char *gateway, |
688 |
const char *gateway, |
688 |
uint32_t priority_offset, |
689 |
uint32_t priority_offset, |
689 |
uint8_t proto, |
690 |
uint8_t proto, |