-
Notifications
You must be signed in to change notification settings - Fork 3
/
SipRequest.hpp
140 lines (122 loc) · 3.7 KB
/
SipRequest.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#ifndef SIPREQUEST_HPP
#define SIPREQUEST_HPP
#include "SipMessage.hpp" //Superclass
#include "lookuptable.hpp"
#include "URI.hpp"
#include <string>
namespace Sip {
/**
* \class SipRequestException
* \brief standard exception class for SipRequest
*/
class SipRequestException : public SipMessageException
{
public:
SipRequestException ( std::string what ) throw() : SipMessageException ( what ) {};
};
using std::string;
/**
* \class SipRequest
* \brief Holder for a SIP request.
* \sa SipServer::Accept(), SipMessage
*/
class SipRequest : public SipMessage
{
friend class SipUtility;
public:
enum REQUEST_METHOD
{
REQUEST_METHOD_REGISTER,
REQUEST_METHOD_INVITE,
REQUEST_METHOD_SUBSCRIBE,
REQUEST_METHOD_PUBLISH,
REQUEST_METHOD_ACK,
REQUEST_METHOD_PRACK,
REQUEST_METHOD_CANCEL,
REQUEST_METHOD_BYE,
REQUEST_METHOD_OPTIONS,
REQUEST_METHOD_MESSAGE,
REQUEST_METHOD_REFER,
REQUEST_METHOD_NOTIFY,
REQUEST_METHOD_INFO,
REQUEST_METHOD_FEATURE, //This might be 3Com specific...
REQUEST_METHOD_UPDATE
};
/**
* Creates an empty SipRequest
*/
SipRequest() throw();
/**
* Creates a SipRequest for a specific request method.
* @param rm The request type
* @sa SipRequest::REQUEST_METHOD
*/
SipRequest ( SipRequest::REQUEST_METHOD rm );
/**
* Create a request from a request. Since you would only be doing this to pass on a request, it only copies the transactionally important stuff.
* @param rhs The request to copy construct from
*/
SipRequest( const SipRequest& rhs );
/**
* Create a sip request from raw data received from a UDP packet
* @param data
*/
SipRequest ( const string& data ) throw ( SipMessageException, SipRequestException );
/**8496
* Provides request method for this SipRequest
* @return The request method
*/
SipRequest::REQUEST_METHOD RequestMethod() const throw();
/**
* Returns the request URI of the SIP request
* @return The request URI
*/
const URI& RequestURI() const throw();
/**
* Allows changing the request URI
* @param uri The new URI to use
*/
void SetRequestURI( const URI& uri ) throw();
/**
* Changes request method. If set to CANCEL, updates the CSeq method as well.
* @param rm The new request method
*/
void SetRequestMethod( const SipRequest::REQUEST_METHOD rm ) throw();
string ToString() const;
// ostream &operator<< ( ostream& stream ) const;
private:
URI m_requestURI;
REQUEST_METHOD requestMethod;
};
/**
* \class RequestTypesDef
* \brief Definition for a lookup table that converts SIP request methods as a string to the appropriate SipRequest::REQUEST_METHOD
*/
class RequestTypesDef : public LookupTable<string, SipRequest::REQUEST_METHOD>
{
public:
RequestTypesDef()
{ LoadValues(); }
private:
void LoadValues()
{
table["register"] = SipRequest::REQUEST_METHOD_REGISTER;
table["invite"] = SipRequest::REQUEST_METHOD_INVITE;
table["subscribe"] = SipRequest::REQUEST_METHOD_SUBSCRIBE;
table["publish"] = SipRequest::REQUEST_METHOD_PUBLISH;
table["ack"] = SipRequest::REQUEST_METHOD_ACK;
table["prack"] = SipRequest::REQUEST_METHOD_PRACK;
table["cancel"] = SipRequest::REQUEST_METHOD_CANCEL;
table["bye"] = SipRequest::REQUEST_METHOD_BYE;
table["options"] = SipRequest::REQUEST_METHOD_OPTIONS;
table["message"] = SipRequest::REQUEST_METHOD_MESSAGE;
table["refer"] = SipRequest::REQUEST_METHOD_REFER;
table["notify"] = SipRequest::REQUEST_METHOD_NOTIFY;
table["info"] = SipRequest::REQUEST_METHOD_INFO;
table["feature"] = SipRequest::REQUEST_METHOD_FEATURE;
table["update"] = SipRequest::REQUEST_METHOD_UPDATE;
}
};
static RequestTypesDef RequestTypes;
}; //namespace Sip
#endif //SIPREQUEST_HPP