wireless.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. struct wireless_driver *drv;
  37. struct vlist_tree interfaces;
  38. struct vlist_tree vlans;
  39. struct vlist_tree stations;
  40. char *name;
  41. struct netifd_process script_task;
  42. struct uloop_timeout timeout;
  43. struct uloop_timeout poll;
  44. struct list_head script_proc;
  45. struct uloop_fd script_proc_fd;
  46. struct uloop_timeout script_check;
  47. struct ubus_request_data *kill_request;
  48. struct blob_attr *prev_config;
  49. struct blob_attr *config;
  50. struct blob_attr *data;
  51. bool autostart;
  52. bool disabled;
  53. bool retry_setup_failed;
  54. enum interface_state state;
  55. enum interface_config_state config_state;
  56. bool reconf;
  57. bool cancel;
  58. int retry;
  59. int vif_idx;
  60. int vlan_idx;
  61. int sta_idx;
  62. };
  63. struct wireless_interface {
  64. struct vlist_node node;
  65. const char *section;
  66. char *name;
  67. struct wireless_device *wdev;
  68. struct blob_attr *config;
  69. struct blob_attr *data;
  70. const char *ifname;
  71. struct blob_attr *network;
  72. bool proxyarp;
  73. bool isolate;
  74. bool ap_mode;
  75. };
  76. struct wireless_vlan {
  77. struct vlist_node node;
  78. const char *section;
  79. char *name;
  80. struct wireless_device *wdev;
  81. char *vif;
  82. struct blob_attr *config;
  83. struct blob_attr *data;
  84. const char *ifname;
  85. struct blob_attr *network;
  86. bool isolate;
  87. };
  88. struct wireless_station {
  89. struct vlist_node node;
  90. const char *section;
  91. char *name;
  92. struct wireless_device *wdev;
  93. char *vif;
  94. struct blob_attr *config;
  95. struct blob_attr *data;
  96. };
  97. struct wireless_process {
  98. struct list_head list;
  99. const char *exe;
  100. int pid;
  101. bool required;
  102. bool keep;
  103. };
  104. void wireless_device_create(struct wireless_driver *drv, const char *name, struct blob_attr *data);
  105. void wireless_device_set_up(struct wireless_device *wdev);
  106. void wireless_device_set_down(struct wireless_device *wdev);
  107. void wireless_device_reconf(struct wireless_device *wdev);
  108. void wireless_device_status(struct wireless_device *wdev, struct blob_buf *b);
  109. void wireless_device_get_validate(struct wireless_device *wdev, struct blob_buf *b);
  110. struct wireless_interface* wireless_interface_create(struct wireless_device *wdev, struct blob_attr *data, const char *section);
  111. void wireless_vlan_create(struct wireless_device *wdev, char *vif, struct blob_attr *data, const char *section);
  112. void wireless_station_create(struct wireless_device *wdev, char *vif, struct blob_attr *data, const char *section);
  113. int wireless_device_notify(struct wireless_device *wdev, struct blob_attr *data,
  114. struct ubus_request_data *req);
  115. void wireless_start_pending(void);
  116. void wireless_init(void);
  117. void wireless_device_hotplug_event(const char *name, bool add);
  118. #endif