00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef SIPSTACK_H_
00011 #define SIPSTACK_H_
00012
00013
00014 class SipSdp;
00015 class SipXpidf;
00016 class SipUrl;
00017 class SipCallId;
00018 class sdpCodec;
00019
00020
00022
00024
00025
00026 class SipMsg
00027 {
00028 public:
00029 SipMsg(QString Method);
00030 SipMsg();
00031 ~SipMsg();
00032 void addRequestLine(SipUrl &Url);
00033 void addStatusLine(int Code);
00034 void addVia(QString Hostname, int Port);
00035 void addTo(SipUrl &to, QString tag="", QString epid="");
00036 void addFrom(SipUrl &from, QString tag="", QString epid="");
00037 void addViaCopy(QString Via) { addGenericLine(Via); }
00038 void addToCopy(QString To, QString Tag="");
00039 void addFromCopy(QString From) { addGenericLine(From); }
00040 void addRRCopy(QString RR) { addGenericLine(RR); }
00041 void addCallId(SipCallId id);
00042 void addCSeq(int c);
00043 void addContact(SipUrl contact, QString Methods="");
00044 void addUserAgent(QString ua="MythPhone");
00045 void addAllow();
00046 void addEvent(QString Event);
00047 void addSubState(QString State, int Expires);
00048 void addAuthorization(QString authMethod, QString Username, QString Password, QString realm, QString nonce, QString uri, bool Proxy=false);
00049 void addProxyAuthorization(QString authMethod, QString Username, QString Password, QString realm, QString nonce, QString uri);
00050 void addExpires(int e);
00051 void addTimestamp(int t);
00052 void addNullContent();
00053 void addContent(QString contentType, QString contentData);
00054 void insertVia(QString Hostname, int Port);
00055 void removeVia();
00056 QString StatusPhrase(int Code);
00057 void decode(QString sipString);
00058 QString string() { return Msg; }
00059 QString getMethod() { return thisMethod; }
00060 int getCSeqValue() { return cseqValue; }
00061 QString getCSeqMethod() { return cseqMethod; }
00062 int getExpires() { return Expires; }
00063 int getTimestamp() { return Timestamp; }
00064 int getStatusCode() { return statusCode; }
00065 QString getReasonPhrase() { return statusText; }
00066 SipCallId *getCallId() { return callId; }
00067 SipMsg &operator= (SipMsg &rhs);
00068 SipSdp *getSdp() { return sdp; }
00069 SipXpidf *getXpidf() { return xpidf; }
00070 QString getPlainText() { return PlainTextContent; }
00071 SipUrl *getContactUrl() { return contactUrl; }
00072 SipUrl *getRecRouteUrl() { return recRouteUrl; }
00073 SipUrl *getFromUrl() { return fromUrl; }
00074 SipUrl *getToUrl() { return toUrl; }
00075 QString getFromTag() { return fromTag; }
00076 QString getFromEpid() { return fromEpid; }
00077 QString getToTag() { return toTag; }
00078 QString getCompleteTo() { return completeTo; }
00079 QString getCompleteFrom(){ return completeFrom; }
00080 QString getCompleteVia() { return completeVia; }
00081 QString getCompleteRR() { return completeRR; }
00082 QString getViaIp() { return viaIp; }
00083 int getViaPort() { return viaPort; }
00084 QString getAuthMethod() { return authMethod; }
00085 QString getAuthRealm() { return authRealm; }
00086 QString getAuthNonce() { return authNonce; }
00087 void addGenericLine(QString Line);
00088
00089
00090 private:
00091 void decodeLine(QString line);
00092 void decodeRequestLine(QString line);
00093 void decodeVia(QString via);
00094 void decodeFrom(QString from);
00095 void decodeTo(QString to);
00096 void decodeContact(QString contact);
00097 void decodeRecordRoute(QString rr);
00098 void decodeCseq(QString cseq);
00099 void decodeExpires(QString Exp);
00100 void decodeTimestamp(QString ts);
00101 void decodeCallid(QString callid);
00102 void decodeAuthenticate(QString auth);
00103 void decodeContentType(QString cType);
00104 void decodeSdp(QString content);
00105 void decodeXpidf(QString content);
00106 void decodePlainText(QString content);
00107 QPtrList<sdpCodec> *decodeSDPLine(QString sdpLine, QPtrList<sdpCodec> *codecList);
00108 void decodeSDPConnection(QString c);
00109 QPtrList<sdpCodec> *decodeSDPMedia(QString m);
00110 void decodeSDPMediaAttribute(QString a, QPtrList<sdpCodec> *codecList);
00111 SipUrl *decodeUrl(QString source);
00112
00113 QString Msg;
00114 QStringList attList;
00115 QString thisMethod;
00116 int statusCode;
00117 QString statusText;
00118 SipCallId *callId;
00119 int cseqValue;
00120 QString cseqMethod;
00121 int Expires;
00122 int Timestamp;
00123 bool msgContainsSDP;
00124 bool msgContainsXPIDF;
00125 bool msgContainsPlainText;
00126 SipSdp *sdp;
00127 SipXpidf *xpidf;
00128 QString PlainTextContent;
00129 SipUrl *contactUrl;
00130 SipUrl *recRouteUrl;
00131 SipUrl *fromUrl;
00132 SipUrl *toUrl;
00133 QString fromTag;
00134 QString toTag;
00135 QString fromEpid;
00136 QString completeTo;
00137 QString completeFrom;
00138 QString viaIp;
00139 int viaPort;
00140 QString completeVia;
00141 QString completeRR;
00142 QString authMethod;
00143 QString authRealm;
00144 QString authNonce;
00145 };
00146
00147
00148
00150
00152
00153 class SipUrl
00154 {
00155 public:
00156 SipUrl(QString url, QString DisplayName);
00157 SipUrl(QString dispName, QString User, QString Hostname, int Port);
00158 SipUrl(SipUrl *orig);
00159 ~SipUrl();
00160 bool operator==(SipUrl &rhs) { return (rhs.thisUser == thisUser); }
00161 const QString string() { return thisUrl; }
00162 QString getDisplay() { return thisDisplayName; }
00163 QString getUser() { return thisUser; }
00164 QString getHost() { return thisHostname; }
00165 QString getHostIp() { return thisHostIp; }
00166 QString formatReqLineUrl();
00167 QString formatContactUrl();
00168 int getPort() { return thisPort; }
00169 void setHostIp(QString ip) { thisHostIp = ip; }
00170 void setPort(int p) { thisPort = p; }
00171
00172 private:
00173 void encode();
00174 void HostnameToIpAddr();
00175
00176 QString thisDisplayName;
00177 QString thisUser;
00178 QString thisHostname;
00179 QString thisHostIp;
00180 int thisPort;
00181 QString thisUrl;
00182 };
00183
00184
00186
00188
00189 class SipCallId
00190 {
00191 public:
00192 SipCallId(QString ip);
00193 SipCallId() { thisCallid = "";}
00194 SipCallId(SipCallId &id) { thisCallid = id.string();}
00195 ~SipCallId();
00196 void Generate(QString ip);
00197 void setValue(QString v) { thisCallid = v; }
00198 const QString string() { return thisCallid; }
00199 bool operator== (SipCallId &rhs);
00200 SipCallId &operator= (SipCallId &rhs);
00201
00202 private:
00203 QString thisCallid;
00204 };
00205
00207
00209
00210 class sdpCodec
00211 {
00212 public:
00213 sdpCodec(int v, QString s, QString f="") { c=v; name=s; format=f; }
00214 ~sdpCodec() {};
00215 int intValue() {return c;}
00216 QString strValue() {return name;}
00217 QString fmtValue() {return format;}
00218 void setName(QString n) { name=n; }
00219 void setFormat(QString f) { format=f; }
00220 private:
00221 int c;
00222 QString name;
00223 QString format;
00224 };
00225
00226 class SipSdp
00227 {
00228 public:
00229 SipSdp(QString IP, int aPort, int vPort);
00230 ~SipSdp();
00231 void addAudioCodec(int c, QString descr, QString fmt="");
00232 void addVideoCodec(int c, QString descr, QString fmt="");
00233 void encode();
00234 const QString string() { return thisSdp; }
00235 int length() { return thisSdp.length(); }
00236 QPtrList<sdpCodec> *getAudioCodecList() { return &audioCodec; }
00237 QPtrList<sdpCodec> *getVideoCodecList() { return &videoCodec; }
00238 QString getMediaIP() { return MediaIp; }
00239 void setMediaIp(QString ip) { MediaIp = ip; }
00240 void setAudioPort(int p) { audioPort=p; }
00241 void setVideoPort(int p) { videoPort=p; }
00242 int getAudioPort() { return audioPort; }
00243 int getVideoPort() { return videoPort; }
00244
00245 private:
00246 QString thisSdp;
00247 QPtrList<sdpCodec> audioCodec;
00248 QPtrList<sdpCodec> videoCodec;
00249 int audioPort, videoPort;
00250 QString MediaIp;
00251 };
00252
00253
00255
00257
00258 class SipXpidf
00259 {
00260 public:
00261 SipXpidf(SipUrl &Url);
00262 SipXpidf();
00263 ~SipXpidf() {};
00264 void setUserHost(QString u, QString h) { user = u; host = h; };
00265 void setStatus(QString status, QString substatus="") { sipStatus = status; sipSubstatus = substatus; };
00266 void setSubStatus(QString substatus) { sipSubstatus = substatus; };
00267 QString encode();
00268 QString getUser() { return user; };
00269 QString getHost() { return host; };
00270 QString getStatus() { return sipStatus; };
00271 QString getSubstatus() { return sipSubstatus; };
00272
00273 private:
00274 QString user;
00275 QString host;
00276 QString sipStatus;
00277 QString sipSubstatus;
00278 };
00279
00280
00281 #endif
00282
00283