wireless.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * netifd - network interface daemon
  3. * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2
  7. * as published by the Free Software Foundation
  8. *
  9. * This program 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. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef __NETIFD_WIRELESS_H
  15. #define __NETIFD_WIRELESS_H
  16. #include <libubox/utils.h>
  17. #include <libubox/list.h>
  18. #include "interface.h"
  19. extern struct vlist_tree wireless_devices;
  20. extern struct avl_tree wireless_drivers;
  21. struct wireless_driver {
  22. struct avl_node node;
  23. const char *name;
  24. const char *script;
  25. struct {
  26. char *buf;
  27. struct uci_blob_param_list *config;
  28. } device, interface, vlan, station;
  29. };
  30. struct wireless_device {
  31. struct vlist_node node;
  32. struct list_head handler;
  33. bool handler_action;
  34. bool handler_pending;
  35. bool serialize;
  36. bool config_update;
  37. struct wireless_driver *drv;
  38. struct vlist_tree interfaces;
  39. char *name;
  40. struct netifd_process script_task;
  41. struct uloop_timeout timeout;
  42. struct uloop_timeout poll;
  43. struct list_head script_proc;
  44. struct uloop_fd script_proc_fd;
  45. struct uloop_timeout script_check;
  46. struct ubus_request_data *kill_request;
  47. struct blob_attr *prev_config;
  48. struct blob_attr *config;
  49. struct blob_attr *data;
  50. bool autostart;
  51. bool disabled;
  52. bool retry_setup_failed;
  53. enum interface_state state;
  54. enum interface_config_state config_state;
  55. bool reconf;
  56. bool cancel;
  57. int retry;
  58. int vif_idx;
  59. };
  60. struct wireless_interface {
  61. struct vlist_node node;
  62. const char *section;
  63. char *name;
  64. struct vlist_tree vlans;
  65. struct vlist_tree stations;
  66. struct wireless_device *wdev;
  67. struct blob_attr *config;
  68. struct blob_attr *data;
  69. const char *ifname;
  70. struct blob_attr *network;
  71. struct blob_attr *network_vlan;
  72. bool proxyarp;
  73. bool isolate;
  74. bool bridge_isolate;
  75. bool ap_mode;
  76. int multicast_to_unicast;
  77. int vlan_idx;
  78. int sta_idx;
  79. bool disabled;
  80. };
  81. struct wireless_vlan {
  82. struct vlist_node node;
  83. const char *section;
  84. char *name;
  85. struct blob_attr *config;
  86. struct blob_attr *data;
  87. const char *ifname;
  88. struct blob_attr *network;
  89. struct blob_attr *network_vlan;
  90. int multicast_to_unicast;
  91. bool isolate;
  92. bool bridge_isolate;
  93. };
  94. struct wireless_station {
  95. struct vlist_node node;
  96. const char *section;
  97. char *name;
  98. struct blob_attr *config;
  99. struct blob_attr *data;
  100. };
  101. struct wireless_process {
  102. struct list_head list;
  103. const char *exe;
  104. int pid;
  105. bool required;
  106. bool keep;
  107. };
  108. void wireless_device_create(struct wireless_driver *drv, const char *name, struct blob_attr *data);
  109. void wireless_device_set_up(struct wireless_device *wdev);
  110. void wireless_device_set_down(struct wireless_device *wdev);
  111. void wireless_device_reconf(struct wireless_device *wdev);
  112. void wireless_device_status(struct wireless_device *wdev, struct blob_buf *b);
  113. void wireless_device_get_validate(struct wireless_device *wdev, struct blob_buf *b);
  114. struct wireless_interface* wireless_interface_create(struct wireless_device *wdev, struct blob_attr *data, const char *section);
  115. void wireless_vlan_create(struct wireless_interface *vif, struct blob_attr *data, const char *section);
  116. void wireless_station_create(struct wireless_interface *vif, struct blob_attr *data, const char *section);
  117. int wireless_device_notify(struct wireless_device *wdev, struct blob_attr *data,
  118. struct ubus_request_data *req);
  119. void wireless_check_network_enabled(void);
  120. void wireless_start_pending(int timeout);
  121. void wireless_init(void);
  122. void wireless_device_hotplug_event(const char *name, bool add);
  123. #endif