Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Achou.Wang
4Gsim
提交
fd7fc027
4
4Gsim
项目概览
Achou.Wang
/
4Gsim
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
4
4Gsim
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fd7fc027
编写于
7月 04, 2012
作者:
C
calincerchez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
got to connection
上级
59c26afd
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
421 addition
and
265 deletion
+421
-265
src/applications/diameter/DiameterApplication.cc
src/applications/diameter/DiameterApplication.cc
+0
-0
src/applications/diameter/DiameterApplication.h
src/applications/diameter/DiameterApplication.h
+5
-0
src/applications/diameter/DiameterBase.cc
src/applications/diameter/DiameterBase.cc
+0
-3
src/applications/diameter/DiameterBase.h
src/applications/diameter/DiameterBase.h
+3
-3
src/applications/diameter/DiameterConnection.cc
src/applications/diameter/DiameterConnection.cc
+50
-0
src/applications/diameter/DiameterConnection.h
src/applications/diameter/DiameterConnection.h
+21
-1
src/applications/diameter/DiameterPeer.cc
src/applications/diameter/DiameterPeer.cc
+94
-16
src/applications/diameter/DiameterPeer.h
src/applications/diameter/DiameterPeer.h
+213
-0
src/applications/diameter/DiameterSession.cc
src/applications/diameter/DiameterSession.cc
+2
-2
src/applications/diameter/DiameterSession.h
src/applications/diameter/DiameterSession.h
+33
-9
src/applications/diameter/connection/DiameterConnectionMap.cc
...applications/diameter/connection/DiameterConnectionMap.cc
+0
-68
src/applications/diameter/connection/DiameterConnectionMap.h
src/applications/diameter/connection/DiameterConnectionMap.h
+0
-40
src/applications/diameter/peer/DiameterPeerTable.cc
src/applications/diameter/peer/DiameterPeerTable.cc
+0
-82
src/applications/diameter/peer/DiameterPeerTable.h
src/applications/diameter/peer/DiameterPeerTable.h
+0
-41
未找到文件。
src/applications/diameter/
peer/
DiameterApplication.cc
→
src/applications/diameter/DiameterApplication.cc
浏览文件 @
fd7fc027
文件已移动
src/applications/diameter/
peer/
DiameterApplication.h
→
src/applications/diameter/DiameterApplication.h
浏览文件 @
fd7fc027
...
@@ -21,6 +21,11 @@
...
@@ -21,6 +21,11 @@
#define TGPP 10415
#define TGPP 10415
#define S6a 16777251
#define S6a 16777251
/*
* Class for holding info about Diameter application. At the moment
* it only holds application id and vendor id for S6a application.
* Maybe it should be moved in peer class...
*/
class
DiameterApplication
{
class
DiameterApplication
{
public:
public:
unsigned
applId
;
unsigned
applId
;
...
...
src/applications/diameter/DiameterBase.cc
浏览文件 @
fd7fc027
...
@@ -165,10 +165,7 @@ void DiameterBase::loadPeersFromXML(const cXMLElement& diameterNode) {
...
@@ -165,10 +165,7 @@ void DiameterBase::loadPeersFromXML(const cXMLElement& diameterNode) {
DiameterConnection
*
conn
=
createConnection
(
addresses
,
port
);
DiameterConnection
*
conn
=
createConnection
(
addresses
,
port
);
DiameterPeer
*
peer
=
createPeer
(
fqdn
,
realm
,
conn
,
appl
);
DiameterPeer
*
peer
=
createPeer
(
fqdn
,
realm
,
conn
,
appl
);
peer
->
setType
(
STATIC
);
peer
->
setType
(
STATIC
);
peer
->
startTimer
(
peer
->
tcTimer
,
"TC-TIMER"
,
TC_TIMER_TIMEOUT
);
conn
->
setPeer
(
peer
);
conn
->
setPeer
(
peer
);
}
}
}
}
}
}
...
...
src/applications/diameter/DiameterBase.h
浏览文件 @
fd7fc027
...
@@ -21,9 +21,9 @@
...
@@ -21,9 +21,9 @@
#include <omnetpp.h>
#include <omnetpp.h>
#include <string>
#include <string>
#include "SCTPSocket.h"
#include "SCTPSocket.h"
#include "DiameterConnection
Map
.h"
#include "DiameterConnection.h"
#include "DiameterSession.h"
#include "DiameterSession.h"
#include "DiameterPeer
Table
.h"
#include "DiameterPeer.h"
#include "RoutingTableAccess.h"
#include "RoutingTableAccess.h"
/*
/*
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
* Diameter base class holds the server socket from which each Diameter connection is forked.
* Diameter base class holds the server socket from which each Diameter connection is forked.
* Also it manages the connection table, peer table and session table.
* Also it manages the connection table, peer table and session table.
*
*
*
All
Diameter base protocol model is implemented according to RFC 3588.
* Diameter base protocol model is implemented according to RFC 3588.
*/
*/
class
DiameterBase
:
public
cSimpleModule
{
class
DiameterBase
:
public
cSimpleModule
{
protected:
protected:
...
...
src/applications/diameter/
connection/
DiameterConnection.cc
→
src/applications/diameter/DiameterConnection.cc
浏览文件 @
fd7fc027
...
@@ -222,3 +222,53 @@ unsigned DiameterConnection::processOrigin(DiameterPeer *&peer, DiameterMessage
...
@@ -222,3 +222,53 @@ unsigned DiameterConnection::processOrigin(DiameterPeer *&peer, DiameterMessage
}
}
return
DIAMETER_SUCCESS
;
return
DIAMETER_SUCCESS
;
}
}
DiameterConnectionMap
::
DiameterConnectionMap
()
{
// TODO Auto-generated constructor stub
}
DiameterConnectionMap
::~
DiameterConnectionMap
()
{
// TODO Auto-generated destructor stub
}
DiameterConnection
*
DiameterConnectionMap
::
findConnectionFor
(
cMessage
*
msg
)
{
SCTPCommand
*
ind
=
dynamic_cast
<
SCTPCommand
*>
(
msg
->
getControlInfo
());
if
(
!
ind
)
opp_error
(
"DiameterConnectionMap: findConnectionFor(): no SCTPCommand control info in message (not from SCTP?)"
);
int
assocId
=
ind
->
getAssocId
();
ConnMap
::
iterator
i
=
connMap
.
find
(
assocId
);
ASSERT
(
i
==
connMap
.
end
()
||
i
->
first
==
i
->
second
->
getConnectionId
());
return
(
i
==
connMap
.
end
())
?
NULL
:
i
->
second
;
}
void
DiameterConnectionMap
::
addConnection
(
DiameterConnection
*
conn
)
{
ASSERT
(
connMap
.
find
(
conn
->
getConnectionId
())
==
connMap
.
end
());
connMap
[
conn
->
getConnectionId
()]
=
conn
;
}
DiameterConnection
*
DiameterConnectionMap
::
removeConnection
(
DiameterConnection
*
conn
)
{
ConnMap
::
iterator
i
=
connMap
.
find
(
conn
->
getConnectionId
());
if
(
i
!=
connMap
.
end
())
connMap
.
erase
(
i
);
printConnectionMap
();
return
conn
;
}
/*
void DiameterConnectionMap::deleteConnections()
{
for (ConnMap::iterator i = connMap.begin(); i != connMap.end(); ++i)
delete i->second;
}
*/
void
DiameterConnectionMap
::
printConnectionMap
()
{
EV
<<
"=====================================================================
\n
"
<<
"Connection Map:
\n
"
<<
"-------------------------------------------------------------------------------
\n
"
<<
"Conn Id
\t
| Local Addr
\t
| Local Port
\t
| Remote Addr
\t
| Remote Port
\n
"
<<
"---------------------------------------------------------------------
\n
"
;
for
(
ConnMap
::
iterator
i
=
connMap
.
begin
();
i
!=
connMap
.
end
();
++
i
)
EV
<<
(
i
->
second
)
->
getConnectionId
()
<<
endl
;
// << "\t| " << (i->second)->getLocalAddresses().at(0) << "\t| " << "" << "\t| " << "" << "\t| " << "" << endl;
EV
<<
"=====================================================================
\n
"
;
}
src/applications/diameter/
connection/
DiameterConnection.h
→
src/applications/diameter/DiameterConnection.h
浏览文件 @
fd7fc027
...
@@ -29,10 +29,13 @@
...
@@ -29,10 +29,13 @@
class
DiameterPeer
;
class
DiameterPeer
;
class
DiameterBase
;
class
DiameterBase
;
/*
* Class for Diameter connection.
*/
class
DiameterConnection
:
public
SCTPSocket
::
CallbackInterface
{
class
DiameterConnection
:
public
SCTPSocket
::
CallbackInterface
{
private:
private:
bool
type
;
// initiator or responder
bool
type
;
// initiator or responder
bool
ignore
;
bool
ignore
;
// used because socketClosed is called twice
DiameterBase
*
module
;
DiameterBase
*
module
;
DiameterPeer
*
peer
;
DiameterPeer
*
peer
;
...
@@ -71,4 +74,21 @@ public:
...
@@ -71,4 +74,21 @@ public:
int
getConnectionId
()
{
return
socket
->
getConnectionId
();
}
int
getConnectionId
()
{
return
socket
->
getConnectionId
();
}
};
};
class
DiameterConnectionMap
{
private:
typedef
std
::
map
<
int
,
DiameterConnection
*>
ConnMap
;
ConnMap
connMap
;
public:
DiameterConnectionMap
();
virtual
~
DiameterConnectionMap
();
DiameterConnection
*
findConnectionFor
(
cMessage
*
msg
);
void
addConnection
(
DiameterConnection
*
conn
);
DiameterConnection
*
removeConnection
(
DiameterConnection
*
conn
);
unsigned
int
size
()
{
return
connMap
.
size
();}
// void deleteConnections();
void
printConnectionMap
();
};
#endif
/* DIAMETERCONNECTION_H_ */
#endif
/* DIAMETERCONNECTION_H_ */
src/applications/diameter/
peer/
DiameterPeer.cc
→
src/applications/diameter/DiameterPeer.cc
浏览文件 @
fd7fc027
...
@@ -20,10 +20,6 @@
...
@@ -20,10 +20,6 @@
#include "DiameterUtils.h"
#include "DiameterUtils.h"
#include "DiameterSerializer.h"
#include "DiameterSerializer.h"
DiameterPeerStateVariables
::
DiameterPeerStateVariables
()
{
msg
=
NULL
;
}
DiameterPeer
::
DiameterPeer
(
DiameterBase
*
module
)
{
DiameterPeer
::
DiameterPeer
(
DiameterBase
*
module
)
{
// TODO Auto-generated constructor stub
// TODO Auto-generated constructor stub
this
->
module
=
module
;
this
->
module
=
module
;
...
@@ -37,19 +33,21 @@ DiameterPeer::DiameterPeer(DiameterBase *module) {
...
@@ -37,19 +33,21 @@ DiameterPeer::DiameterPeer(DiameterBase *module) {
fsm
.
setName
(
fsmname
);
fsm
.
setName
(
fsmname
);
fsm
.
setState
(
CLOSED
);
fsm
.
setState
(
CLOSED
);
state
=
new
DiameterPeerStateVariables
();
iConn
=
NULL
;
iConn
=
NULL
;
rConn
=
NULL
;
rConn
=
NULL
;
tsTimer
=
NULL
;
startTimer
(
tcTimer
,
"TC-TIMER"
,
TC_TIMER_TIMEOUT
)
;
tcTimer
=
NULL
;
tcTimer
=
NULL
;
twTimer
=
NULL
;
twTimer
=
NULL
;
teTimer
=
NULL
;
teTimer
=
NULL
;
appl
=
NULL
;
appl
=
NULL
;
msg
=
NULL
;
}
}
DiameterPeer
::~
DiameterPeer
()
{
DiameterPeer
::~
DiameterPeer
()
{
// TODO Auto-generated destructor stub
// TODO Auto-generated destructor stub
delete
state
;
// msg will be deleted at receiver end
if
(
twTimer
!=
NULL
)
{
if
(
twTimer
!=
NULL
)
{
if
(
twTimer
->
getContextPointer
()
!=
NULL
)
if
(
twTimer
->
getContextPointer
()
!=
NULL
)
module
->
cancelEvent
(
twTimer
);
module
->
cancelEvent
(
twTimer
);
...
@@ -72,6 +70,7 @@ DiameterPeer::~DiameterPeer() {
...
@@ -72,6 +70,7 @@ DiameterPeer::~DiameterPeer() {
}
}
if
(
appl
!=
NULL
)
if
(
appl
!=
NULL
)
delete
appl
;
delete
appl
;
// iConn and rConn will be deleted in connection map
// iConn and rConn will be deleted in connection map
}
}
...
@@ -147,7 +146,7 @@ void DiameterPeer::performStateTransition(PeerEvent &event, DiameterMessage *msg
...
@@ -147,7 +146,7 @@ void DiameterPeer::performStateTransition(PeerEvent &event, DiameterMessage *msg
if
((
resCode
/
1000
)
!=
2
)
{
if
((
resCode
/
1000
)
!=
2
)
{
break
;
break
;
}
}
state
->
msg
=
msg
;
this
->
msg
=
msg
;
FSM_Goto
(
fsm
,
WAIT_CONN_ACK_ELECT
);
FSM_Goto
(
fsm
,
WAIT_CONN_ACK_ELECT
);
break
;
break
;
}
}
...
@@ -174,7 +173,7 @@ void DiameterPeer::performStateTransition(PeerEvent &event, DiameterMessage *msg
...
@@ -174,7 +173,7 @@ void DiameterPeer::performStateTransition(PeerEvent &event, DiameterMessage *msg
if
((
resCode
/
1000
)
!=
2
)
{
if
((
resCode
/
1000
)
!=
2
)
{
break
;
break
;
}
}
state
->
msg
=
msg
;
this
->
msg
=
msg
;
FSM_Goto
(
fsm
,
WAIT_RETURNS
);
FSM_Goto
(
fsm
,
WAIT_RETURNS
);
break
;
break
;
}
}
...
@@ -201,7 +200,7 @@ void DiameterPeer::performStateTransition(PeerEvent &event, DiameterMessage *msg
...
@@ -201,7 +200,7 @@ void DiameterPeer::performStateTransition(PeerEvent &event, DiameterMessage *msg
FSM_Goto
(
fsm
,
WAIT_RETURNS
);
FSM_Goto
(
fsm
,
WAIT_RETURNS
);
break
;
break
;
case
I_RCV_CONN_NACK
:
case
I_RCV_CONN_NACK
:
sendCEA
(
rConn
,
state
->
msg
,
DIAMETER_SUCCESS
);
sendCEA
(
rConn
,
this
->
msg
,
DIAMETER_SUCCESS
);
FSM_Goto
(
fsm
,
R_OPEN
);
FSM_Goto
(
fsm
,
R_OPEN
);
break
;
break
;
case
R_PEER_DISC
:
case
R_PEER_DISC
:
...
@@ -227,7 +226,7 @@ void DiameterPeer::performStateTransition(PeerEvent &event, DiameterMessage *msg
...
@@ -227,7 +226,7 @@ void DiameterPeer::performStateTransition(PeerEvent &event, DiameterMessage *msg
switch
(
event
)
{
switch
(
event
)
{
case
WIN_ELECTION
:
case
WIN_ELECTION
:
iDisconnect
();
iDisconnect
();
sendCEA
(
rConn
,
state
->
msg
,
DIAMETER_SUCCESS
);
sendCEA
(
rConn
,
this
->
msg
,
DIAMETER_SUCCESS
);
FSM_Goto
(
fsm
,
R_OPEN
);
FSM_Goto
(
fsm
,
R_OPEN
);
break
;
break
;
case
I_PEER_DISC
:
case
I_PEER_DISC
:
...
@@ -261,7 +260,7 @@ void DiameterPeer::performStateTransition(PeerEvent &event, DiameterMessage *msg
...
@@ -261,7 +260,7 @@ void DiameterPeer::performStateTransition(PeerEvent &event, DiameterMessage *msg
switch
(
event
)
{
switch
(
event
)
{
case
SEND_MESSAGE
:
case
SEND_MESSAGE
:
sendApplMessage
(
rConn
,
msg
);
sendApplMessage
(
rConn
,
msg
);
//
remain
in this state
//
stay
in this state
break
;
break
;
case
R_RCV_MESSAGE
:
case
R_RCV_MESSAGE
:
processApplMessage
(
rConn
,
msg
);
processApplMessage
(
rConn
,
msg
);
...
@@ -311,11 +310,11 @@ void DiameterPeer::performStateTransition(PeerEvent &event, DiameterMessage *msg
...
@@ -311,11 +310,11 @@ void DiameterPeer::performStateTransition(PeerEvent &event, DiameterMessage *msg
switch
(
event
)
{
switch
(
event
)
{
case
SEND_MESSAGE
:
case
SEND_MESSAGE
:
sendApplMessage
(
iConn
,
msg
);
sendApplMessage
(
iConn
,
msg
);
//
remain
in this state
//
stay
in this state
break
;
break
;
case
I_RCV_MESSAGE
:
case
I_RCV_MESSAGE
:
processApplMessage
(
iConn
,
msg
);
processApplMessage
(
iConn
,
msg
);
//
remain
in this state
//
stay
in this state
break
;
break
;
case
I_RCV_DWR
:
{
case
I_RCV_DWR
:
{
unsigned
resCode
=
processDWR
(
msg
);
unsigned
resCode
=
processDWR
(
msg
);
...
@@ -677,11 +676,90 @@ void DiameterPeer::elect() {
...
@@ -677,11 +676,90 @@ void DiameterPeer::elect() {
}
}
}
}
bool
DiameterPeer
::
getConnectionType
()
{
const
char
*
DiameterPeer
::
getTypeName
(){
if
(
type
==
STATIC
)
return
"STATIC"
;
else
return
"DYNAMIC"
;
}
int
DiameterPeer
::
getConnectionId
()
{
if
(
rConn
==
NULL
)
return
iConn
->
getConnectionId
();
else
return
rConn
->
getConnectionId
();
}
int
DiameterPeer
::
getConnectionType
()
{
if
(
iConn
!=
NULL
)
if
(
iConn
!=
NULL
)
return
INITIATOR
;
return
INITIATOR
;
else
if
(
rConn
!=
NULL
)
else
if
(
rConn
!=
NULL
)
return
RESPONDER
;
return
RESPONDER
;
else
else
return
0
;
return
-
1
;
}
}
DiameterPeerTable
::
DiameterPeerTable
()
{
// TODO Auto-generated constructor stub
}
DiameterPeerTable
::~
DiameterPeerTable
()
{
// TODO Auto-generated destructor stub
}
DiameterPeer
*
DiameterPeerTable
::
findPeer
(
std
::
string
dFQDN
,
std
::
string
dRealm
)
{
if
(
dRealm
==
""
)
{
for
(
unsigned
i
=
0
;
i
<
peers
.
size
();
i
++
)
{
DiameterPeer
*
peer
=
peers
[
i
];
if
((
peer
->
dFQDN
.
find
(
dFQDN
))
!=
std
::
string
::
npos
)
return
peer
;
}
}
else
{
for
(
unsigned
i
=
0
;
i
<
peers
.
size
();
i
++
)
{
DiameterPeer
*
peer
=
peers
[
i
];
if
((
peer
->
dFQDN
==
dFQDN
)
&&
(
peer
->
dRealm
==
dRealm
))
return
peer
;
}
}
return
NULL
;
}
DiameterPeer
*
DiameterPeerTable
::
findPeer
(
unsigned
applId
)
{
for
(
unsigned
i
=
0
;
i
<
peers
.
size
();
i
++
)
{
DiameterPeer
*
peer
=
peers
[
i
];
if
(
peer
->
appl
->
applId
==
applId
)
return
peer
;
}
return
NULL
;
}
void
DiameterPeerTable
::
erase
(
unsigned
start
,
unsigned
end
)
{
PeerTable
::
iterator
first
=
peers
.
begin
()
+
start
;
PeerTable
::
iterator
last
=
peers
.
begin
()
+
end
;
PeerTable
::
iterator
i
=
first
;
for
(;
i
!=
last
;
++
i
)
delete
*
i
;
peers
.
erase
(
first
,
last
);
}
void
DiameterPeerTable
::
print
()
{
EV
<<
"=====================================================================
\n
"
<<
"Diameter Peer Table:
\n
"
;
for
(
unsigned
int
i
=
0
;
i
<
peers
.
size
();
i
++
)
{
EV
<<
"DiameterPeer nr. "
<<
i
<<
":{
\n
"
;
DiameterPeer
*
peer
=
peers
.
at
(
i
);
EV
<<
"
\t
origFQDN:"
<<
peer
->
oFQDN
<<
endl
;
EV
<<
"
\t
destFQDN:"
<<
peer
->
dFQDN
<<
endl
;
EV
<<
"
\t
state:"
<<
peer
->
stateName
(
peer
->
getState
())
<<
endl
;
if
(
peer
->
appl
)
{
EV
<<
"
\t
appl:{
\n
"
;
EV
<<
"
\t\t
applId:"
<<
peer
->
appl
->
applId
<<
endl
;
EV
<<
"
\t\t
vendorId:"
<<
peer
->
appl
->
vendorId
<<
endl
;
EV
<<
"}
\n
"
;
}
EV
<<
"}
\n
"
;
}
EV
<<
"=====================================================================
\n
"
;
}
src/applications/diameter/
peer/
DiameterPeer.h
→
src/applications/diameter/DiameterPeer.h
浏览文件 @
fd7fc027
...
@@ -72,18 +72,57 @@ enum PeerEvent {
...
@@ -72,18 +72,57 @@ enum PeerEvent {
STOP
STOP
};
};
class
DiameterPeerStateVariables
:
public
cPolymorphic
{
/*
public:
* Class for Diameter peer. A Diameter peer can have a initiating
DiameterPeerStateVariables
();
* or a responding Diameter connection which is basically just the
DiameterMessage
*
msg
;
// for inter state message handling
* SCTP socket. It can have both for a limited period of time during
};
* the election process. All the message processing (base protocol
* messages and application messages) is done during the state machine
* changes, described in the specification. For more info contact RFC 3588.
*/
class
DiameterPeer
:
public
cPolymorphic
{
class
DiameterPeer
:
public
cPolymorphic
{
private:
private:
bool
type
;
bool
type
;
// dummy
bool
isTLSEnabled
;
bool
isTLSEnabled
;
// dummy
DiameterBase
*
module
;
DiameterBase
*
module
;
cFSM
fsm
;
cFSM
fsm
;
DiameterMessage
*
msg
;
// for inter state message handling
cMessage
*
tcTimer
;
// connection initiation timer
cMessage
*
twTimer
;
// watchdog
cMessage
*
tsTimer
;
// test timer
cMessage
*
teTimer
;
// connection expire timer
/*
* Methods for base protocol message processing. CER and CEA are
* for connection setup, DWR and DWA are the watchdog messages,
* DPR and DPA are termination messages.
*/
void
sendCER
(
DiameterConnection
*
conn
);
unsigned
processCER
(
DiameterMessage
*
msg
);
void
sendCEA
(
DiameterConnection
*
conn
,
DiameterMessage
*
cer
,
unsigned
resCode
);
unsigned
processCEA
(
DiameterMessage
*
msg
);
void
sendDWR
(
DiameterConnection
*
conn
);
unsigned
processDWR
(
DiameterMessage
*
msg
);
void
sendDWA
(
DiameterConnection
*
conn
,
DiameterMessage
*
dwr
,
unsigned
resCode
);
unsigned
processDWA
(
DiameterMessage
*
msg
);
void
sendDPR
(
DiameterConnection
*
conn
);
void
sendDPA
(
DiameterConnection
*
conn
,
DiameterMessage
*
dpr
);
/*
* Methods for cleaning up the Diameter connections.
*/
void
iDisconnect
();
void
rDisconnect
();
void
cleanup
();
void
error
()
{
cleanup
();
}
/*
* Method for electing the Diameter connection which will be used by the peer.
* Election is done by comparing destination FQDN with origin FQDN and is
* described in more detail in the standard.
*/
void
elect
();
public:
public:
std
::
string
dFQDN
;
std
::
string
dFQDN
;
std
::
string
oFQDN
;
std
::
string
oFQDN
;
...
@@ -92,56 +131,83 @@ public:
...
@@ -92,56 +131,83 @@ public:
DiameterApplication
*
appl
;
DiameterApplication
*
appl
;
DiameterConnection
*
iConn
;
DiameterConnection
*
iConn
;
DiameterConnection
*
rConn
;
DiameterConnection
*
rConn
;
cMessage
*
tcTimer
;
cMessage
*
twTimer
;
// watchdog
cMessage
*
tsTimer
;
// test timer
cMessage
*
teTimer
;
// connection expire timer
private:
DiameterPeerStateVariables
*
state
;
void
sendCER
(
DiameterConnection
*
conn
);
unsigned
processCER
(
DiameterMessage
*
msg
);
void
sendCEA
(
DiameterConnection
*
conn
,
DiameterMessage
*
cer
,
unsigned
resCode
);
unsigned
processCEA
(
DiameterMessage
*
msg
);
void
sendDWR
(
DiameterConnection
*
conn
);
unsigned
processDWR
(
DiameterMessage
*
msg
);
void
sendDWA
(
DiameterConnection
*
conn
,
DiameterMessage
*
dwr
,
unsigned
resCode
);
unsigned
processDWA
(
DiameterMessage
*
msg
);
void
sendDPR
(
DiameterConnection
*
conn
);
void
sendDPA
(
DiameterConnection
*
conn
,
DiameterMessage
*
dpr
);
const
char
*
stateName
(
int
state
);
const
char
*
eventName
(
int
event
);
public:
DiameterPeer
(
DiameterBase
*
module
);
DiameterPeer
(
DiameterBase
*
module
);
virtual
~
DiameterPeer
();
virtual
~
DiameterPeer
();
void
iDisconnect
();
/*
void
rDisconnect
();
* Getter methods.
void
cleanup
();
*/
void
error
()
{
cleanup
();
}
void
elect
();
DiameterConnection
*
getIConnection
()
{
return
iConn
;
}
DiameterConnection
*
getRConnection
()
{
return
rConn
;
}
bool
getType
()
{
return
type
;
}
bool
getType
()
{
return
type
;
}
const
char
*
getTypeName
()
{
if
(
type
==
STATIC
)
return
"STATIC"
;
else
return
"DYNAMIC"
;
}
const
char
*
getTypeName
();
void
setType
(
bool
type
)
{
this
->
type
=
type
;
}
int
getConnectionType
();
bool
getConnectionType
();
int
getConnectionId
();
int
getConnectionId
()
{
if
(
rConn
==
NULL
)
return
iConn
->
getConnectionId
();
else
return
rConn
->
getConnectionId
();
}
int
getState
()
{
return
fsm
.
getState
();
}
int
getState
()
{
return
fsm
.
getState
();
}
const
char
*
getStateName
()
{
return
stateName
(
fsm
.
getState
());
}
/*
* Setter methods.
*/
void
setType
(
bool
type
)
{
this
->
type
=
type
;
}
/*
* Utility methods for timer.
*/
void
startTimer
(
cMessage
*&
timer
,
const
char
*
name
,
simtime_t
timeout
);
void
processTimer
(
cMessage
*
timer
);
void
processTimer
(
cMessage
*
timer
);
/*
* Utility methods for state processing.
*/
void
performStateTransition
(
PeerEvent
&
event
,
DiameterMessage
*
msg
);
void
performStateTransition
(
PeerEvent
&
event
,
DiameterMessage
*
msg
);
void
stateEntered
();
void
stateEntered
();
const
char
*
stateName
(
int
state
);
const
char
*
eventName
(
int
event
);
void
startTimer
(
cMessage
*&
timer
,
const
char
*
name
,
simtime_t
timeout
);
/*
* Methods for processing the application messages. The application
* messages are forwarded and received from the appropriate session.
*/
void
sendApplMessage
(
DiameterConnection
*
conn
,
DiameterMessage
*
msg
);
void
sendApplMessage
(
DiameterConnection
*
conn
,
DiameterMessage
*
msg
);
void
processApplMessage
(
DiameterConnection
*
conn
,
DiameterMessage
*
msg
);
void
processApplMessage
(
DiameterConnection
*
conn
,
DiameterMessage
*
msg
);
};
};
/*
* Class for Diameter peer table. This table will hold all the peers
* owned by the Diameter base protocol model implementation.
*/
class
DiameterPeerTable
{
private:
typedef
std
::
vector
<
DiameterPeer
*>
PeerTable
;
PeerTable
peers
;
public:
DiameterPeerTable
();
virtual
~
DiameterPeerTable
();
/*
* Methods for find a Diameter peer. The method returns the
* peer if it is found, or NULL otherwise.
*/
DiameterPeer
*
findPeer
(
std
::
string
dFQDN
,
std
::
string
dRealm
=
""
);
DiameterPeer
*
findPeer
(
unsigned
applId
);
/*
* Method for deleting Diameter peer. The method calls first
* the destructor for each peer between start and end position
* and removes them afterwards.
*/
void
erase
(
unsigned
start
,
unsigned
end
);
/*
* Method for printing the peer table.
*/
void
print
();
/*
* Wrapper methods.
*/
void
push_back
(
DiameterPeer
*
peer
)
{
peers
.
push_back
(
peer
);
}
unsigned
size
()
{
return
peers
.
size
();
}
DiameterPeer
*
at
(
unsigned
i
)
{
return
peers
[
i
];
}
};
#endif
/* DIAMETERPEER_H_ */
#endif
/* DIAMETERPEER_H_ */
src/applications/diameter/DiameterSession.cc
浏览文件 @
fd7fc027
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
DiameterSession
::
DiameterSession
(
DiameterBase
*
module
,
bool
state
)
{
DiameterSession
::
DiameterSession
(
DiameterBase
*
module
,
bool
state
)
{
// TODO Auto-generated constructor stub
// TODO Auto-generated constructor stub
this
->
state
=
stat
e
;
this
->
type
=
typ
e
;
this
->
module
=
module
;
this
->
module
=
module
;
char
time
[
10
];
char
time
[
10
];
...
@@ -81,7 +81,7 @@ void DiameterSession::performStateTransition(SessionEvent &event, unsigned applI
...
@@ -81,7 +81,7 @@ void DiameterSession::performStateTransition(SessionEvent &event, unsigned applI
void
DiameterSession
::
sendDiameterMessage
(
unsigned
applId
,
DiameterPeer
*
peer
,
DiameterMessage
*
msg
)
{
void
DiameterSession
::
sendDiameterMessage
(
unsigned
applId
,
DiameterPeer
*
peer
,
DiameterMessage
*
msg
)
{
msg
->
insertAvp
(
0
,
DiameterUtils
().
createUTF8StringAVP
(
AVP_SessionId
,
0
,
1
,
0
,
0
,
id
));
msg
->
insertAvp
(
0
,
DiameterUtils
().
createUTF8StringAVP
(
AVP_SessionId
,
0
,
1
,
0
,
0
,
id
));
msg
->
insertAvp
(
1
,
DiameterUtils
().
createInteger32AVP
(
AVP_AuthSessionState
,
0
,
1
,
0
,
0
,
stat
e
?
NO_STATE_MAINTAINED
:
STATE_MAINTAINED
));
msg
->
insertAvp
(
1
,
DiameterUtils
().
createInteger32AVP
(
AVP_AuthSessionState
,
0
,
1
,
0
,
0
,
typ
e
?
NO_STATE_MAINTAINED
:
STATE_MAINTAINED
));
PeerEvent
event
=
SEND_MESSAGE
;
PeerEvent
event
=
SEND_MESSAGE
;
peer
->
performStateTransition
(
event
,
msg
);
peer
->
performStateTransition
(
event
,
msg
);
}
}
...
...
src/applications/diameter/DiameterSession.h
浏览文件 @
fd7fc027
...
@@ -42,9 +42,9 @@ enum SessionEvent {
...
@@ -42,9 +42,9 @@ enum SessionEvent {
};
};
/*
/*
* Class
Diameter session. The class implements the session state machin
e
* Class
for Diameter session. The class implements the session stat
e
*
and processes Diameter application messages which are not meant for
*
machine and processes Diameter application messages which are not
* Diameter base protocol.
*
meant for
Diameter base protocol.
*/
*/
class
DiameterSession
:
public
cPolymorphic
{
class
DiameterSession
:
public
cPolymorphic
{
private:
private:
...
@@ -54,9 +54,10 @@ private:
...
@@ -54,9 +54,10 @@ private:
// cMessage *sTimer;
// cMessage *sTimer;
DiameterBase
*
module
;
DiameterBase
*
module
;
const
char
*
stateName
(
int
state
);
/*
const
char
*
eventName
(
int
event
);
* Methods for sending and processing Diameter messages. Message handling
* will not be done directly, it will be done during a state transition.
*/
void
sendDiameterMessage
(
unsigned
applId
,
DiameterPeer
*
peer
,
DiameterMessage
*
req
);
void
sendDiameterMessage
(
unsigned
applId
,
DiameterPeer
*
peer
,
DiameterMessage
*
req
);
void
processDiameterMessage
(
unsigned
applId
,
DiameterPeer
*
peer
,
DiameterMessage
*
msg
);
void
processDiameterMessage
(
unsigned
applId
,
DiameterPeer
*
peer
,
DiameterMessage
*
msg
);
public:
public:
...
@@ -64,13 +65,22 @@ public:
...
@@ -64,13 +65,22 @@ public:
virtual
~
DiameterSession
();
virtual
~
DiameterSession
();
/*
/*
* Getter methods
* Getter methods
.
*/
*/
std
::
string
getId
()
{
return
id
;
}
std
::
string
getId
()
{
return
id
;
}
/*
* Methods for managing the session state machine
*/
void
performStateTransition
(
SessionEvent
&
event
,
unsigned
applId
,
DiameterPeer
*
peer
,
DiameterMessage
*
msg
);
void
performStateTransition
(
SessionEvent
&
event
,
unsigned
applId
,
DiameterPeer
*
peer
,
DiameterMessage
*
msg
);
const
char
*
stateName
(
int
state
);
const
char
*
eventName
(
int
event
);
};
};
/*
* Class for Diameter session table. This table will hold all the sessions
* owned by the Diameter base protocol model implementation.
*/
class
DiameterSessionTable
{
class
DiameterSessionTable
{
private:
private:
typedef
std
::
vector
<
DiameterSession
*>
SessionTable
;
typedef
std
::
vector
<
DiameterSession
*>
SessionTable
;
...
@@ -79,11 +89,25 @@ public:
...
@@ -79,11 +89,25 @@ public:
DiameterSessionTable
();
DiameterSessionTable
();
virtual
~
DiameterSessionTable
();
virtual
~
DiameterSessionTable
();
/*
* Method for find a Diameter session with a specific id. The method
* returns the session if it is found, or NULL otherwise.
*/
DiameterSession
*
find
(
std
::
string
id
);
DiameterSession
*
find
(
std
::
string
id
);
DiameterSession
*
at
(
unsigned
i
)
{
return
sessions
.
at
(
i
);
}
void
push_back
(
DiameterSession
*
session
)
{
sessions
.
push_back
(
session
);
}
/*
* Method for deleting Diameter sessions. The method calls first
* the destructor for each session between start and end position
* and removes them afterwards.
*/
void
erase
(
unsigned
start
,
unsigned
end
);
void
erase
(
unsigned
start
,
unsigned
end
);
/*
* Wrapper methods.
*/
unsigned
size
()
{
return
sessions
.
size
();}
unsigned
size
()
{
return
sessions
.
size
();}
DiameterSession
*
at
(
unsigned
i
)
{
return
sessions
.
at
(
i
);
}
void
push_back
(
DiameterSession
*
session
)
{
sessions
.
push_back
(
session
);
}
// void deleteSessions();
// void deleteSessions();
};
};
...
...
src/applications/diameter/connection/DiameterConnectionMap.cc
已删除
100644 → 0
浏览文件 @
59c26afd
//
// Copyright (C) 2012 Calin Cerchez
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
#include "DiameterConnectionMap.h"
DiameterConnectionMap
::
DiameterConnectionMap
()
{
// TODO Auto-generated constructor stub
}
DiameterConnectionMap
::~
DiameterConnectionMap
()
{
// TODO Auto-generated destructor stub
}
DiameterConnection
*
DiameterConnectionMap
::
findConnectionFor
(
cMessage
*
msg
)
{
SCTPCommand
*
ind
=
dynamic_cast
<
SCTPCommand
*>
(
msg
->
getControlInfo
());
if
(
!
ind
)
opp_error
(
"DiameterConnectionMap: findConnectionFor(): no SCTPCommand control info in message (not from SCTP?)"
);
int
assocId
=
ind
->
getAssocId
();
ConnMap
::
iterator
i
=
connMap
.
find
(
assocId
);
ASSERT
(
i
==
connMap
.
end
()
||
i
->
first
==
i
->
second
->
getConnectionId
());
return
(
i
==
connMap
.
end
())
?
NULL
:
i
->
second
;
}
void
DiameterConnectionMap
::
addConnection
(
DiameterConnection
*
conn
)
{
ASSERT
(
connMap
.
find
(
conn
->
getConnectionId
())
==
connMap
.
end
());
connMap
[
conn
->
getConnectionId
()]
=
conn
;
}
DiameterConnection
*
DiameterConnectionMap
::
removeConnection
(
DiameterConnection
*
conn
)
{
ConnMap
::
iterator
i
=
connMap
.
find
(
conn
->
getConnectionId
());
if
(
i
!=
connMap
.
end
())
connMap
.
erase
(
i
);
printConnectionMap
();
return
conn
;
}
/*
void DiameterConnectionMap::deleteConnections()
{
for (ConnMap::iterator i = connMap.begin(); i != connMap.end(); ++i)
delete i->second;
}
*/
void
DiameterConnectionMap
::
printConnectionMap
()
{
EV
<<
"=====================================================================
\n
"
<<
"Connection Map:
\n
"
<<
"-------------------------------------------------------------------------------
\n
"
<<
"Conn Id
\t
| Local Addr
\t
| Local Port
\t
| Remote Addr
\t
| Remote Port
\n
"
<<
"---------------------------------------------------------------------
\n
"
;
for
(
ConnMap
::
iterator
i
=
connMap
.
begin
();
i
!=
connMap
.
end
();
++
i
)
EV
<<
(
i
->
second
)
->
getConnectionId
()
<<
endl
;
// << "\t| " << (i->second)->getLocalAddresses().at(0) << "\t| " << "" << "\t| " << "" << "\t| " << "" << endl;
EV
<<
"=====================================================================
\n
"
;
}
src/applications/diameter/connection/DiameterConnectionMap.h
已删除
100644 → 0
浏览文件 @
59c26afd
//
// Copyright (C) 2012 Calin Cerchez
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
#ifndef DIAMETERCONNECTIONMAP_H_
#define DIAMETERCONNECTIONMAP_H_
#include "DiameterConnection.h"
class
DiameterConnectionMap
{
private:
typedef
std
::
map
<
int
,
DiameterConnection
*>
ConnMap
;
ConnMap
connMap
;
public:
DiameterConnectionMap
();
virtual
~
DiameterConnectionMap
();
DiameterConnection
*
findConnectionFor
(
cMessage
*
msg
);
void
addConnection
(
DiameterConnection
*
conn
);
DiameterConnection
*
removeConnection
(
DiameterConnection
*
conn
);
unsigned
int
size
()
{
return
connMap
.
size
();}
// void deleteConnections();
void
printConnectionMap
();
};
#endif
/* DIAMETERCONNECTIONMAP_H_ */
src/applications/diameter/peer/DiameterPeerTable.cc
已删除
100644 → 0
浏览文件 @
59c26afd
//
// Copyright (C) 2012 Calin Cerchez
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
#include "DiameterPeerTable.h"
DiameterPeerTable
::
DiameterPeerTable
()
{
// TODO Auto-generated constructor stub
}
DiameterPeerTable
::~
DiameterPeerTable
()
{
// TODO Auto-generated destructor stub
}
DiameterPeer
*
DiameterPeerTable
::
findPeer
(
std
::
string
dFQDN
,
std
::
string
dRealm
)
{
if
(
dRealm
==
""
)
{
for
(
unsigned
i
=
0
;
i
<
peers
.
size
();
i
++
)
{
DiameterPeer
*
peer
=
peers
[
i
];
if
((
peer
->
dFQDN
.
find
(
dFQDN
))
!=
std
::
string
::
npos
)
return
peer
;
}
}
else
{
for
(
unsigned
i
=
0
;
i
<
peers
.
size
();
i
++
)
{
DiameterPeer
*
peer
=
peers
[
i
];
if
((
peer
->
dFQDN
==
dFQDN
)
&&
(
peer
->
dRealm
==
dRealm
))
return
peer
;
}
}
return
NULL
;
}
DiameterPeer
*
DiameterPeerTable
::
findPeer
(
unsigned
applId
)
{
for
(
unsigned
i
=
0
;
i
<
peers
.
size
();
i
++
)
{
DiameterPeer
*
peer
=
peers
[
i
];
if
(
peer
->
appl
->
applId
==
applId
)
return
peer
;
}
return
NULL
;
}
void
DiameterPeerTable
::
erase
(
unsigned
start
,
unsigned
end
)
{
PeerTable
::
iterator
first
=
peers
.
begin
()
+
start
;
PeerTable
::
iterator
last
=
peers
.
begin
()
+
end
;
PeerTable
::
iterator
i
=
first
;
for
(;
i
!=
last
;
++
i
)
delete
*
i
;
peers
.
erase
(
first
,
last
);
}
void
DiameterPeerTable
::
print
()
{
EV
<<
"=====================================================================
\n
"
<<
"Diameter Peer Table:
\n
"
;
for
(
unsigned
int
i
=
0
;
i
<
peers
.
size
();
i
++
)
{
EV
<<
"DiameterPeer nr. "
<<
i
<<
":{
\n
"
;
DiameterPeer
*
peer
=
peers
.
at
(
i
);
EV
<<
"
\t
origFQDN:"
<<
peer
->
oFQDN
<<
endl
;
EV
<<
"
\t
destFQDN:"
<<
peer
->
dFQDN
<<
endl
;
EV
<<
"
\t
state:"
<<
peer
->
getStateName
()
<<
endl
;
if
(
peer
->
appl
)
{
EV
<<
"
\t
appl:{
\n
"
;
EV
<<
"
\t\t
applId:"
<<
peer
->
appl
->
applId
<<
endl
;
EV
<<
"
\t\t
vendorId:"
<<
peer
->
appl
->
vendorId
<<
endl
;
EV
<<
"}
\n
"
;
}
EV
<<
"}
\n
"
;
}
EV
<<
"=====================================================================
\n
"
;
}
src/applications/diameter/peer/DiameterPeerTable.h
已删除
100644 → 0
浏览文件 @
59c26afd
//
// Copyright (C) 2012 Calin Cerchez
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
#ifndef DIAMETERPEERTABLE_H_
#define DIAMETERPEERTABLE_H_
#include "DiameterPeer.h"
class
DiameterPeerTable
{
private:
typedef
std
::
vector
<
DiameterPeer
*>
PeerTable
;
PeerTable
peers
;
public:
DiameterPeerTable
();
virtual
~
DiameterPeerTable
();
void
push_back
(
DiameterPeer
*
peer
)
{
peers
.
push_back
(
peer
);
}
void
erase
(
unsigned
start
,
unsigned
end
);
void
print
();
DiameterPeer
*
findPeer
(
std
::
string
dFQDN
,
std
::
string
dRealm
=
""
);
DiameterPeer
*
findPeer
(
unsigned
applId
);
DiameterPeer
*
at
(
unsigned
i
)
{
return
peers
[
i
];
}
unsigned
size
()
{
return
peers
.
size
();
}
};
#endif
/* DIAMETERPEERTABLE_H_ */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录