12 #ifndef _SipUserAgent_h_ 13 #define _SipUserAgent_h_ 19 #include <utl/UtlHashBag.h> 20 #include <os/OsServerTask.h> 27 #include <os/OsQueuedEvent.h> 32 #include <os/OsNatKeepaliveListener.h> 35 #define SIP_DEFAULT_RTT 500 36 #define SIP_MINIMUM_RTT 100 37 #define SIP_MAX_PORT_RANGE 10 // If a port is in use and the sip user agent 43 #define SIPUA_DEFAULT_SERVER_UDP_BUFFER_SIZE 1000000 46 #define SIPUA_DEFAULT_SERVER_OSMSG_QUEUE_SIZE 10000 237 const char* publicAddress = NULL,
238 const char* defaultUser = NULL,
239 const char* defaultSipAddress = NULL,
240 const char* sipProxyServers = NULL,
241 const char* sipDirectoryServers = NULL,
242 const char* sipRegistryServers = NULL,
243 const char* authenticationScheme = NULL,
244 const char* authenicateRealm = NULL,
245 OsConfigDb* authenticateDb = NULL,
246 OsConfigDb* authorizeUserIds = NULL,
247 OsConfigDb* authorizePasswords = NULL,
250 UtlBoolean defaultToUaTransactions = TRUE,
251 int readBufferSize = -1,
252 int queueSize = OsServerTask::DEF_MAX_MSGS,
253 UtlBoolean bUseNextAvailablePort = FALSE,
254 UtlString certNickname =
"",
255 UtlString certPassword =
"",
256 UtlString dbLocation =
".",
257 UtlBoolean doUaMessageChecks = TRUE);
273 void shutdown(UtlBoolean blockingShutdown = TRUE);
277 virtual void enableStun(
const char* szStunServer,
279 int refreshPeriodInSecs,
280 OsNotification* pNotification = NULL,
281 const char* szIp = NULL) ;
313 const char* sipMethod = NULL,
314 UtlBoolean wantRequests = TRUE,
315 UtlBoolean wantResponses = TRUE,
316 UtlBoolean wantIncoming = TRUE,
317 UtlBoolean wantOutGoing = FALSE,
318 const char* eventName = NULL,
320 void* observerData = NULL);
334 void* pObserverData = NULL);
354 OsMsgQ* responseListener = NULL,
355 void* responseListenerData = NULL,
373 void allowMethod(
const char* methodName,
const bool bAllow =
true);
389 const char* szRemoteIp,
390 const int remotePort,
391 const int keepAliveSecs,
392 OsNatKeepaliveListener* pListener) ;
395 const char* szRemoteIp,
396 const int remotePort) ;
399 const char* szRemoteIp,
400 const int remotePort,
401 const int keepAliveSecs,
402 OsNatKeepaliveListener* pListener) ;
405 const char* szRemoteIp,
406 const int remotePort) ;
411 const char* szRemoteIp,
412 const int remotePort,
413 const char* szMethod,
414 const int keepAliveSecs,
415 OsNatKeepaliveListener* pListener) ;
418 const char* szRemoteIp,
419 const int remotePort,
420 const char* szMethod) ;
467 void getFromAddress(UtlString* address,
int* port, UtlString* protocol);
472 const char* pszTargetAddress,
473 const int* piTargetPort);
476 int* port, UtlString* protocol);
479 int* port, UtlString* protocol);
490 virtual void logMessage(
const char* message,
int messageLength);
570 const bool bDateHeader,
571 const bool bShortNames,
572 const UtlString& acceptLanguage);
576 {
return mbShortNames;}
580 {mbUseLocationHeader=bLocationHeader;}
607 UtlBoolean
isOk(OsSocket::IpProtocolSocketType socketType);
633 OsSocket::IpProtocolSocketType& toProtocol,
634 const char* szTargetAddress,
635 const int* piTargetPort,
639 SipTlsServer* getTlsServer() {
return mSipTlsServer; }
641 bool onServerCertificate(
void* pCert,
char* serverHostName);
642 bool onTlsEvent(
int cause);
652 const char* szTargetAddress,
653 const int* piTargetPort) ;
661 UtlString* disallowedExtensions)
const;
672 OsSocket::IpProtocolSocketType protocol,
673 UtlString& branchId);
676 const char* serverAddress,
680 const char* serverAddress,
684 const char* serverAddress,
689 const char* sendAddress,
693 const char* serverAddress,
698 UtlString& sipAddress,
711 const char* uri = NULL)
const;
718 int authorizationEntity);
726 SipTlsServer* mSipTlsServer;
729 UtlString defaultSipUser;
730 UtlString defaultSipAddress;
731 UtlString proxyServers;
732 UtlString directoryServers;
733 UtlString registryServers;
735 int lastRegisterSeqNum;
736 UtlString registerCallId;
737 UtlString sipIpAddress;
738 UtlString mConfigPublicAddress ;
740 UtlDList allowedSipMethods;
741 UtlDList allowedSipExtensions;
742 UtlString mUserAgentHeaderProperties;
743 UtlHashBag mMyHostAliases;
744 UtlHashBag mMessageObservers;
745 UtlHashMap mExternalTransports;
746 OsRWMutex mMessageLogRMutex;
747 OsRWMutex mMessageLogWMutex;
750 int mFirstResendTimeoutMs;
751 int mLastResendTimeoutMs;
752 int mReliableTransportTimeoutMs;
753 int mTransactionStateTimeoutMs;
754 int mDefaultExpiresSeconds;
755 int mDefaultSerialExpiresSeconds;
756 int mMinInviteTransactionTimeout;
757 int mMaxTcpSocketIdleTime;
762 UtlString defaultUserAgentName;
763 long mLastCleanUpTime;
764 UtlString mAuthenticationScheme;
765 UtlString mAuthenticationRealm;
766 OsConfigDb* mpAuthenticationDb;
767 OsConfigDb* mpAuthorizationUserIds;
768 OsConfigDb* mpAuthorizationPasswords;
770 int mMaxMessageLogSize;
771 UtlString mMessageLog;
772 UtlString mLocationHeader;
773 UtlBoolean mIsUaTransactionByDefault;
774 UtlBoolean mForkingEnabled;
776 UtlBoolean mRecurseOnlyOne300Contact;
777 UtlBoolean mReturnViasForMaxForwards;
778 UtlBoolean mbUseRport;
779 UtlBoolean mUseRportMapping;
780 UtlBoolean mbUseLocationHeader;
781 bool mbIncludePlatformInUserAgentName;
789 UtlBoolean mDoUaMessageChecks;
791 void garbageCollection();
794 const UtlString& method);
795 void queueMessageToObservers(
SipMessage* message,
802 UtlBoolean mbShuttingDown;
803 UtlBoolean mbShutdownDone;
804 UtlBoolean mbBlockingShutdown;
809 UtlString mAcceptLanguage;
811 int mRegisterTimeoutSeconds;
823 #endif // _SipUserAgent_h_ UtlBoolean sendSymmetricUdp(SipMessage &message, const char *serverAddress, int port)
Definition: SipUserAgent.cpp:1169
void setDefaultSerialExpiresSeconds(int expiresSeconds)
Definition: SipUserAgent.cpp:3574
UtlBoolean sendTcp(SipMessage *message, const char *serverAddress, int port)
Definition: SipUserAgent.cpp:1441
Definition: SipSession.h:33
void setUserAgentName(const UtlString &name)
Get the local Tls port number (or PORT_NONE if disabled)
Definition: SipUserAgent.cpp:3082
void setRegisterResponseTimeout(const int seconds)
Definition: SipUserAgent.h:499
void getDirectoryServer(int index, UtlString *address, int *port, UtlString *protocol)
Definition: SipUserAgent.cpp:3487
UtlBoolean isForkingEnabled()
Definition: SipUserAgent.cpp:3887
void setDefaultExpiresSeconds(int expiresSeconds)
Definition: SipUserAgent.cpp:3553
Transaction and Transport manager for SIP stack.
Definition: SipUserAgent.h:157
Definition: SipTcpServer.h:58
void getFromAddress(UtlString *address, int *port, UtlString *protocol)
Definition: SipUserAgent.cpp:3439
The SipUdpServer is owner/container of the sockets used for UDP communications.
Definition: SipUdpServer.h:52
Definition: SipMessageEvent.h:39
void getViaInfo(int protocol, UtlString &address, int &port, const char *pszTargetAddress, const int *piTargetPort)
Definition: SipUserAgent.cpp:3398
UtlBoolean sendTls(SipMessage *message, const char *serverAddress, int port)
Definition: SipUserAgent.cpp:1519
void lookupSRVSipAddress(UtlString protocol, UtlString &sipAddress, int &port, UtlString &srcIp)
DNS SRV lookup for to address.
Definition: SipUserAgent.cpp:4131
void allowMethod(const char *methodName, const bool bAllow=true)
Definition: SipUserAgent.cpp:674
const SIPX_TRANSPORT_DATA *const lookupExternalTransport(const UtlString transportName, const UtlString ipAddress) const
Definition: SipUserAgent.cpp:4430
void getAllowedMethods(UtlString *allowedMethods)
Definition: SipUserAgent.cpp:3379
void stopTransactionTimers()
Definition: SipTransactionList.cpp:312
UtlBoolean sendStatelessRequest(SipMessage &request, UtlString &address, int port, OsSocket::IpProtocolSocketType protocol, UtlString &branchId)
Definition: SipUserAgent.cpp:1392
UtlBoolean addStunKeepAlive(const char *szLocalIp, const char *szRemoteIp, const int remotePort, const int keepAliveSecs, OsNatKeepaliveListener *pListener)
Definition: SipUserAgent.cpp:2986
SipContactDb mContactDb
Definition: SipUserAgentBase.h:123
void shutdown(UtlBoolean blockingShutdown=TRUE)
Cleanly shuts down SipUserAgent.
Definition: SipUserAgent.cpp:534
int getUdpPort() const
Definition: SipUserAgent.cpp:3780
void setReturnViasForMaxForwards(UtlBoolean returnVias)
Flag to return Vias in too many hops response to request with max-forwards == 0.
void addAuthentication(SipMessage *message) const
Definition: SipUserAgent.cpp:4065
#define SIP_DEFAULT_RTT
Definition: SipUserAgent.h:35
void startMessageLog(int newMaximumLogSize=0)
Definition: SipUserAgent.cpp:3656
int getDnsSrvTimeout()
Get the number of seconds to wait before trying the next DNS SRV record.
Definition: SipUserAgent.cpp:3254
const bool addContactAddress(SIPX_CONTACT_ADDRESS &contactAddress)
Adds a contact record to the contact db.
Definition: SipUserAgent.cpp:4292
Indicator for a UDP socket type.
Definition: sipXtapi.h:543
UtlBoolean checkExtensions(SipMessage *message)
void setUserAgentHeader(SipMessage &message)
Definition: SipUserAgent.cpp:4260
void startTransactionTimers()
Definition: SipUserAgent.h:585
void stopTransactionTimers()
Definition: SipUserAgent.h:584
UtlBoolean isShutdownDone()
Find out if SipUserAgent has finished shutting down.
Definition: SipUserAgent.cpp:3955
virtual UtlBoolean handleMessage(OsMsg &eventMessage)
For internal use only.
Definition: SipUserAgent.cpp:2443
void removeExternalTransport(const UtlString transportName, const SIPX_TRANSPORT_DATA *const pTransport)
Definition: SipUserAgent.cpp:4422
void selfHeaderValue(UtlString &self)
constuct the value to be used in either user-agent or server header.
Definition: SipUserAgent.cpp:4272
UtlBoolean removeStunKeepAlive(const char *szLocalIp, const char *szRemoteIp, const int remotePort)
Definition: SipUserAgent.cpp:3003
void setForking(UtlBoolean enabled)
Allow or disallow recursion and forking of 3xx class requests.
Definition: SipUserAgent.cpp:3264
void setProxyServers(const char *sipProxyServers)
Set the SIP proxy servers for the user agent.
Definition: SipUserAgent.cpp:3516
int getTcpPort() const
Get the local UDP port number (or PORT_NONE if disabled)
Definition: SipUserAgent.cpp:3768
Specialization of HttpMessage to contain and manipulate SIP messages.
Definition: SipMessage.h:343
void whichExtensionsNotAllowed(const SipMessage *message, UtlString *disallowedExtensions) const
Definition: SipUserAgent.cpp:3841
UtlBoolean removeMessageObserver(OsMsgQ &messageQueue, void *pObserverData=NULL)
Removes all SIP message observers for the given message/queue observer.
Definition: SipUserAgent.cpp:640
UtlBoolean getUseRport() const
Is use report set?
Definition: SipUserAgent.cpp:3077
SipTransaction correlates requests and responses.
Definition: SipTransaction.h:51
void prepareVia(SipMessage &message, UtlString &branchId, OsSocket::IpProtocolSocketType &toProtocol, const char *szTargetAddress, const int *piTargetPort, SIPX_TRANSPORT_DATA *pTransport=NULL)
Definition: SipUserAgent.cpp:4317
Definition: SipUserAgent.h:172
void setHostAliases(UtlString &aliases)
Set other DNS names or IP addresses which are considered to refer to this SipUserAgent.
Definition: SipUserAgent.cpp:3603
void setServerHeader(SipMessage &message)
Definition: SipUserAgent.cpp:4246
UtlBoolean removeSipKeepAlive(const char *szLocalIp, const char *szRemoteIp, const int remotePort, const char *szMethod)
Definition: SipUserAgent.cpp:3037
UtlBoolean getConfiguredPublicAddress(UtlString *pIpAddress, int *pPort)
Get the manually configured public address.
Definition: SipUserAgent.cpp:3095
virtual ~SipUserAgent()
Destructor.
Definition: SipUserAgent.cpp:438
#define SIP_PORT
Definition: SipMessage.h:256
UtlBoolean getNatMappedAddress(UtlString *pIpAddress, int *pPort)
Get the NAT mapped address and port.
Definition: SipUserAgent.cpp:3162
int getMaxSrvRecords() const
Get the maximum number of DNS SRV records to pursue in the case of failover.
Definition: SipUserAgent.cpp:3244
UtlBoolean recurseOnlyOne300Contact()
Definition: SipUserAgent.cpp:3915
int getSipStateTransactionTimeout()
Definition: SipUserAgent.cpp:3528
void setHeaderOptions(const bool bAllowHeader, const bool bDateHeader, const bool bShortNames, const UtlString &acceptLanguage)
Sets the User Agent name sent with outgoing sip messages.
Definition: SipUserAgent.cpp:4306
void stopMessageLog()
Definition: SipUserAgent.cpp:3670
virtual UtlBoolean waitUntilReady()
Definition: SipUserAgent.cpp:3874
void setMaxForwards(int maxForwards)
Set the limit of allowed hops a message can make.
Definition: SipUserAgent.cpp:3213
UtlBoolean sendStatelessResponse(SipMessage &response)
Definition: SipUserAgent.cpp:1339
OsTimer * getTimer()
Definition: SipUserAgent.h:408
SipMessage * getRequest(const SipMessage &response)
Get a copy of the original request that was sent corresponding to this incoming response.
Definition: SipUserAgent.cpp:3744
void setEnableLocationHeader(const bool bLocationHeader)
Definition: SipUserAgent.h:579
void printStatus()
Print diagnostics.
Definition: SipUserAgent.cpp:3632
void clearMessageLog()
Definition: SipUserAgent.cpp:3675
void addExternalTransport(const UtlString tranportName, const SIPX_TRANSPORT_DATA *const pTransport)
Definition: SipUserAgent.cpp:4415
virtual UtlBoolean send(SipMessage &message, OsMsgQ *responseListener=NULL, void *responseListenerData=NULL, SIPX_TRANSPORT_DATA *pTransport=NULL)
Send a SIP message over the net.
Definition: SipUserAgent.cpp:698
UtlBoolean setUseRport(UtlBoolean bEnable)
Enable or disable the outbound use of rport (send packet to actual port – not advertised port)...
Definition: SipUserAgent.cpp:3057
int getTlsPort() const
Get the local TCP port number (or PORT_NONE if disabled)
Definition: SipUserAgent.cpp:3792
void prepareContact(SipMessage &message, const char *szTargetAddress, const int *piTargetPort)
Definition: SipUserAgent.cpp:3269
Definition: SipUserAgent.h:171
int getLastResendTimeout()
Definition: SipUserAgent.cpp:3543
virtual void logMessage(const char *message, int messageLength)
Definition: SipUserAgent.cpp:3682
UtlBoolean checkMethods(SipMessage *message)
EventSubTypes
Definition: SipUserAgent.h:169
virtual void addMessageConsumer(OsServerTask *messageConsumer)
Deprecated (Add a SIP message recipient)
Definition: SipUserAgent.cpp:598
void getProxyServer(int index, UtlString *address, int *port, UtlString *protocol)
Definition: SipUserAgent.cpp:3502
void allowExtension(const char *extension)
Definition: SipUserAgent.cpp:3713
UtlBoolean isMethodAllowed(const char *method)
Definition: SipUserAgent.cpp:3809
UtlBoolean isMyHostAlias(Url &route) const
Definition: SipUserAgent.cpp:3892
Definition: SipLineMgr.h:67
void getSupportedExtensions(UtlString &extensionsString)
Definition: SipUserAgent.cpp:3722
int getReliableTransportTimeout()
Definition: SipUserAgent.cpp:3533
int getFirstResendTimeout()
Definition: SipUserAgent.cpp:3538
SipUserAgent(int sipTcpPort=SIP_PORT, int sipUdpPort=SIP_PORT, int sipTlsPort=SIP_PORT+1, const char *publicAddress=NULL, const char *defaultUser=NULL, const char *defaultSipAddress=NULL, const char *sipProxyServers=NULL, const char *sipDirectoryServers=NULL, const char *sipRegistryServers=NULL, const char *authenticationScheme=NULL, const char *authenicateRealm=NULL, OsConfigDb *authenticateDb=NULL, OsConfigDb *authorizeUserIds=NULL, OsConfigDb *authorizePasswords=NULL, SipLineMgr *lineMgr=NULL, int sipFirstResendTimeout=SIP_DEFAULT_RTT, UtlBoolean defaultToUaTransactions=TRUE, int readBufferSize=-1, int queueSize=OsServerTask::DEF_MAX_MSGS, UtlBoolean bUseNextAvailablePort=FALSE, UtlString certNickname="", UtlString certPassword="", UtlString dbLocation=".", UtlBoolean doUaMessageChecks=TRUE)
Constructor.
Definition: SipUserAgent.cpp:108
virtual void enableStun(const char *szStunServer, int iStunPort, int refreshPeriodInSecs, OsNotification *pNotification=NULL, const char *szIp=NULL)
Enable stun lookups for UDP signaling. Use a NULL szStunServer to disable.
Definition: SipUserAgent.cpp:582
const int getRegisterResponseTimeout() const
Definition: SipUserAgent.h:498
void setUseRportMapping(UtlBoolean bEnable)
Enable or disable use of rport IP and port in response via for contact mapping database.
Definition: SipUserAgent.cpp:3066
void addMessageObserver(OsMsgQ &messageQueue, const char *sipMethod=NULL, UtlBoolean wantRequests=TRUE, UtlBoolean wantResponses=TRUE, UtlBoolean wantIncoming=TRUE, UtlBoolean wantOutGoing=FALSE, const char *eventName=NULL, SipSession *pSession=NULL, void *observerData=NULL)
Add a SIP message observer for receiving SIP messages meeting the given filter criteria.
Definition: SipUserAgent.cpp:613
UtlBoolean removeCrLfKeepAlive(const char *szLocalIp, const char *szRemoteIp, const int remotePort)
Definition: SipUserAgent.cpp:2971
bool getEnabledShortNames()
Sets header options - send or not send.
Definition: SipUserAgent.h:575
Definition: SipMessageEvent.h:32
SIPX_TRANSPORT_TYPE
SIPX_TRANSPORT_TYPE defines various protocols use for signaling transport.
Definition: sipXtapi.h:541
Definition: sipXtapiInternal.h:288
virtual UtlBoolean isMessageLoggingEnabled()
Definition: SipUserAgent.cpp:3864
UtlBoolean shouldAuthenticate(SipMessage *message) const
Definition: SipUserAgent.cpp:3961
int getDefaultSerialExpiresSeconds() const
Definition: SipUserAgent.cpp:3569
UtlBoolean addCrLfKeepAlive(const char *szLocalIp, const char *szRemoteIp, const int remotePort, const int keepAliveSecs, OsNatKeepaliveListener *pListener)
Definition: SipUserAgent.cpp:2953
void setRecurseOnlyOne300Contact(UtlBoolean recurseOnlyOne)
Flag to recurse only one contact in a 300 response.
Definition: SipUserAgent.cpp:3739
UtlBoolean sendUdp(SipMessage *message, const char *serverAddress, int port)
Definition: SipUserAgent.cpp:1031
void setSelfHeader(SipMessage &message)
Add either Server or User-Agent header, as appropriate based on isUserAgent.
Definition: SipUserAgent.cpp:3185
void getMessageLog(UtlString &logData)
Definition: SipUserAgent.cpp:3707
Definition: SipUserAgent.h:173
void getContactAddresses(SIPX_CONTACT_ADDRESS *pContacts[], int &numContacts)
Gets all contact addresses for this user agent.
Definition: SipUserAgent.cpp:4301
void setUserAgentHeaderProperty(const char *property)
Provides a string to be appended to the standard User-Agent header.
Definition: SipUserAgent.cpp:3203
UtlBoolean resendWithAuthorization(SipMessage *response, SipMessage *request, int *messageType, int authorizationEntity)
Definition: SipUserAgent.cpp:4073
void setIsUserAgent(UtlBoolean isUserAgent)
Definition: SipUserAgent.cpp:3179
virtual void dispatch(SipMessage *message, int messageType=SipMessageEvent::APPLICATION, SIPX_TRANSPORT_DATA *pData=NULL)
Dispatch the SIP message to the message consumer(s)
Definition: SipUserAgent.cpp:1597
Definition: SipUserAgentBase.h:44
UtlBoolean getUseRportMapping() const
Get if use of rport IP and port in response via for contact mapping database is enabled.
Definition: SipUserAgent.cpp:3071
void setIncludePlatformInUserAgentName(const bool bInclude)
Tells the User Agent whether or not to append the platform name onto the User Agent string...
Definition: SipUserAgent.cpp:4287
SipContactDb & getContactDb()
Definition: SipUserAgent.h:623
int getMaxForwards()
Get the limit of allowed hops a message can make.
Definition: SipUserAgent.cpp:3226
URL parser and constructor.
Definition: Url.h:90
UtlBoolean isExtensionAllowed(const char *extension) const
Definition: SipUserAgent.cpp:3828
void startTransactionTimers()
Definition: SipTransactionList.cpp:331
UtlBoolean sendCustom(SIPX_TRANSPORT_DATA *pTransport, SipMessage *message, const char *sendAddress, const int sendPort)
Definition: SipUserAgent.cpp:1229
void setLocationHeader(const char *szHeader)
Definition: SipUserAgent.cpp:3734
int run(void *pArg)
Definition: SipUdpServer.cpp:349
int getDefaultExpiresSeconds() const
Definition: SipUserAgent.cpp:3548
void setMaxSrvRecords(int numRecords)
Set the maximum number of DNS SRV records to pursue in the case of failover.
Definition: SipUserAgent.cpp:3249
UtlBoolean getLocalAddress(UtlString *pIpAddress, int *pPort, SIPX_TRANSPORT_TYPE protocol=TRANSPORT_UDP)
Get the local address and port.
Definition: SipUserAgent.cpp:3118
void setDnsSrvTimeout(int timeout)
Set the number of seconds to wait before trying the next DNS SRV record.
Definition: SipUserAgent.cpp:3259
UtlBoolean isOk(OsSocket::IpProtocolSocketType socketType)
Definition: SipUserAgent.cpp:3921
virtual UtlBoolean isReady()
Definition: SipUserAgent.cpp:3869
const UtlString & getUserAgentName() const
Sets the User Agent name sent with outgoing sip messages.
Definition: SipUserAgent.cpp:3088
The CONTACT_ADDRESS structure includes contact information (IP-address and port), address source type...
Definition: sipXtapi.h:640
void setMaxTcpSocketIdleTime(int idleTimeSeconds)
Period of time a TCP socket can remain idle before it is removed.
Definition: SipUserAgent.cpp:3589
Definition: SipTransactionList.h:36
UtlBoolean addSipKeepAlive(const char *szLocalIp, const char *szRemoteIp, const int remotePort, const char *szMethod, const int keepAliveSecs, OsNatKeepaliveListener *pListener)
Definition: SipUserAgent.cpp:3019
UtlBoolean authorized(SipMessage *request, const char *uri=NULL) const
Definition: SipUserAgent.cpp:3987