You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

if.h 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* This file is part of Netsukuku
  2. * (c) Copyright 2004 Andrea Lo Pumo aka AlpT <alpt@freaknet.org>
  3. *
  4. * This source code is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as published
  6. * by the Free Software Foundation; either version 2 of the License,
  7. * or (at your option) any later version.
  8. *
  9. * This source code is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. * Please refer to the GNU Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Public License along with
  15. * this source code; if not, write to:
  16. * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #ifndef IF_H
  19. #define IF_H
  20. #include <net/if.h>
  21. #include "inet.h"
  22. #define MAX_INTERFACES 16 /* The maximum number of network
  23. interfaces, which can be used
  24. by Netsukuku */
  25. typedef struct {
  26. char dev_name[IFNAMSIZ]; /* If name */
  27. int dev_idx; /* If index */
  28. } interface;
  29. /* from linux/ipv6.h */
  30. struct in6_ifreq {
  31. struct in6_addr ifr6_addr;
  32. uint32_t ifr6_prefixlen;
  33. int ifr6_ifindex;
  34. };
  35. int ifs_get_pos(interface * ifs, int ifs_n, interface * dev);
  36. interface *ifs_find_idx(interface * ifs, int ifs_n, int dev_idx);
  37. int ifs_find_devname(interface * ifs, int ifs_n, char *dev_name);
  38. void ifs_del(interface * ifs, int *ifs_n, int if_pos);
  39. void ifs_del_byname(interface * ifs, int *ifs_n, char *dev_name);
  40. void ifs_del_all_name(interface * ifs, int *ifs_n, char *dev_name);
  41. const char *get_dev(int *dev_idx);
  42. int set_dev_up(char *dev);
  43. int set_dev_down(char *dev);
  44. int set_flags(char *dev, u_int flags, u_int mask);
  45. int set_all_ifs(interface * ifs, int ifs_n, int (*set_func) (char *dev));
  46. int if_init_all(char *ifs_name[MAX_INTERFACES], int ifs_n,
  47. interface * new_ifs, int *new_ifs_n);
  48. void if_close_all(void);
  49. int set_all_dev_ip(inet_prefix ip, interface * ifs, int ifs_n);
  50. int set_dev_ip(inet_prefix ip, char *dev);
  51. int get_dev_ip(inet_prefix * ip, int family, char *dev);
  52. int ip_addr_flush(int family, char *dev, int scope);
  53. int ip_addr_flush_all_ifs(interface * ifs, int ifs_n, int family,
  54. int scope);
  55. #endif /*IF_H */