sipxtacklib  Version 3.3
SipConfigServerAgent.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 #ifndef _SipConfigServerAgent_h_
12 #define _SipConfigServerAgent_h_
13 
14 // SYSTEM INCLUDES
15 //#include <...>
16 
17 // APPLICATION INCLUDES
18 #include <os/OsServerTask.h>
19 #include <net/SipMessage.h>
20 #include <os/OsBSem.h>
21 
22 // DEFINES
23 // MACROS
24 // EXTERNAL FUNCTIONS
25 // EXTERNAL VARIABLES
26 // CONSTANTS
27 // STRUCTS
28 // TYPEDEFS
29 typedef int (*EnrollmentCallbackFunc)(const SipMessage& subscribeRequest);
30 // Note this function will need to parse out the following:
31 // from the From header field URL:
32 // fromUser, fromAddress, fromPort
33 // from the From header field parameters (Url:getHeaderFieldParameter):
34 // vender, model, version, mac, serial
35 // from the Config-Requires header field:
36 // numProfiles, profiles[]
37 // from the Config-Allow header field
38 // numProcols, protocols[]
39 // from the Config-Expires header field:
40 // expirationSeconds
41 // Note: #defines exist in SipMessage.h for these header field names:
42 // SIP_FROM_FIELD, SIP_TO_FIELD,
43 // SIP_CONFIG_ALLOW_FIELD, SIP_CONFIG_REQUIRE_FIELD
44 
45 typedef void (*NotifyResponseCallbackFunc)(const SipMessage& notifyResponse);
46 // Note: this function will need to parse out the
47 // following data from the SipMessage:
48 // from the header response status code: notifyChangeResponseCode
49 // from the header response status text: notifyChangeResponseText
50 
51 
52 // FORWARD DECLARATIONS
53 class SipUserAgent;
54 class OsConfigDb;
55 
56 
57 //:This class is the SIP configuation agent for the deployment serve
58 // From the SIP messaging perspective there are two types of messages
59 // related to configuration:
60 // 1) Enrollment from the SIP UA/device to the server in the form of SUBSCRIBE
61 // 2) Configuration change notification from the config server to the device
62 // in the form of a NOTIFY request
63 // <BR>
64 // The following message flow illustrates the communications
65 // between this object, the config. server and the managed
66 // SIP UA device.
67 //
68 // config. SipConfigServerAgent UA device
69 // server
70 // <------------------SUBSCRIBE (enrollment)
71 // <--------------EnrollmentCallbackFunc
72 // return code --------->
73 // SUBSCRIBE response ---------->
74 // ...
75 // sendChangeNotification->
76 // NOTIFY (config change) ------>
77 // <------------------NOTIFY response
78 // <--------------NotifyResponseCallbackFunc
79 //
80 // <BR>
81 // Enrollment is initiated by the device sending the SUBSCRIBE to the config
82 // server. When the SipConfigServerAgent receives the SUBSCRIBE it calls
83 // the callback: EnrollmentCallbackFunc to provide the entollement data
84 // to the config. server. The config. server must return the response
85 // code to be used for the SUBSCRIBE response. Typically this will
86 // be: 202 Acepted for success, 400 Bad Request, etc. see SipMessage.h
87 // Included is a subscribe context that is needed if the config. server
88 // is to send change notifications.
89 // <BR>
90 // Later when the config. server wishes to send the config profile
91 // URLs, it calls the sendChangeNotification method. This method
92 // returns a boolean indicating whether the NOTIFY was sent or
93 // not. This does not indicate the request was received or not
94 // by the SIP UA device. The final outcome is indicated to the
95 // config. server via the callaback: NotifyResponseCallbackFunc
96 // Note: I have not come up with a convenient means of matching
97 // the invocations of this call back with the sendChangeNotification
98 // invocation (i.e. same transaction). So for now I won't implement
99 // this callback.
100 
101 class SipConfigServerAgent : public OsServerTask
102 {
103 /* //////////////////////////// PUBLIC //////////////////////////////////// */
104 public:
105 
106 /* ============================ CREATORS ================================== */
107 
109  //:Default constructor
110 
111  virtual
113  //:Destructor
114 
115 /* ============================ MANIPULATORS ============================== */
116 
117  virtual UtlBoolean handleMessage(OsMsg& eventMessage);
118 
119  UtlBoolean sendChangeNotification(SipMessage& notifyRequest);
120  //: Sends an config. change notification (NOTIFY) to the SIP UA device indicated in subscriberContext
125 
126  // Note the application is responsible for keeping a copy of the
127  // original request as it will need to copy and reverse the
128  // To & From fields.. It should construct the proper route
129  // field if there was a record-route field in the subscribe
130  // request. Each notify request should have an incremented
131  // CSeq header field. The NOTIFY body should contain the
132  // profile urls and sequence numbers.
133 
134  // Note: we need a asychronous meand of letting the
135  // caller of this method know that the message failed to send.
136 
137 /* ============================ ACCESSORS ================================= */
138 
140  //: Sets the function which gets called when an enrollment SUBSCRIBE comes in
141 
143  //: Sets the function which gets called when a response is received for a change notification
144 
146  //: Returns a singleton reference to the Sip Config Server Agent
147 
149  //: Returns a reference to the Sip User Agent
150 
151 /* ============================ INQUIRY =================================== */
152 
153 /* //////////////////////////// PROTECTED ///////////////////////////////// */
154 protected:
155 
156 /* //////////////////////////// PRIVATE /////////////////////////////////// */
157 private:
158 
159  static SipConfigServerAgent* startAgents(const char* configFileName) ;
160  //: Starts up the SipUserAgent and the SipConfigServerAgent
161 
162  SipConfigServerAgent(const SipConfigServerAgent& rSipConfigServerAgent);
163  //:Copy constructor diabled
164 
165  SipConfigServerAgent& operator=(const SipConfigServerAgent& rhs);
166  //:Assignment operator diabled
167 
168  static SipConfigServerAgent* spInstance ;
169  //: Singleton instance to ourself
170  static OsBSem sLock;
171  //: Semaphore guarding start up
172  SipUserAgent* mpSipUserAgent;
173  //: Reference to the Sip User Agent
174  EnrollmentCallbackFunc mfpEnrollmentCallbackFunc;
175  NotifyResponseCallbackFunc mfpNotifyResponseCallbackFunc;
176 
177  void static initializeLog(OsConfigDb* pConfigDb) ;
178  //: Initialize the OsSysLog
179 
180 };
181 
182 /* ============================ INLINE METHODS ============================ */
183 
184 #endif // _SipConfigServerAgent_h_
Transaction and Transport manager for SIP stack.
Definition: SipUserAgent.h:157
Definition: SipConfigServerAgent.h:101
virtual ~SipConfigServerAgent()
Definition: SipConfigServerAgent.cpp:85
void(* NotifyResponseCallbackFunc)(const SipMessage &notifyResponse)
Definition: SipConfigServerAgent.h:45
void setChangeNotifyStatusCallback(NotifyResponseCallbackFunc callback)
static SipConfigServerAgent * getSipConfigServerAgent()
Definition: SipConfigServerAgent.cpp:281
SipUserAgent * getSipUserAgent()
Definition: SipConfigServerAgent.cpp:275
Specialization of HttpMessage to contain and manipulate SIP messages.
Definition: SipMessage.h:343
void setEnrollmentCallback(EnrollmentCallbackFunc callback)
param: subscribeContext - text serialization of the enrollment SUBSCRIBE param: notifyCSeqence - the ...
Definition: SipConfigServerAgent.cpp:335
int(* EnrollmentCallbackFunc)(const SipMessage &subscribeRequest)
Definition: SipConfigServerAgent.h:29
SipConfigServerAgent(SipUserAgent *userAgent)
Definition: SipConfigServerAgent.cpp:52
UtlBoolean sendChangeNotification(SipMessage &notifyRequest)
virtual UtlBoolean handleMessage(OsMsg &eventMessage)
Definition: SipConfigServerAgent.cpp:102

sipXtackLib home page