forked from YeeYoungHan/cppsipstack
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSipStack.h
More file actions
130 lines (103 loc) · 4.02 KB
/
Copy pathSipStack.h
File metadata and controls
130 lines (103 loc) · 4.02 KB
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
/*
* Copyright (C) 2012 Yee Young Han <websearch@naver.com> (http://blog.naver.com/websearch)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _SIP_STACK_H_
#define _SIP_STACK_H_
#include "SipStackDefine.h"
#include "SipTcp.h"
#include "SipStatusCode.h"
#include "SipICTList.h"
#include "SipNICTList.h"
#include "SipISTList.h"
#include "SipNISTList.h"
#include "SipStackSetup.h"
#include "SipStackCallBack.h"
#include "TcpThreadList.h"
#include "TcpSocketMap.h"
#include "TcpConnectMap.h"
typedef std::list< ISipStackCallBack * > SIP_STACK_CALLBACK_LIST;
/**
* @defgroup SipStack SipStack
* SIP Stack 라이브러리
*/
/**
* @ingroup SipStack
* @brief SIP stack 클래스
*/
class CSipStack
{
public:
CSipStack();
~CSipStack();
bool Start( CSipStackSetup & clsSetup );
bool Stop( );
bool Execute( struct timeval * psttTime );
void IncreateUdpThreadCount( int & iThreadId );
void DecreateUdpThreadCount();
void IncreateTcpThreadCount( int & iThreadId );
void DecreateTcpThreadCount();
void GetString( CMonitorString & strBuf );
void GetICTString( CMonitorString & strBuf );
void Final();
void DeleteAllTransaction();
// SipStackCallBack.hpp
bool AddCallBack( ISipStackCallBack * pclsCallBack );
bool DeleteCallBack( ISipStackCallBack * pclsCallBack );
void SetSecurityCallBack( ISipStackSecurityCallBack * pclsSecurityCallBack );
void RecvRequest( int iThreadId, CSipMessage * pclsMessage );
void RecvResponse( int iThreadId, CSipMessage * pclsMessage );
void SendTimeout( int iThreadId, CSipMessage * pclsMessage );
void TcpSessionEnd( const char * pszIp, int iPort, ESipTransport eTransport );
void ThreadEnd( int iThreadId );
// SipStackComm.hpp
bool SendSipMessage( CSipMessage * pclsMessage );
bool RecvSipMessage( int iThreadId, CSipMessage * pclsMessage );
bool RecvSipMessage( int iThreadId, const char * pszBuf, int iBufLen, const char * pszIp, unsigned short iPort, ESipTransport eTransport );
bool Send( CSipMessage * pclsMessage, bool bCheckMessage = true );
bool Send( const char * pszMessage, const char * pszIp, unsigned short iPort, ESipTransport eTransport );
bool m_bStopEvent; // SIP stack thread 종료 이벤트
bool m_bStackThreadRun; // SIP stack thread 가 실행 중에 있는가?
Socket m_hUdpSocket; // UDP SIP 메시지 전송/수신 소켓 핸들
Socket m_hTcpSocket; // TCP SIP 메시지를 위한 서버 소켓 핸들
CSipMutex m_clsUdpRecvMutex; // SIP 메시지 수신 뮤텍스
CSipStackSetup m_clsSetup; // SIP stack 설정
CThreadList m_clsTcpThreadList;
CTcpSocketMap m_clsTcpSocketMap;
CTcpConnectMap m_clsTcpConnectMap;
#ifdef USE_TLS
Socket m_hTlsSocket; // TLS SIP 메시지를 위한 서버 소켓 핸들
CThreadList m_clsTlsThreadList;
CTcpSocketMap m_clsTlsSocketMap;
CTcpConnectMap m_clsTlsConnectMap;
#endif
private:
bool m_bStarted;
int m_iUdpThreadRunCount; // UDP 수신 쓰레드 개수
int m_iTcpThreadRunCount; // TCP 수신 쓰레드 개수
CSipMutex m_clsMutex;
CSipMutex m_clsUdpSendMutex; // SIP 메시지 전송 뮤텍스
CSipICTList m_clsICT;
CSipNICTList m_clsNICT;
CSipISTList m_clsIST;
CSipNISTList m_clsNIST;
SIP_STACK_CALLBACK_LIST m_clsCallBackList;
ISipStackSecurityCallBack * m_pclsSecurityCallBack;
bool _Stop( );
int GetTcpConnectingCount( );
void CheckSipMessage( CSipMessage * pclsMessage );
};
#endif