00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __AWHANDLER_UPNP__
00024 #define __AWHANDLER_UPNP__
00025
00026 #include "sysnet.h"
00027 #include "trie.h"
00028 #include "regexmatch.h"
00029 #include "monitor.h"
00030 #include "wire.h"
00031
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 #define UPNP_MCAST_GROUP "239.255.255.250"
00152 #define UPNP_MCAST_PORT 1900
00153
00154
00158 typedef enum {
00159
00160 AW_UPNPHANDLER_GROUP = 0x1,
00161 AW_UPNPHANDLER_COUNTONCHANGE = 0x2,
00162
00163 } aw_upnphandler_flag_t;
00164
00168 #define AW_UPNPHANDLER_DEFAULT_FLAGS (AW_UPNPHANDLER_COUNTONCHANGE)
00169
00173 typedef struct {
00174
00175 aw_event_sig_t
00176 up,
00177 down,
00178 count;
00179
00180 } aw_upnphandler_events_t;
00181
00182
00186 typedef enum {
00187
00188 AW_UPNPHANDLER_IDLE,
00189 AW_UPNPHANDLER_WAIT_READ,
00190
00191 } aw_upnphandler_state_cd_t;
00192
00196 typedef struct aw_upnphandler_devlist_s {
00197
00198
00199 struct aw_upnphandler_devlist_s
00200 *next;
00201
00202
00203 aw_timestamp_t
00204 expires;
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217 byte_t
00218 *name;
00219
00220
00221 byte_t
00222 *key;
00223
00224 } aw_upnphandler_devlist_t;
00225
00226
00230 typedef struct {
00231
00232 aw_upnphandler_state_cd_t
00233 state_cd;
00234
00235 int32_t
00236 outmcfd,
00237 inmcfd;
00238
00239
00240 byte_t
00241 rx_message[0xffff];
00242
00243
00244 u_int32_t
00245 first_handler;
00246
00247
00248 aw_upnphandler_devlist_t
00249 *up,
00250 *new_up;
00251
00252
00253 aw_trie_t
00254 *up_index,
00255 *new_up_index;
00256
00257 aw_cache_allocator_t
00258 devlist_factory;
00259
00260 } aw_upnphandler_state_t;
00261
00265 typedef struct {
00266
00267 aw_upnphandler_flag_t
00268 flags;
00269
00270 aw_upnphandler_events_t
00271 events;
00272
00273
00274 const byte_t
00275 *regex;
00276
00277
00278 const byte_t
00279 *subst;
00280
00281 } aw_upnphandler_regex_t;
00282
00286 typedef struct {
00287
00288 aw_upnphandler_flag_t
00289 flags;
00290
00291 aw_upnphandler_events_t
00292 events;
00293
00294
00295 regex_t
00296 pattern;
00297
00298
00299 byte_t
00300 *subst;
00301
00302 aw_upnphandler_devlist_t
00303 *watch;
00304
00305 u_int32_t
00306 watchcount;
00307
00308 } aw_upnphandler_watcher_t;
00309
00310
00314 typedef struct {
00315
00316 aw_handler_t
00317 handler_header;
00318
00319 u_int32_t
00320 nwatchers;
00321
00322 aw_upnphandler_watcher_t
00323 *watchers;
00324
00325 aw_upnphandler_state_t
00326 state;
00327
00328
00329 struct in_addr
00330 mcast_if_addr;
00331
00332
00333 u_int32_t
00334 mcast_loopback;
00335
00336
00337 struct sockaddr_in
00338 mcast_grp_addr;
00339
00340
00341 aw_alarm_sched_t
00342 msearch_sched;
00343
00344
00345 aw_timestamp_t
00346 timeout;
00347
00348 } aw_upnphandler_t ;
00349
00360 aw_upnphandler_t *aw_create_upnphandler(u_int32_t nregexs,
00361 const aw_upnphandler_regex_t *regexs,
00362 const byte_t *mcinterface,
00363 u_int32_t mcloopback,
00364 const aw_alarm_sched_t *sched,
00365 aw_logger_t *logger
00366 );
00367
00372 void aw_free_upnphandler(aw_upnphandler_t *p);
00373
00377 aw_handler_t *aw_wire_upnphandler(aw_wire_mkhandler_args_t *args);
00378
00379 #endif
00380
00381