00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef WPS_UPNP_I_H
00012 #define WPS_UPNP_I_H
00013
00014 #include "utils/list.h"
00015 #include "http.h"
00016
00017 #define UPNP_MULTICAST_ADDRESS "239.255.255.250"
00018 #define UPNP_MULTICAST_PORT 1900
00019
00020
00021 #define UPNP_SUBSCRIBE_SEC_MIN 1800
00022
00023 #define UPNP_SUBSCRIBE_SEC (UPNP_SUBSCRIBE_SEC_MIN + 1)
00024
00025
00026 #define UPNP_WPS_DEVICE_XML_FILE "wps_device.xml"
00027 #define UPNP_WPS_SCPD_XML_FILE "wps_scpd.xml"
00028 #define UPNP_WPS_DEVICE_CONTROL_FILE "wps_control"
00029 #define UPNP_WPS_DEVICE_EVENT_FILE "wps_event"
00030
00031 #define MULTICAST_MAX_READ 1600
00032
00033
00034 struct upnp_wps_device_sm;
00035 struct wps_registrar;
00036
00037
00038 enum advertisement_type_enum {
00039 ADVERTISE_UP = 0,
00040 ADVERTISE_DOWN = 1,
00041 MSEARCH_REPLY = 2
00042 };
00043
00044
00045
00046
00047
00048
00049
00050
00051 struct advertisement_state_machine {
00052 struct dl_list list;
00053 enum advertisement_type_enum type;
00054 int state;
00055 int nerrors;
00056 struct sockaddr_in client;
00057 };
00058
00059
00060
00061
00062
00063
00064
00065 struct subscr_addr {
00066 struct dl_list list;
00067 char *domain_and_port;
00068 char *path;
00069 struct sockaddr_in saddr;
00070 };
00071
00072
00073
00074
00075
00076
00077
00078 struct subscription {
00079 struct dl_list list;
00080 struct upnp_wps_device_sm *sm;
00081 time_t timeout_time;
00082 unsigned next_subscriber_sequence;
00083
00084
00085
00086
00087
00088 u8 uuid[UUID_LEN];
00089
00090 struct dl_list addr_list;
00091 struct dl_list event_queue;
00092 struct wps_event_ *current_event;
00093
00094
00095
00096 u8 selected_registrar;
00097 u16 dev_password_id;
00098 u16 config_methods;
00099 struct wps_registrar *reg;
00100 };
00101
00102
00103
00104
00105
00106
00107
00108
00109 struct upnp_wps_device_sm {
00110 struct upnp_wps_device_ctx *ctx;
00111 struct wps_context *wps;
00112 void *priv;
00113 char *root_dir;
00114 char *desc_url;
00115 int started;
00116 u8 mac_addr[ETH_ALEN];
00117 char *ip_addr_text;
00118 unsigned ip_addr;
00119 int multicast_sd;
00120 int ssdp_sd;
00121 int ssdp_sd_registered;
00122 unsigned advertise_count;
00123 struct advertisement_state_machine advertisement;
00124 struct dl_list msearch_replies;
00125 int web_port;
00126 struct http_server *web_srv;
00127
00128 struct dl_list subscriptions;
00129 int event_send_all_queued;
00130
00131
00132 char *wlanevent;
00133
00134
00135 struct upnp_wps_peer peer;
00136 };
00137
00138
00139 void format_date(struct wpabuf *buf);
00140 struct subscription * subscription_start(struct upnp_wps_device_sm *sm,
00141 const char *callback_urls);
00142 struct subscription * subscription_renew(struct upnp_wps_device_sm *sm,
00143 const u8 uuid[UUID_LEN]);
00144 void subscription_destroy(struct subscription *s);
00145 struct subscription * subscription_find(struct upnp_wps_device_sm *sm,
00146 const u8 uuid[UUID_LEN]);
00147 int send_wpabuf(int fd, struct wpabuf *buf);
00148 int get_netif_info(const char *net_if, unsigned *ip_addr, char **ip_addr_text,
00149 u8 mac[ETH_ALEN]);
00150
00151
00152 void msearchreply_state_machine_stop(struct advertisement_state_machine *a);
00153 int advertisement_state_machine_start(struct upnp_wps_device_sm *sm);
00154 void advertisement_state_machine_stop(struct upnp_wps_device_sm *sm,
00155 int send_byebye);
00156 void ssdp_listener_stop(struct upnp_wps_device_sm *sm);
00157 int ssdp_listener_start(struct upnp_wps_device_sm *sm);
00158 int ssdp_listener_open(void);
00159 int add_ssdp_network(const char *net_if);
00160 int ssdp_open_multicast_sock(u32 ip_addr);
00161 int ssdp_open_multicast(struct upnp_wps_device_sm *sm);
00162
00163
00164 int web_listener_start(struct upnp_wps_device_sm *sm);
00165 void web_listener_stop(struct upnp_wps_device_sm *sm);
00166
00167
00168 int event_add(struct subscription *s, const struct wpabuf *data);
00169 void event_delete_all(struct subscription *s);
00170 void event_send_all_later(struct upnp_wps_device_sm *sm);
00171 void event_send_stop_all(struct upnp_wps_device_sm *sm);
00172
00173
00174 int upnp_er_set_selected_registrar(struct wps_registrar *reg,
00175 struct subscription *s,
00176 const struct wpabuf *msg);
00177 void upnp_er_remove_notification(struct subscription *s);
00178
00179 #endif