wps_upnp_i.h
Go to the documentation of this file.00001
00012 #ifndef WPS_UPNP_I_H
00013 #define WPS_UPNP_I_H
00014
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 subscription;
00035 struct upnp_wps_device_sm;
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
00053 struct advertisement_state_machine *next;
00054 struct advertisement_state_machine *prev;
00055 struct upnp_wps_device_sm *sm;
00056 enum advertisement_type_enum type;
00057 int state;
00058 int nerrors;
00059 struct sockaddr_in client;
00060 };
00061
00062
00063
00064
00065
00066
00067
00068 struct subscr_addr {
00069
00070 struct subscr_addr *next;
00071 struct subscr_addr *prev;
00072 struct subscription *s;
00073 char *domain_and_port;
00074 char *path;
00075 struct sockaddr_in saddr;
00076 };
00077
00078
00079
00080
00081
00082
00083
00084 struct subscription {
00085
00086 struct subscription *next;
00087 struct subscription *prev;
00088 struct upnp_wps_device_sm *sm;
00089 time_t timeout_time;
00090 unsigned next_subscriber_sequence;
00091
00092
00093
00094
00095
00096 u8 uuid[UUID_LEN];
00097
00098 struct subscr_addr *addr_list;
00099 int n_addr;
00100 struct wps_event_ *event_queue;
00101 int n_queue;
00102 struct wps_event_ *current_event;
00103
00104 };
00105
00106
00107
00108
00109
00110
00111
00112
00113 struct upnp_wps_device_sm {
00114 struct upnp_wps_device_ctx *ctx;
00115 struct wps_context *wps;
00116 void *priv;
00117 char *root_dir;
00118 char *desc_url;
00119 int started;
00120 char *net_if;
00121 char *mac_addr_text;
00122 u8 mac_addr[ETH_ALEN];
00123 char *ip_addr_text;
00124 unsigned ip_addr;
00125 int multicast_sd;
00126 int ssdp_sd;
00127 int ssdp_sd_registered;
00128 unsigned advertise_count;
00129 struct advertisement_state_machine advertisement;
00130 struct advertisement_state_machine *msearch_replies;
00131 int n_msearch_replies;
00132 int web_port;
00133 struct http_server *web_srv;
00134
00135 struct subscription *subscriptions;
00136 int n_subscriptions;
00137 int event_send_all_queued;
00138
00139
00140 char *wlanevent;
00141
00142
00143 struct upnp_wps_peer peer;
00144 };
00145
00146
00147 void format_date(struct wpabuf *buf);
00148 struct subscription * subscription_start(struct upnp_wps_device_sm *sm,
00149 const char *callback_urls);
00150 struct subscription * subscription_renew(struct upnp_wps_device_sm *sm,
00151 const u8 uuid[UUID_LEN]);
00152 void subscription_unlink(struct subscription *s);
00153 void subscription_destroy(struct subscription *s);
00154 struct subscription * subscription_find(struct upnp_wps_device_sm *sm,
00155 const u8 uuid[UUID_LEN]);
00156 int send_wpabuf(int fd, struct wpabuf *buf);
00157 int get_netif_info(const char *net_if, unsigned *ip_addr, char **ip_addr_text,
00158 u8 mac[ETH_ALEN], char **mac_addr_text);
00159
00160
00161 void msearchreply_state_machine_stop(struct advertisement_state_machine *a);
00162 int advertisement_state_machine_start(struct upnp_wps_device_sm *sm);
00163 void advertisement_state_machine_stop(struct upnp_wps_device_sm *sm,
00164 int send_byebye);
00165 void ssdp_listener_stop(struct upnp_wps_device_sm *sm);
00166 int ssdp_listener_start(struct upnp_wps_device_sm *sm);
00167 int ssdp_listener_open(void);
00168 int add_ssdp_network(const char *net_if);
00169 int ssdp_open_multicast_sock(u32 ip_addr);
00170 int ssdp_open_multicast(struct upnp_wps_device_sm *sm);
00171
00172
00173 int web_listener_start(struct upnp_wps_device_sm *sm);
00174 void web_listener_stop(struct upnp_wps_device_sm *sm);
00175
00176
00177 int event_add(struct subscription *s, const struct wpabuf *data);
00178 void event_delete_all(struct subscription *s);
00179 void event_send_all_later(struct upnp_wps_device_sm *sm);
00180 void event_send_stop_all(struct upnp_wps_device_sm *sm);
00181
00182 #endif
00183