AmSipDialog.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00028 #ifndef AmSipDialog_h
00029 #define AmSipDialog_h
00030
00031 #include "AmSipMsg.h"
00032
00033 #include <string>
00034 #include <vector>
00035 #include <map>
00036 using std::string;
00037
00038 #define MAX_SER_KEY_LEN 30
00039 #define CONTACT_USER_PREFIX "sems"
00040
00041
00042 #define SIP_FLAGS_VERBATIM 1 // send request verbatim,
00043
00044
00046 struct AmSipTransaction
00047 {
00048 string method;
00049 unsigned int cseq;
00050
00051
00052
00053
00054
00055 AmSipTransaction(const string& method, unsigned int cseq)
00056 : method(method),
00057 cseq(cseq)
00058 {}
00059
00060 AmSipTransaction()
00061 {}
00062 };
00063
00064 typedef std::map<int,AmSipTransaction> TransMap;
00065
00069 class AmSipDialogEventHandler
00070 {
00071 public:
00072 virtual void onSendRequest(const string& method,
00073 const string& content_type,
00074 const string& body,
00075 string& hdrs,
00076 int flags,
00077 unsigned int cseq)=0;
00078
00079 virtual void onSendReply(const AmSipRequest& req,
00080 unsigned int code,
00081 const string& reason,
00082 const string& content_type,
00083 const string& body,
00084 string& hdrs,
00085 int flags)=0;
00086
00087 virtual ~AmSipDialogEventHandler() {};
00088 };
00089
00093 class AmSipDialog
00094 {
00095 int status;
00096
00097 TransMap uas_trans;
00098 TransMap uac_trans;
00099
00100 AmSipDialogEventHandler* hdl;
00101 std::vector<string> route;
00102
00103 int updateStatusReply(const AmSipRequest& req,
00104 unsigned int code);
00105
00106 public:
00107 enum Status {
00108
00109 Disconnected=0,
00110 Pending,
00111 Connected,
00112 Disconnecting
00113 };
00114
00115 static const char* status2str[4];
00116
00117 string user;
00118 string domain;
00119 string sip_ip;
00120 string sip_port;
00121
00122 string local_uri;
00123 string remote_uri;
00124
00125 string contact_uri;
00126
00127 string callid;
00128 string remote_tag;
00129 string local_tag;
00130
00131 string remote_party;
00132 string local_party;
00133
00134 string getRoute();
00135 void setRoute(const string& n_route);
00136
00137 string next_hop;
00138
00139 int cseq;
00140
00141 char serKey[MAX_SER_KEY_LEN];
00142 unsigned int serKeyLen;
00143
00144 AmSipDialog(AmSipDialogEventHandler* h=0);
00145 ~AmSipDialog();
00146
00147 bool getUACTransPending() { return !uac_trans.empty(); }
00148 int getStatus() { return status; }
00149 string getContactHdr();
00150
00151 void updateStatus(const AmSipRequest& req);
00152 void updateStatus(const AmSipReply& reply);
00154 void updateStatusFromLocalRequest(const AmSipRequest& req);
00155
00156 int reply(const AmSipRequest& req,
00157 unsigned int code,
00158 const string& reason,
00159 const string& content_type = "",
00160 const string& body = "",
00161 const string& hdrs = "",
00162 int flags = 0);
00163
00164 int sendRequest(const string& method,
00165 const string& content_type = "",
00166 const string& body = "",
00167 const string& hdrs = "",
00168 int flags = 0);
00169
00170 int bye();
00171 int cancel();
00172 int update(const string& hdrs);
00173 int reinvite(const string& hdrs,
00174 const string& content_type,
00175 const string& body);
00176 int invite(const string& hdrs,
00177 const string& content_type,
00178 const string& body);
00179 int refer(const string& refer_to);
00180 int transfer(const string& target);
00181 int drop();
00182
00187 bool match_cancel(const AmSipRequest& cancel_req);
00188
00192 string get_uac_trans_method(unsigned int cseq);
00193
00194 static int reply_error(const AmSipRequest& req,
00195 unsigned int code,
00196 const string& reason,
00197 const string& hdrs = "");
00198 };
00199
00200
00201 #endif
Generated on Fri May 16 12:02:05 2008 for SEMS by
1.5.1