Yate
yatesip.h
1
20
21#ifndef __YATESIP_H
22#define __YATESIP_H
23
24#include <yateclass.h>
25#include <yatemime.h>
26
27#ifdef _WINDOWS
28
29#ifdef LIBYSIP_EXPORTS
30#define YSIP_API __declspec(dllexport)
31#else
32#ifndef LIBYSIP_STATIC
33#define YSIP_API __declspec(dllimport)
34#endif
35#endif
36
37#endif /* _WINDOWS */
38
39#ifndef YSIP_API
40#define YSIP_API
41#endif
42
46namespace TelEngine {
47
51extern YSIP_API TokenDict* SIPResponses;
52
53class SIPEngine;
54class SIPEvent;
55
56class YSIP_API SIPParty : public RefObject
57{
58public:
59 SIPParty(Mutex* mutex = 0);
60 SIPParty(bool reliable, Mutex* mutex = 0);
61 virtual ~SIPParty();
67 virtual bool transmit(SIPEvent* event) = 0;
68 virtual const char* getProtoName() const = 0;
69 virtual bool setParty(const URI& uri) = 0;
70 virtual void* getTransport() = 0;
71 void setAddr(const String& addr, int port, bool local);
72 void getAddr(String& addr, int& port, bool local);
73 inline void appendAddr(String& buf, bool local, bool unsafe = true) {
74 Lock lock(unsafe ? m_mutex : 0);
75 if (local)
76 SocketAddr::appendTo(buf,m_local,m_localPort);
77 else
78 SocketAddr::appendTo(buf,m_party,m_partyPort);
79 }
80 inline Mutex* mutex()
81 { return m_mutex; }
82 inline const String& getLocalAddr() const
83 { return m_local; }
84 inline const String& getPartyAddr() const
85 { return m_party; }
86 inline int getLocalPort() const
87 { return m_localPort; }
88 inline int getPartyPort() const
89 { return m_partyPort; }
90 inline bool isReliable() const
91 { return m_reliable; }
92protected:
93 Mutex* m_mutex;
94 bool m_reliable;
95 String m_local;
96 String m_party;
97 int m_localPort;
98 int m_partyPort;
99};
100
105class YSIP_API SIPSequence : public RefObject, public Mutex
106{
107public:
112 inline SIPSequence(int32_t cseq = -1)
113 : Mutex(false,"CSeq"), m_cseq(cseq)
114 { }
115
120 inline int32_t getLastCSeq() const
121 { return m_cseq; }
122
127 inline int32_t getNextCSeq()
128 { Lock mylock(this); return (++m_cseq > 0) ? m_cseq : (m_cseq = 1); }
129
134 inline void setCSeq(int32_t cseq)
135 { m_cseq = cseq; }
136
137private:
138 int32_t m_cseq;
139};
140
147class YSIP_API SIPMessage : public RefObject
148{
149public:
153 enum Flags {
154 Defaults = 0,
155 NotReqRport = 0x0001,
156 NotAddAllow = 0x0002,
157 NotAddAgent = 0x0004,
158 RportAfterBranch = 0x0008,
159 NotSetRport = 0x0010,
160 NotSetReceived = 0x0020,
161 NoConnReuse = 0x0040, // Don't add 'alias' parameter to Via header (reliable only)
162 NoTagFailure = 0x0080, // Don't add a To tag for 3xx/4xx/5xx/6xx answers
163 };
164
168 SIPMessage(const SIPMessage& original);
169
173 SIPMessage(const char* _method, const char* _uri, const char* _version = "SIP/2.0");
174
184 SIPMessage(SIPParty* ep, const char* buf, int len = -1, unsigned int* bodyLen = 0);
185
189 SIPMessage(const SIPMessage* message, int _code, const char* _reason = 0);
190
194 SIPMessage(const SIPMessage* original, const SIPMessage* answer);
195
199 virtual ~SIPMessage();
200
211 static SIPMessage* fromParsing(SIPParty* ep, const char* buf, int len = -1,
212 unsigned int* bodyLen = 0);
213
220 void buildBody(const char* buf, int len = -1);
221
230 void complete(SIPEngine* engine, const char* user = 0, const char* domain = 0, const char* dlgTag = 0, int flags = -1);
231
239 bool copyHeader(const SIPMessage* message, const char* name, const char* newName = 0);
240
248 int copyAllHeaders(const SIPMessage* message, const char* name, const char* newName = 0);
249
254 inline SIPParty* getParty() const
255 { return m_ep; }
256
261 void setParty(SIPParty* ep = 0);
262
266 inline bool isValid() const
267 { return m_valid; }
268
272 inline bool isAnswer() const
273 { return m_answer; }
274
279 inline bool isOutgoing() const
280 { return m_outgoing; }
281
286 inline bool isACK() const
287 { return m_ack; }
288
293 inline bool isReliable() const
294 { return m_ep ? m_ep->isReliable() : false; }
295
300 inline int32_t getCSeq() const
301 { return m_cseq; }
302
307 inline void setCSeq(int32_t cseq)
308 { m_cseq = cseq; }
309
314 inline int getFlags() const
315 { return m_flags; }
316
321 inline bool dontSend() const
322 { return m_dontSend; }
323
328 inline void dontSend(bool val)
329 { m_dontSend = val; }
330
335 const MimeHeaderLine* getHeader(const char* name) const;
336
342 const MimeHeaderLine* getLastHeader(const char* name) const;
343
349 int countHeaders(const char* name) const;
350
358 const NamedString* getParam(const char* name, const char* param, bool last = false) const;
359
366 const String& getHeaderValue(const char* name, bool last = false) const;
367
375 const String& getParamValue(const char* name, const char* param, bool last = false) const;
376
382 inline void addHeader(const char* name, const char* value = 0)
383 { header.append(new MimeHeaderLine(name,value)); }
384
389 inline void addHeader(MimeHeaderLine* line)
390 { header.append(line); }
391
396 void clearHeaders(const char* name);
397
401 inline void setHeader(const char* name, const char* value = 0)
402 { clearHeaders(name); addHeader(name,value); }
403
414 MimeAuthLine* buildAuth(const String& username, const String& password,
415 const String& meth, const String& uri, bool proxy = false, SIPEngine* engine = 0) const;
416
423 MimeAuthLine* buildAuth(const SIPMessage& original, SIPEngine* engine = 0) const;
424
430 inline void setAutoAuth(const char* username = 0, const char* password = 0)
431 { m_authUser = username; m_authPass = password; }
432
437 inline const String& getAuthUsername() const
438 { return m_authUser; }
439
444 inline const String& getAuthPassword() const
445 { return m_authPass; }
446
452
457 void addRoutes(const ObjList* routes);
458
463 inline SIPSequence* getSequence() const
464 { return m_seq; }
465
470 inline void setSequence(SIPSequence* seq)
471 { m_seq = seq; }
472
476 const DataBlock& getBuffer() const;
477
481 const String& getHeaders() const;
482
486 void setBody(MimeBody* newbody = 0);
487
492 const String& traceId() const
493 { return msgTraceId; }
494
499
504
509
513 int code;
514
519
524
529 MimeBody* body;
530
535
540
541protected:
542 bool parse(const char* buf, int len, unsigned int* bodyLen);
543 bool parseFirst(String& line);
544 SIPParty* m_ep;
546 bool m_valid;
547 bool m_answer;
548 bool m_outgoing;
549 bool m_ack;
550 int32_t m_cseq;
551 int m_flags;
552 mutable String m_string;
553 mutable DataBlock m_data;
554 String m_authUser;
555 String m_authPass;
556 bool m_dontSend;
557private:
558 SIPMessage(); // no, thanks
559};
560
565class YSIP_API SIPDialog : public String
566{
567public:
571 inline SIPDialog()
572 : remoteCSeq(-1)
573 { }
574
579 SIPDialog(const SIPDialog& original);
580
585 explicit SIPDialog(const SIPMessage& message);
586
591 inline explicit SIPDialog(const String& callid)
592 : String(callid), remoteCSeq(-1)
593 { }
594
600 SIPDialog& operator=(const SIPDialog& original);
601
608
614 SIPDialog& operator=(const String& callid);
615
622 bool matches(const SIPDialog& other, bool ignoreURIs) const;
623
629 inline bool operator==(const SIPDialog& other) const
630 { return matches(other,false); }
631
637 inline bool operator!=(const SIPDialog& other) const
638 { return !matches(other,false); }
639
645 inline bool operator&=(const SIPDialog& other) const
646 { return matches(other,true); }
647
653 inline bool operator|=(const SIPDialog& other) const
654 { return !matches(other,true); }
655
661 inline const String& fromURI(bool outgoing) const
662 { return outgoing ? localURI : remoteURI; }
663
669 inline const String& fromTag(bool outgoing) const
670 { return outgoing ? localTag : remoteTag; }
671
677 inline const String& toURI(bool outgoing) const
678 { return outgoing ? remoteURI : localURI; }
679
685 inline const String& toTag(bool outgoing) const
686 { return outgoing ? remoteTag : localTag; }
687
692 inline SIPSequence* getSequence() const
693 { return m_seq; }
694
699 inline void setSequence(SIPSequence* seq)
700 { m_seq = seq; }
701
706 void setCSeq(int32_t cseq);
707
712 inline int32_t getLastCSeq() const
713 { return m_seq ? m_seq->getLastCSeq() : -1; }
714
719 inline int32_t getNextCSeq()
720 { return m_seq ? m_seq->getNextCSeq() : -1; }
721
727 inline bool adjustCSeq(int cseq)
728 { return (cseq > remoteCSeq) && ((remoteCSeq = cseq) >= 0); }
729
735 inline bool adjustCSeq(const SIPMessage* message)
736 { return message && adjustCSeq(message->getCSeq()); }
737
742
747
752
757
762
763protected:
765};
766
771class YSIP_API SIPTransaction : public RefObject
772{
773public:
777 enum State {
778 // Invalid state - before constructor or after destructor
779 Invalid,
780
781 // Initial state - after the initial message was inserted
782 Initial,
783
784 // Trying state - got the message but no decision made yet
785 Trying,
786
787 // Process state - while locally processing the event
788 Process,
789
790 // Retrans state - retransmits latest message until getting ACK
791 Retrans,
792
793 // Finish state - transmits the last message on client retransmission
794 Finish,
795
796 // Cleared state - removed from engine, awaiting destruction
797 Cleared
798 };
799
804 // Not matched at all
805 NoMatch,
806
807 // Belongs to another dialog - probably result of a fork
808 NoDialog,
809
810 // Matched to transaction/dialog and processed
811 Matched
812 };
813
822 SIPTransaction(SIPMessage* message, SIPEngine* engine, bool outgoing = true,
823 bool* autoChangeParty = 0);
824
830 SIPTransaction(const SIPTransaction& original, const String& tag);
831
836
840 static const char* stateName(int state);
841
846 inline int getState() const
847 { return m_state; }
848
853 inline bool isActive() const
854 { return (Invalid < m_state) && (m_state < Finish); }
855
859 inline const SIPMessage* initialMessage() const
860 { return m_firstMessage; }
861
865 inline const SIPMessage* latestMessage() const
866 { return m_lastMessage; }
867
871 inline const SIPMessage* recentMessage() const
872 { return m_lastMessage ? m_lastMessage : m_firstMessage; }
873
877 inline SIPEngine* getEngine() const
878 { return m_engine; }
879
884 inline bool isOutgoing() const
885 { return m_outgoing; }
886
891 inline bool isIncoming() const
892 { return !m_outgoing; }
893
898 inline bool isInvite() const
899 { return m_invite; }
900
905 inline bool isReliable() const
906 { return m_firstMessage ? m_firstMessage->isReliable() : false; }
907
911 inline const String& getMethod() const
912 { return m_firstMessage ? m_firstMessage->method : String::empty(); }
913
917 inline const String& getURI() const
918 { return m_firstMessage ? m_firstMessage->uri : String::empty(); }
919
924 inline const String& getBranch() const
925 { return m_branch; }
926
931 inline const String& getCallID() const
932 { return m_callid; }
933
938 inline const String& getDialogTag() const
939 { return m_tag; }
940
945 void setDialogTag(const char* tag = 0);
946
951 inline void setTransmit()
952 { m_transmit = true; }
953
958 inline void setCleared()
959 { changeState(Cleared); }
960
965 inline unsigned int getTransCount() const
966 { return m_transCount; }
967
972 void setTransCount(int count);
973
978 inline bool autoAck() const
979 { return m_autoAck; }
980
985 inline void autoAck(bool setAuto)
986 { m_autoAck = setAuto; }
987
995 void requestAuth(const String& realm, const String& domain, bool stale, bool proxy = false);
996
1005 int authUser(String& user, bool proxy = false, GenObject* userData = 0);
1006
1015 virtual Processed processMessage(SIPMessage* message, const String& branch);
1016
1022 virtual void processMessage(SIPMessage* message);
1023
1033 virtual SIPEvent* getEvent(bool pendingOnly = false, u_int64_t time = 0);
1034
1039 bool setResponse() const;
1040
1047 bool setResponse(int code, const char* reason = 0);
1048
1052 void setResponse(SIPMessage* message);
1053
1058 inline int getResponseCode() const
1059 { return m_response; }
1060
1066 bool setAcknowledge(MimeBody* ackBody = 0);
1067
1073
1077 inline void setUserData(void* data)
1078 { m_private = data; }
1079
1083 inline void* getUserData() const
1084 { return m_private; }
1085
1090
1095 const String& traceId() const
1096 { return m_traceId; }
1097
1098protected:
1105
1109 virtual void destroyed();
1110
1117
1125 virtual SIPEvent* getClientEvent(int state, int timeout);
1126
1134 virtual SIPEvent* getServerEvent(int state, int timeout);
1135
1142 virtual void processClientMessage(SIPMessage* message, int state);
1143
1150 virtual void processServerMessage(SIPMessage* message, int state);
1151
1157 bool changeState(int newstate);
1158
1163 void setLatestMessage(SIPMessage* message = 0);
1164
1170 void setPendingEvent(SIPEvent* event = 0, bool replace = false);
1171
1176 inline bool isPendingEvent() const
1177 { return (m_pending != 0); }
1178
1184 void setTimeout(u_int64_t delay = 0, unsigned int count = 1);
1185
1186 bool m_outgoing;
1187 bool m_invite;
1188 bool m_transmit;
1189 int m_state;
1190 int m_response;
1191 unsigned int m_transCount;
1192 unsigned int m_timeouts;
1193 u_int64_t m_delay;
1194 u_int64_t m_timeout;
1195 SIPMessage* m_firstMessage;
1196 SIPMessage* m_lastMessage;
1197 SIPEvent* m_pending;
1198 SIPEngine* m_engine;
1199 String m_branch;
1200 String m_callid;
1201 String m_tag;
1202 void *m_private;
1203 bool m_autoChangeParty;
1204 bool m_autoAck;
1205 bool m_silent;
1206 String m_traceId;
1207};
1208
1213class YSIP_API SIPEvent
1214{
1215 friend class SIPTransaction;
1216public:
1217
1218 SIPEvent()
1219 : m_message(0), m_transaction(0), m_state(SIPTransaction::Invalid)
1220 { }
1221
1222 SIPEvent(SIPMessage* message, SIPTransaction* transaction = 0);
1223
1224 ~SIPEvent();
1225
1230 inline SIPEngine* getEngine() const
1231 { return m_transaction ? m_transaction->getEngine() : 0; }
1232
1237 inline SIPMessage* getMessage() const
1238 { return m_message; }
1239
1244 inline SIPTransaction* getTransaction() const
1245 { return m_transaction; }
1246
1251 inline bool isOutgoing() const
1252 { return m_message && m_message->isOutgoing(); }
1253
1258 inline bool isIncoming() const
1259 { return m_message && !m_message->isOutgoing(); }
1260
1264 inline SIPParty* getParty() const
1265 { return m_message ? m_message->getParty() : 0; }
1266
1270 inline void* getUserData() const
1271 { return m_transaction ? m_transaction->getUserData() : 0; }
1272
1276 inline int getState() const
1277 { return m_state; }
1278
1283 inline bool isActive() const
1284 { return (SIPTransaction::Invalid < m_state) && (m_state < SIPTransaction::Finish); }
1285
1290 inline const String& traceId() const
1291 { return m_transaction ? m_transaction->traceId() : String::empty(); }
1292
1293protected:
1294 SIPMessage* m_message;
1295 SIPTransaction* m_transaction;
1296 int m_state;
1297};
1298
1303class YSIP_API SIPEngine : public DebugEnabler, public Mutex
1304{
1305public:
1309 SIPEngine(const char* userAgent = 0);
1310
1314 virtual ~SIPEngine();
1315
1321 virtual bool buildParty(SIPMessage* message) = 0;
1322
1327 virtual void allocTraceId(String& id) = 0;
1328
1334 virtual void traceMsg(SIPMessage* message, bool incoming = true) = 0;
1335
1349 virtual bool checkUser(String& username, const String& realm, const String& nonce,
1350 const String& method, const String& uri, const String& response,
1351 const SIPMessage* message, const MimeHeaderLine* authLine, GenObject* userData);
1352
1363 virtual bool checkAuth(bool noUser, String& username, const SIPMessage* message,
1364 const MimeHeaderLine* authLine, GenObject* userData);
1365
1375 int authUser(const SIPMessage* message, String& user, bool proxy = false, GenObject* userData = 0);
1376
1384 SIPTransaction* addMessage(SIPParty* ep, const char* buf, int len = -1);
1385
1394
1403
1409 bool process();
1410
1417 virtual void processEvent(SIPEvent *event);
1418
1426
1433 virtual u_int64_t getUserTimeout() const;
1434
1441 u_int64_t getTimer(char which, bool reliable = false) const;
1442
1448 inline unsigned int getReqTransCount() const
1449 { return m_reqTransCount; }
1450
1456 inline unsigned int getRspTransCount() const
1457 { return m_rspTransCount; }
1458
1463 inline unsigned int getMaxForwards() const
1464 { return m_maxForwards; }
1465
1469 inline const String& getUserAgent() const
1470 { return m_userAgent; }
1471
1476 inline SIPSequence* getSequence() const
1477 { return m_seq; }
1478
1483 inline int32_t getNextCSeq()
1484 { return m_seq->getNextCSeq(); }
1485
1490 inline bool lazyTrying() const
1491 { return m_lazyTrying; }
1492
1497 inline void lazyTrying(bool lazy100)
1498 { m_lazyTrying = lazy100; }
1499
1504 inline int flags() const
1505 { return m_flags; }
1506
1511 inline bool autoChangeParty() const
1512 { return m_autoChangeParty; }
1513
1518 void nonceGet(String& nonce);
1519
1525 long nonceAge(const String& nonce);
1526
1531 void ncGet(String& nc);
1532
1544 static void buildAuth(const String& username, const String& realm, const String& passwd,
1545 const String& nonce, const String& method, const String& uri, String& response,
1546 const NamedList& qop = NamedList::empty());
1547
1555 static void buildAuth(const String& hash_a1, const String& nonce, const String& hash_a2,
1556 String& response);
1557
1563 bool isAllowed(const char* method) const;
1564
1569 void addAllowed(const char* method);
1570
1575 inline const String& getAllowed() const
1576 { return m_allowed; }
1577
1582 inline void remove(SIPTransaction* transaction)
1583 { lock(); m_transList.remove(transaction,false); unlock(); }
1584
1589 inline void append(SIPTransaction* transaction)
1590 { lock(); m_transList.append(transaction); unlock(); }
1591
1596 inline void insert(SIPTransaction* transaction)
1597 { lock(); m_transList.insert(transaction); unlock(); }
1598
1603 inline unsigned int transactionCount()
1604 { Lock mylock(this); return m_transList.count(); }
1605
1606protected:
1611
1612 u_int64_t m_t1;
1613 u_int64_t m_t4;
1614 int m_reqTransCount;
1615 int m_rspTransCount;
1616 unsigned int m_maxForwards;
1617 int m_flags;
1618 bool m_lazyTrying;
1619 String m_userAgent;
1620 String m_allowed;
1622 u_int32_t m_nc;
1623 String m_nonce;
1624 String m_nonce_secret;
1625 u_int32_t m_nonce_time;
1626 Mutex m_nonce_mutex;
1627 bool m_autoChangeParty;
1628};
1629
1630}
1631
1632#endif /* __YATESIP_H */
1633
1634/* vi: set ts=8 sw=4 sts=4 noet: */
A class that holds just a block of raw data.
Definition yateclass.h:4237
DebugEnabler(int level=TelEngine::debugLevel(), bool enabled=true)
Definition yateclass.h:319
Definition yateclass.h:1049
virtual const String & traceId() const
Ephemeral mutex or semaphore locking object.
Definition yateclass.h:5833
Mutex support.
Definition yateclass.h:5607
virtual bool unlock()
Mutex(bool recursive=false, const char *name=0)
virtual bool lock(long maxwait=-1)
A named string container class.
Definition yateclass.h:5016
static const NamedList & empty()
A named string class.
Definition yateclass.h:3481
An object list class.
Definition yateclass.h:1454
Templated smart pointer class.
Definition yateclass.h:1306
SIPDialog(const SIPMessage &message)
int remoteCSeq
Definition yatesip.h:761
int32_t getNextCSeq()
Definition yatesip.h:719
SIPDialog & operator=(const SIPDialog &original)
SIPSequence * getSequence() const
Definition yatesip.h:692
void setSequence(SIPSequence *seq)
Definition yatesip.h:699
void setCSeq(int32_t cseq)
SIPDialog(const String &callid)
Definition yatesip.h:591
String localTag
Definition yatesip.h:746
bool adjustCSeq(const SIPMessage *message)
Definition yatesip.h:735
bool matches(const SIPDialog &other, bool ignoreURIs) const
bool operator&=(const SIPDialog &other) const
Definition yatesip.h:645
String localURI
Definition yatesip.h:741
SIPDialog & operator=(const String &callid)
String remoteTag
Definition yatesip.h:756
bool adjustCSeq(int cseq)
Definition yatesip.h:727
const String & toTag(bool outgoing) const
Definition yatesip.h:685
const String & fromTag(bool outgoing) const
Definition yatesip.h:669
int32_t getLastCSeq() const
Definition yatesip.h:712
const String & toURI(bool outgoing) const
Definition yatesip.h:677
bool operator==(const SIPDialog &other) const
Definition yatesip.h:629
SIPDialog(const SIPDialog &original)
bool operator!=(const SIPDialog &other) const
Definition yatesip.h:637
String remoteURI
Definition yatesip.h:751
bool operator|=(const SIPDialog &other) const
Definition yatesip.h:653
SIPDialog & operator=(const SIPMessage &message)
SIPDialog()
Definition yatesip.h:571
const String & fromURI(bool outgoing) const
Definition yatesip.h:661
The SIP engine and transaction list.
Definition yatesip.h:1304
void addAllowed(const char *method)
void lazyTrying(bool lazy100)
Definition yatesip.h:1497
unsigned int getMaxForwards() const
Definition yatesip.h:1463
int32_t getNextCSeq()
Definition yatesip.h:1483
SIPSequence * getSequence() const
Definition yatesip.h:1476
virtual void allocTraceId(String &id)=0
const String & getAllowed() const
Definition yatesip.h:1575
unsigned int getReqTransCount() const
Definition yatesip.h:1448
const String & getUserAgent() const
Definition yatesip.h:1469
SIPEngine(const char *userAgent=0)
static void buildAuth(const String &hash_a1, const String &nonce, const String &hash_a2, String &response)
virtual SIPTransaction * forkInvite(SIPMessage *answer, SIPTransaction *trans)
virtual void processEvent(SIPEvent *event)
SIPTransaction * addMessage(SIPParty *ep, const char *buf, int len=-1)
long nonceAge(const String &nonce)
bool autoChangeParty() const
Definition yatesip.h:1511
void remove(SIPTransaction *transaction)
Definition yatesip.h:1582
ObjList m_transList
Definition yatesip.h:1610
bool lazyTrying() const
Definition yatesip.h:1490
SIPTransaction * addMessage(SIPMessage *message, bool *autoChangeParty=0)
unsigned int getRspTransCount() const
Definition yatesip.h:1456
virtual ~SIPEngine()
virtual bool checkAuth(bool noUser, String &username, const SIPMessage *message, const MimeHeaderLine *authLine, GenObject *userData)
unsigned int transactionCount()
Definition yatesip.h:1603
void nonceGet(String &nonce)
int flags() const
Definition yatesip.h:1504
void ncGet(String &nc)
virtual void traceMsg(SIPMessage *message, bool incoming=true)=0
virtual u_int64_t getUserTimeout() const
int authUser(const SIPMessage *message, String &user, bool proxy=false, GenObject *userData=0)
virtual bool checkUser(String &username, const String &realm, const String &nonce, const String &method, const String &uri, const String &response, const SIPMessage *message, const MimeHeaderLine *authLine, GenObject *userData)
u_int64_t getTimer(char which, bool reliable=false) const
bool isAllowed(const char *method) const
virtual bool buildParty(SIPMessage *message)=0
void insert(SIPTransaction *transaction)
Definition yatesip.h:1596
SIPEvent * getEvent()
void append(SIPTransaction *transaction)
Definition yatesip.h:1589
static void buildAuth(const String &username, const String &realm, const String &passwd, const String &nonce, const String &method, const String &uri, String &response, const NamedList &qop=NamedList::empty())
bool process()
A SIP event as retrieved from engine.
Definition yatesip.h:1214
bool isActive() const
Definition yatesip.h:1283
const String & traceId() const
Definition yatesip.h:1290
void * getUserData() const
Definition yatesip.h:1270
SIPParty * getParty() const
Definition yatesip.h:1264
SIPTransaction * getTransaction() const
Definition yatesip.h:1244
SIPEngine * getEngine() const
Definition yatesip.h:1230
bool isIncoming() const
Definition yatesip.h:1258
bool isOutgoing() const
Definition yatesip.h:1251
SIPMessage * getMessage() const
Definition yatesip.h:1237
int getState() const
Definition yatesip.h:1276
A container and parser for SIP messages.
Definition yatesip.h:148
SIPMessage(const SIPMessage *original, const SIPMessage *answer)
MimeAuthLine * buildAuth(const SIPMessage &original, SIPEngine *engine=0) const
int copyAllHeaders(const SIPMessage *message, const char *name, const char *newName=0)
SIPMessage(const char *_method, const char *_uri, const char *_version="SIP/2.0")
void setHeader(const char *name, const char *value=0)
Definition yatesip.h:401
void setParty(SIPParty *ep=0)
void setAutoAuth(const char *username=0, const char *password=0)
Definition yatesip.h:430
SIPMessage(const SIPMessage &original)
String msgTraceId
Definition yatesip.h:534
MimeBody * body
Definition yatesip.h:529
const String & getAuthPassword() const
Definition yatesip.h:444
int countHeaders(const char *name) const
const String & traceId() const
Definition yatesip.h:492
virtual ~SIPMessage()
SIPSequence * getSequence() const
Definition yatesip.h:463
void addRoutes(const ObjList *routes)
int code
Definition yatesip.h:513
void setSequence(SIPSequence *seq)
Definition yatesip.h:470
void setCSeq(int32_t cseq)
Definition yatesip.h:307
const String & getAuthUsername() const
Definition yatesip.h:437
ObjList * getRoutes() const
bool isValid() const
Definition yatesip.h:266
static SIPMessage * fromParsing(SIPParty *ep, const char *buf, int len=-1, unsigned int *bodyLen=0)
String version
Definition yatesip.h:498
bool msgPrint
Definition yatesip.h:539
SIPParty * getParty() const
Definition yatesip.h:254
int getFlags() const
Definition yatesip.h:314
MimeAuthLine * buildAuth(const String &username, const String &password, const String &meth, const String &uri, bool proxy=false, SIPEngine *engine=0) const
bool isAnswer() const
Definition yatesip.h:272
void buildBody(const char *buf, int len=-1)
bool isReliable() const
Definition yatesip.h:293
void complete(SIPEngine *engine, const char *user=0, const char *domain=0, const char *dlgTag=0, int flags=-1)
String reason
Definition yatesip.h:518
const String & getHeaders() const
SIPMessage(SIPParty *ep, const char *buf, int len=-1, unsigned int *bodyLen=0)
int32_t getCSeq() const
Definition yatesip.h:300
bool isACK() const
Definition yatesip.h:286
bool isOutgoing() const
Definition yatesip.h:279
void dontSend(bool val)
Definition yatesip.h:328
const String & getHeaderValue(const char *name, bool last=false) const
Flags
Definition yatesip.h:153
void addHeader(const char *name, const char *value=0)
Definition yatesip.h:382
const DataBlock & getBuffer() const
ObjList header
Definition yatesip.h:523
String uri
Definition yatesip.h:508
void addHeader(MimeHeaderLine *line)
Definition yatesip.h:389
const NamedString * getParam(const char *name, const char *param, bool last=false) const
const String & getParamValue(const char *name, const char *param, bool last=false) const
SIPMessage(const SIPMessage *message, int _code, const char *_reason=0)
bool dontSend() const
Definition yatesip.h:321
const MimeHeaderLine * getLastHeader(const char *name) const
bool copyHeader(const SIPMessage *message, const char *name, const char *newName=0)
const MimeHeaderLine * getHeader(const char *name) const
void setBody(MimeBody *newbody=0)
String method
Definition yatesip.h:503
void clearHeaders(const char *name)
Definition yatesip.h:57
virtual bool transmit(SIPEvent *event)=0
SIP CSeq generator.
Definition yatesip.h:106
SIPSequence(int32_t cseq=-1)
Definition yatesip.h:112
int32_t getNextCSeq()
Definition yatesip.h:127
void setCSeq(int32_t cseq)
Definition yatesip.h:134
int32_t getLastCSeq() const
Definition yatesip.h:120
A class holding one SIP transaction.
Definition yatesip.h:772
virtual void processMessage(SIPMessage *message)
virtual Processed processMessage(SIPMessage *message, const String &branch)
void setTransCount(int count)
bool isPendingEvent() const
Definition yatesip.h:1176
void setUserData(void *data)
Definition yatesip.h:1077
virtual SIPEvent * getServerEvent(int state, int timeout)
void setTransmit()
Definition yatesip.h:951
SIPTransaction(SIPTransaction &original, SIPMessage *answer)
virtual ~SIPTransaction()
int getResponseCode() const
Definition yatesip.h:1058
virtual void processServerMessage(SIPMessage *message, int state)
SIPTransaction(const SIPTransaction &original, const String &tag)
SIPTransaction(SIPMessage *message, SIPEngine *engine, bool outgoing=true, bool *autoChangeParty=0)
virtual void destroyed()
void setLatestMessage(SIPMessage *message=0)
virtual void processClientMessage(SIPMessage *message, int state)
bool isActive() const
Definition yatesip.h:853
bool tryAutoAuth(SIPMessage *answer)
const String & traceId() const
Definition yatesip.h:1095
void * getUserData() const
Definition yatesip.h:1083
const String & getURI() const
Definition yatesip.h:917
bool isInvite() const
Definition yatesip.h:898
int authUser(String &user, bool proxy=false, GenObject *userData=0)
State
Definition yatesip.h:777
Processed
Definition yatesip.h:803
bool autoAck() const
Definition yatesip.h:978
const SIPMessage * latestMessage() const
Definition yatesip.h:865
void msgTransmitFailed(SIPMessage *msg)
const SIPMessage * recentMessage() const
Definition yatesip.h:871
void setPendingEvent(SIPEvent *event=0, bool replace=false)
void setDialogTag(const char *tag=0)
virtual SIPEvent * getEvent(bool pendingOnly=false, u_int64_t time=0)
bool setResponse(int code, const char *reason=0)
bool isReliable() const
Definition yatesip.h:905
SIPEngine * getEngine() const
Definition yatesip.h:877
bool isIncoming() const
Definition yatesip.h:891
void requestAuth(const String &realm, const String &domain, bool stale, bool proxy=false)
bool isOutgoing() const
Definition yatesip.h:884
const String & getCallID() const
Definition yatesip.h:931
virtual SIPEvent * getClientEvent(int state, int timeout)
const String & getDialogTag() const
Definition yatesip.h:938
bool setAcknowledge(MimeBody *ackBody=0)
void setResponse(SIPMessage *message)
const String & getMethod() const
Definition yatesip.h:911
void autoAck(bool setAuto)
Definition yatesip.h:985
int getState() const
Definition yatesip.h:846
bool changeState(int newstate)
static const char * stateName(int state)
const String & getBranch() const
Definition yatesip.h:924
const SIPMessage * initialMessage() const
Definition yatesip.h:859
void setTimeout(u_int64_t delay=0, unsigned int count=1)
void setCleared()
Definition yatesip.h:958
unsigned int getTransCount() const
Definition yatesip.h:965
bool setResponse() const
static String & appendTo(String &buf, const String &addr, int port, int family=Unknown)
Definition yateclass.h:6713
A C-style string handling class.
Definition yateclass.h:2131
static const String & empty()
Encapsulation for an URI.
Definition yateclass.h:5396
Definition yatemime.h:34