📄 sipprocessor.h
字号:
#ifndef SIPPROCESSOR_H_#define SIPPROCESSOR_H_#include "Logger.h"#include "socketcc.h"#include <string>/** * Main class for SIP request processing. */ class SipProcessor{ public: /** * Constructor * Gets a pointer to a UDPServerSocket, and the IP and the port of the caller. */ SipProcessor(UDPServerSocket* sSocket, IPAddress* callerIP, int cPort); /** * Destructor */ virtual ~SipProcessor(); /** * Processes a SIP request. The main entry point for request processing. * * Searching and publishing and request forwarding is done here and by subroutines. */ void processRequest(const std::string& request); private: // Static constants const static std::string REGISTER; const static std::string INVITE; const static std::string ACK; /** SIP Header. */ const static std::string SIP_HEADER_OK; const static std::string SIP_HEADER_TRYING; const static std::string SIP_HEADER_MOVED_TEMPORARILY; // Request buffe size const static int BUFFER_SIZE = 65535; // Fields /** Logger. */ Logger* log; /** Server socket */ UDPServerSocket* serverSocket; /** Socket open to the callee if needed. */ UDPConnectedSocket* calleeSocket; /** IP address of the caller and callee */ IPAddress* callerIPSource, calleeIPSource; /** Opened ports to caller and callee. */ int callerPort, calleePort; /** The original message send. */ std::string originalRequest; /** Prepared contact data from original request. * 0 -> name * 1 -> ip address * 2 -> port */ std::string responseContact[3]; // Private methods /** * Processes a SIP REGISTER request. The user data from the request * will be stored in kademlia networt, and the user will be from then * on available for P2P SIP calls. */ void processRegister(); /** * Processes a SIP INVITE reuest. It searches for the specified * name in TO: field in kademlia networt, and searches for user data. * If not found, a NOT FOUND response will be sent to caller. * If found, the data in original request are replaced by the one * found in kademlia network, and the prepared INVITE request will * be sent to the found user. * Then the needed message forwarding betweem caller and callee * will be done, and afterwords the function exits. */ void processInvite(); /** * If an ACK message is received directly on the listening port, * then it just needs to be forwarded to the party in the TO field. */ void processAck(); /** * Sends a response to caller indicating a server error. */ void sendServerError(); /** * Sends a response to caller indicating that request is not supported. */ void sendRequestNotSupported(); /** * Sends a response to caller indicating an invalidrequest. */ void sendInvalidRequest(); /** * Sends a response to caller indicating that a user could not be found. */ void sendNotFound(); /** * Publishes data from REGISTER message in the kademlia networt. */ void publishUserData(); /** * Prepares the INVITE message. It searches for user data in kademlia * and replaces the needed field with data found in kademlia network. * If any error happens, an errorr message is sent to requestor, * and an empty string "" is returned. */ const std::string prepareInvite(); /** * Creates the TRYING message. Becaue it takes some time to find * the user data in kademlia, the TRYING message will be instantly * sent to the caller. Then after TRYING and RINGING is received from * the callee, the RINGING message will be forwarded to the caller. */ const std::string createTryingMessage(); /** * Creates a redirection response to the INVITE message. * A search in kademlia will be done, and the Contact header * field will be replaced by the found ip address and port. */ const std::string createRedirectionMessage(); /** * Splits the contact data from register message. The data are * stored in responseContact array. */ bool splitContactData(const std::string& contactLine); /** * Returns the current date and time in SIP format. */ const std::string getDateAndTime();};#endif /*SIPPROCESSOR_H_*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -