Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

upnphandler.h File Reference


Detailed Description

The upnphandler will send a Universal Plug-n-Play (UPnP) M-SEARCH message to 239.255.255.250:1900 periodically, as well as listen for 'alive' and 'byebye' messages, to collect a list of all UPnP devices (e.g., personal computers, printers, scanners, etc.) The handler will "watch" for changes to a particular list of active devices who's description matches the specified regex's. Events may be generated when the matching devices are available or unavailable as well as to generate counts of the matching devices. The 'up' and 'down' events are useful to monitor devices to generate notification and/or other response to a device stopping (and starting, but that is less common). The 'count' events are useful if you are interested in alerts when the number of a specific devices gets too high or low and when you are keep stats on activity. You may have multiple regex's, each generating its own events. This avoids doing the network search for each regex, rather it is is read one time for all. You may optionally specify a subsitution string that behaves similar to 'sed' to customize the generated events. If you supply a substitution string, rather than copying the original complete matching string, the substitution string is used, replacing all occurances of the special charcters \[0-9] with the associated substring matches. Note: \0 matches the whole expression, while \1,\2 through \9 are substring matches 1, 2 through 9. For example, say you are watching all the HP printers on your network. You can change the name reported in the event by supplying a subsitution string and specifying substrings in the regex (i.e., regex is "http://(.*)/.*HP.*(uuid:[0-9]*)" and substitution is "HP printer at \1 is down (\2)"). Regex's are POSIX 1003.2 "extended" form. Names reported in events are generated by concatenating the LOCATION, SERVER and USN strings seperated by a \t. This handler implements a control point as per the UPnP1.0 spec.

Wire keywords (standard handler keywords documented in Wire )

You my have multiple match: lines. Matches are applied in the order they are declared. Example:

// generate events for all UPnP devices coming up/down and report total count
set up create event { name: "up"  priority: 1 }
set down create event { name: "down"  priority: 1 }
set count create event { name: "count"  priority: 1 }

create handler upnp { 
	match: $up $down $count "" ""
	elogger: $plogger 
}

Events generated:
Event NameTypeDescription
up AW_EVENT_TYPE_STRING Device with matching name is up, send name
down AW_EVENT_TYPE_STRING Device with matching name is that was up is now down, send name
count AW_EVENT_TYPE_INT32 The number of devices matching the regex
References:

#include "sysnet.h"
#include "trie.h"
#include "regexmatch.h"
#include "monitor.h"
#include "wire.h"

Go to the source code of this file.

Data Structures

struct  aw_upnphandler_devlist_s
struct  aw_upnphandler_events_t
 Events generated. More...

struct  aw_upnphandler_regex_t
 Specifies a regex and associated events. More...

struct  aw_upnphandler_state_t
 State of handler during probing. More...

struct  aw_upnphandler_t
 Handler object. More...

struct  aw_upnphandler_watcher_t
 Compiled regex, associated events and state. More...


Defines

#define AW_UPNPHANDLER_DEFAULT_FLAGS   (AW_UPNPHANDLER_COUNTONCHANGE)
#define UPNP_MCAST_GROUP   "239.255.255.250"
#define UPNP_MCAST_PORT   1900

Typedefs

typedef aw_upnphandler_devlist_s aw_upnphandler_devlist_t

Enumerations

enum  aw_upnphandler_flag_t { AW_UPNPHANDLER_GROUP = 0x1, AW_UPNPHANDLER_COUNTONCHANGE = 0x2 }
enum  aw_upnphandler_state_cd_t { AW_UPNPHANDLER_IDLE, AW_UPNPHANDLER_WAIT_READ }
 The state codes for each state on handler. More...


Functions

aw_upnphandler_t * aw_create_upnphandler (u_int32_t nregexs, const aw_upnphandler_regex_t *regexs, const byte_t *mcinterface, u_int32_t mcloopback, const aw_alarm_sched_t *sched, aw_logger_t *logger)
 Create a upnphandler.

void aw_free_upnphandler (aw_upnphandler_t *p)
 Free handler and all associated resources.

aw_handler_t * aw_wire_upnphandler (aw_wire_mkhandler_args_t *args)
 Create a upnp handler using "wire". See header doc for keyword documentation.


Define Documentation

#define AW_UPNPHANDLER_DEFAULT_FLAGS   (AW_UPNPHANDLER_COUNTONCHANGE)
 

Default settings

#define UPNP_MCAST_GROUP   "239.255.255.250"
 

#define UPNP_MCAST_PORT   1900
 


Typedef Documentation

typedef struct aw_upnphandler_devlist_s aw_upnphandler_devlist_t
 


Enumeration Type Documentation

enum aw_upnphandler_flag_t
 

Flag values.

Enumeration values:
AW_UPNPHANDLER_GROUP 
AW_UPNPHANDLER_COUNTONCHANGE 

enum aw_upnphandler_state_cd_t
 

The state codes for each state on handler.

Enumeration values:
AW_UPNPHANDLER_IDLE 
AW_UPNPHANDLER_WAIT_READ 


Function Documentation

aw_upnphandler_t* aw_create_upnphandler (  u_int32_t  nregexs,
const aw_upnphandler_regex_t *  regexs,
const byte_t *  mcinterface,
u_int32_t  mcloopback,
const aw_alarm_sched_t *  sched,
aw_logger_t *  logger
) 
 

Create a upnphandler.

aw_create_upnphandler

Parameters:
nregexs How many regex strings
regexs Array of regex strings
mcinterface Interface name to send multicast, may be NULL to default
mcloopback If nonzero, then enable multicast to current machine (this is encouraged). If zero, then do not.
sched Run schedule
logger Logger object
Returns:
Handler object

void aw_free_upnphandler (  aw_upnphandler_t *  p  ) 
 

Free handler and all associated resources.

aw_free_upnphandler

Parameters:
p The handler

aw_handler_t* aw_wire_upnphandler (  aw_wire_mkhandler_args_t *  args  ) 
 

Create a upnp handler using "wire". See header doc for keyword documentation.

aw_wire_upnphandler

Aware 0.11.1 Copyright (C) 1998-2005 Russell Leighton (russ@elegant-software.com)