Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Achou.Wang
4Gsim
提交
6b2aa9e5
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,发现更多精彩内容 >>
提交
6b2aa9e5
编写于
7月 03, 2012
作者:
C
calincerchez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
work commit
上级
95e34a80
变更
16
显示空白变更内容
内联
并排
Showing
16 changed file
with
205 addition
and
330 deletion
+205
-330
src/applications/diameter/DiameterBase.cc
src/applications/diameter/DiameterBase.cc
+5
-5
src/applications/diameter/DiameterBase.h
src/applications/diameter/DiameterBase.h
+70
-51
src/applications/diameter/DiameterClient.cc
src/applications/diameter/DiameterClient.cc
+0
-29
src/applications/diameter/DiameterClient.h
src/applications/diameter/DiameterClient.h
+0
-32
src/applications/diameter/DiameterClient.ned
src/applications/diameter/DiameterClient.ned
+0
-27
src/applications/diameter/DiameterServer.cc
src/applications/diameter/DiameterServer.cc
+0
-29
src/applications/diameter/DiameterServer.h
src/applications/diameter/DiameterServer.h
+0
-32
src/applications/diameter/DiameterServer.ned
src/applications/diameter/DiameterServer.ned
+0
-27
src/applications/diameter/DiameterSession.cc
src/applications/diameter/DiameterSession.cc
+29
-2
src/applications/diameter/DiameterSession.h
src/applications/diameter/DiameterSession.h
+22
-1
src/applications/diameter/peer/DiameterPeer.cc
src/applications/diameter/peer/DiameterPeer.cc
+6
-6
src/applications/diameter/session/DiameterSessionTable.cc
src/applications/diameter/session/DiameterSessionTable.cc
+0
-45
src/applications/diameter/session/DiameterSessionTable.h
src/applications/diameter/session/DiameterSessionTable.h
+0
-39
src/applications/diameter/utils/DiameterMessage.h
src/applications/diameter/utils/DiameterMessage.h
+29
-0
src/applications/diameter/utils/DiameterSerializer.h
src/applications/diameter/utils/DiameterSerializer.h
+23
-0
src/applications/diameter/utils/DiameterUtils.h
src/applications/diameter/utils/DiameterUtils.h
+21
-5
未找到文件。
src/applications/diameter/DiameterBase.cc
浏览文件 @
6b2aa9e5
...
...
@@ -46,11 +46,11 @@ void DiameterBase::initialize(int stage) {
void
DiameterBase
::
handleMessage
(
cMessage
*
msg
)
{
if
(
msg
->
isSelfMessage
())
{
if
(
msg
->
isSelfMessage
())
{
// handles timers
DiameterPeer
*
peer
=
(
DiameterPeer
*
)
msg
->
getContextPointer
();
peer
->
processTimer
(
msg
);
}
else
{
DiameterConnection
*
conn
=
conn
Map
.
findConnectionFor
(
msg
);
}
else
{
// handles SCTP messages
DiameterConnection
*
conn
=
conn
s
.
findConnectionFor
(
msg
);
if
(
!
conn
)
{
// new connection -- create new socket object and server process
SCTPSocket
*
socket
=
new
SCTPSocket
(
msg
);
...
...
@@ -58,7 +58,7 @@ void DiameterBase::handleMessage(cMessage *msg) {
conn
=
new
DiameterConnection
(
this
);
conn
->
setType
(
RESPONDER
);
conn
->
setSocket
(
socket
);
conn
Map
.
addConnection
(
conn
);
conn
s
.
addConnection
(
conn
);
socket
->
setCallbackObject
(
conn
);
socket
->
setOutboundStreams
(
outboundStreams
);
...
...
@@ -197,7 +197,7 @@ DiameterConnection *DiameterBase::createConnection(AddressVector addresses, int
conn
->
setAddresses
(
addresses
);
conn
->
setPort
(
port
);
conn
->
setType
(
INITIATOR
);
conn
Map
.
addConnection
(
conn
);
conn
s
.
addConnection
(
conn
);
return
conn
;
}
...
...
src/applications/diameter/DiameterBase.h
浏览文件 @
6b2aa9e5
...
...
@@ -22,98 +22,117 @@
#include <string>
#include "SCTPSocket.h"
#include "DiameterConnectionMap.h"
#include "DiameterSession
Table
.h"
#include "DiameterSession.h"
#include "DiameterPeerTable.h"
#include "RoutingTableAccess.h"
/*
* Implements the
SCTP
protocol. This section describes the internal
* architecture of the
SCTP
model.
* Implements the
Diameter base
protocol. This section describes the internal
* architecture of the
Diameter
model.
*
* You may want to check the SCTPSocket
* class which makes it easier to use SCTP from applications.
*
* The SCTP protocol implementation is composed of several classes (discussion
* The Diameter base protocol implementation is composed of several classes (discussion
* follows below):
* - SCTP: the module class
* - SCTPAssociation: manages a connection
* - SCTPSendQueue, SCTPReceiveQueue: abstract base classes for various types
* of send and receive queues
* - SCTPAlgorithm: abstract base class for SCTP algorithms
*
* SCTP subclassed from cSimpleModule. It manages socketpair-to-connection
* mapping, and dispatches segments and user commands to the appropriate
* SCTPAssociation object.
*
* SCTPAssociation manages the connection, with the help of other objects.
* SCTPAssociation itself implements the basic SCTP "machinery": takes care
* of the state machine, stores the state variables (TCB), sends/receives
* etc.
*
* SCTPAssociation internally relies on 3 objects. The first two are subclassed
* from SCTPSendQueue and SCTPReceiveQueue. They manage the actual data stream,
* so SCTPAssociation itself only works with sequence number variables.
* This makes it possible to easily accomodate need for various types of
* simulated data transfer: real byte stream, "virtual" bytes (byte counts
* only), and sequence of cMessage objects (where every message object is
* mapped to a SCTP sequence number range).
* - DiameterBase: the module class
* - DiameterConnection: manages a connection between two peers
* - DiameterPeer: manages a Diameter peer
* - DiameterSession: manages a session between end to end peers
* - DiameterApplication: manages a Diameter application
*
* Currently implemented send queue and receive queue classes are
* SCTPVirtualDataSendQueue and SCTPVirtualDataRcvQueue which implement
* queues with "virtual" bytes (byte counts only).
* 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.
*
* The third object is subclassed from SCTPAlgorithm. Control over
* retransmissions, congestion control and ACK sending are "outsourced"
* from SCTPAssociation into SCTPAlgorithm: delayed acks, slow start, fast rexmit,
* etc. are all implemented in SCTPAlgorithm subclasses.
*
* The concrete SCTPAlgorithm class to use can be chosen per connection (in OPEN)
* or in a module parameter.
* All Diameter base protocol model is implemented according to RFC 3588.
*/
class
DiameterBase
:
public
cSimpleModule
{
p
ublic
:
p
rotected
:
std
::
string
fqdn
;
std
::
string
realm
;
unsigned
vendorId
;
std
::
string
productName
;
unsigned
sessionIds
;
protected:
int
outboundStreams
;
SCTPSocket
serverSocket
;
DiameterConnectionMap
conn
Map
;
DiameterConnectionMap
conn
s
;
DiameterSessionTable
sessions
;
DiameterPeerTable
peers
;
IRoutingTable
*
rT
;
/*
* Methods for loading the configuration from the XML file
* ex.
* <DNS>
* <Entry fqdn="mme.lte.test" address="192.168.3.2"/>
* </DNS>
* <Diameter
* fqdn="hss.lte.test"
* realm="lte.test"
* vendor="0"
* product="HSSDiameter">
* <Listeners port="3868">
* <Listener address="192.168.3.1"/>
* </Listeners>
* <Peers>
* </Peers>
* </Diameter>
*/
void
loadOwnConfigFromXML
(
const
cXMLElement
&
diameterNode
);
void
loadPeersFromXML
(
const
cXMLElement
&
diameterNode
);
void
loadListenersFromXML
(
const
cXMLElement
&
diameterNode
);
void
loadConfigFromXML
(
const
char
*
filename
);
AddressVector
queryDNS
(
const
cXMLElement
&
diameterNode
,
const
std
::
string
fqdnIn
,
int
port
);
AddressVector
findLocalAddresses
(
AddressVector
remoteAddrs
);
public:
DiameterBase
();
virtual
~
DiameterBase
();
virtual
int
numInitStages
()
const
{
return
5
;
}
/*
* Method for reading and processing the configuration file. This includes
* loading the Diameter peers, creating for each a initiating or responding
* Diameter connection and loading the Diameter application.
*/
void
initialize
(
int
stage
);
/*
* Method for handling incoming messages. If the message is a timer, it sends it
* to the appropriate peer. If the message is a SCTP message, it finds the
* appropriate socket and sends the message to it. If no socket is available,
* it creates a new socket together with a new Diameter connection.
*/
void
handleMessage
(
cMessage
*
msg
);
/*
*
* Method for processing application messages. This method should be overridden
* by Diameter application implementations.
*/
virtual
DiameterMessage
*
processMessage
(
DiameterMessage
*
msg
)
{
return
NULL
;
}
/*
* Getter methods.
*/
int
getOutboundStreams
()
{
return
outboundStreams
;
}
SCTPSocket
getServerSocket
()
{
return
serverSocket
;
}
std
::
string
getFqdn
()
{
return
fqdn
;
}
std
::
string
getRealm
()
{
return
realm
;
}
unsigned
getVendorId
()
{
return
vendorId
;
}
std
::
string
getProductName
()
{
return
productName
;
}
/*
* Utility methods.
*/
DiameterConnection
*
createConnection
(
AddressVector
addresses
,
int
port
);
DiameterPeer
*
createPeer
(
std
::
string
dFQDN
,
std
::
string
dRealm
,
DiameterConnection
*
conn
,
DiameterApplication
*
appl
=
NULL
);
DiameterConnection
*
removeConnection
(
DiameterConnection
*
conn
)
{
return
connMap
.
removeConnection
(
conn
);
}
DiameterConnection
*
removeConnection
(
DiameterConnection
*
conn
)
{
return
conns
.
removeConnection
(
conn
);
}
DiameterSession
*
createSession
(
bool
stType
);
unsigned
genSessionId
()
{
return
++
sessionIds
;
}
/*
* Wrapper methods.
*/
DiameterPeer
*
findPeer
(
std
::
string
dFQDN
,
std
::
string
dRealm
=
""
)
{
return
peers
.
findPeer
(
dFQDN
,
dRealm
);
}
DiameterPeer
*
findPeer
(
unsigned
applId
)
{
return
peers
.
findPeer
(
applId
);
}
DiameterSession
*
createSession
(
bool
stType
);
};
#endif
/* DIAMETERBASE_H_ */
src/applications/diameter/DiameterClient.cc
已删除
100644 → 0
浏览文件 @
95e34a80
//
// 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 "DiameterClient.h"
Define_Module
(
DiameterClient
);
DiameterClient
::
DiameterClient
()
{
// TODO Auto-generated constructor stub
}
DiameterClient
::~
DiameterClient
()
{
// TODO Auto-generated destructor stub
}
src/applications/diameter/DiameterClient.h
已删除
100644 → 0
浏览文件 @
95e34a80
//
// 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 DIAMETERCLIENT_H_
#define DIAMETERCLIENT_H_
#include "DiameterBase.h"
class
DiameterClient
:
public
DiameterBase
{
public:
DiameterClient
();
virtual
~
DiameterClient
();
void
initialize
(
int
stage
)
{
DiameterBase
::
initialize
(
stage
);
}
void
handleMessage
(
cMessage
*
msg
)
{
DiameterBase
::
handleMessage
(
msg
);
}
};
#endif
/* DIAMETERCLIENT_H_ */
src/applications/diameter/DiameterClient.ned
已删除
100644 → 0
浏览文件 @
95e34a80
//
//
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
/.
//
package
inet
.
applications
.
diameter
;
simple
DiameterClient
like
DiameterBase
{
parameters
:
@
display
(
"i=block/app"
);
string
configFile
;
gates
:
input
sctpIn
;
output
sctpOut
;
}
\ No newline at end of file
src/applications/diameter/DiameterServer.cc
已删除
100644 → 0
浏览文件 @
95e34a80
//
// 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 "DiameterServer.h"
Define_Module
(
DiameterServer
)
DiameterServer
::
DiameterServer
()
{
// TODO Auto-generated constructor stub
}
DiameterServer
::~
DiameterServer
()
{
// TODO Auto-generated destructor stub
}
src/applications/diameter/DiameterServer.h
已删除
100644 → 0
浏览文件 @
95e34a80
//
// 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 DIAMETERSERVER_H_
#define DIAMETERSERVER_H_
#include "DiameterBase.h"
class
DiameterServer
:
public
DiameterBase
{
public:
DiameterServer
();
virtual
~
DiameterServer
();
void
initialize
(
int
stage
)
{
DiameterBase
::
initialize
(
stage
);
}
void
handleMessage
(
cMessage
*
msg
)
{
DiameterBase
::
handleMessage
(
msg
);
}
};
#endif
/* DIAMETERSERVER_H_ */
src/applications/diameter/DiameterServer.ned
已删除
100644 → 0
浏览文件 @
95e34a80
//
//
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
/.
//
package
inet
.
applications
.
diameter
;
simple
DiameterServer
like
DiameterBase
{
parameters
:
@
display
(
"i=block/app"
);
string
configFile
;
gates
:
input
sctpIn
;
output
sctpOut
;
}
\ No newline at end of file
src/applications/diameter/
session/
DiameterSession.cc
→
src/applications/diameter/DiameterSession.cc
浏览文件 @
6b2aa9e5
...
...
@@ -27,8 +27,8 @@ DiameterSession::DiameterSession(DiameterBase *module, bool state) {
char
time
[
10
];
sprintf
(
time
,
"%d"
,
(
unsigned
)
simTime
().
raw
());
char
id
[
10
];
sprintf
(
id
,
"%d"
,
module
->
sessionIds
++
);
this
->
id
=
module
->
fqdn
+
";"
+
time
+
";"
+
id
;
sprintf
(
id
,
"%d"
,
module
->
genSessionId
()
);
this
->
id
=
module
->
getFqdn
()
+
";"
+
time
+
";"
+
id
;
fsm
=
new
cFSM
();
fsm
->
setName
(
"sessionState"
);
...
...
@@ -119,3 +119,30 @@ const char *DiameterSession::eventName(int event) {
return
s
;
#undef CASE
}
DiameterSessionTable
::
DiameterSessionTable
()
{
// TODO Auto-generated constructor stub
}
DiameterSessionTable
::~
DiameterSessionTable
()
{
// TODO Auto-generated destructor stub
}
DiameterSession
*
DiameterSessionTable
::
find
(
std
::
string
id
)
{
for
(
unsigned
i
=
0
;
i
<
sessions
.
size
();
i
++
)
{
if
(
sessions
.
at
(
i
)
->
getId
()
==
id
)
return
sessions
.
at
(
i
);
}
return
NULL
;
}
void
DiameterSessionTable
::
erase
(
unsigned
start
,
unsigned
end
)
{
SessionTable
::
iterator
first
=
sessions
.
begin
()
+
start
;
SessionTable
::
iterator
last
=
sessions
.
begin
()
+
end
;
SessionTable
::
iterator
i
=
first
;
for
(;
i
!=
last
;
++
i
)
delete
*
i
;
sessions
.
erase
(
first
,
last
);
}
src/applications/diameter/
session/
DiameterSession.h
→
src/applications/diameter/DiameterSession.h
浏览文件 @
6b2aa9e5
...
...
@@ -41,9 +41,14 @@ enum SessionEvent {
RequestReceived
,
};
/*
* Class Diameter session. The class implements the session state machine
* and processes Diameter application messages which are not meant for
* Diameter base protocol.
*/
class
DiameterSession
:
public
cPolymorphic
{
private:
bool
state
;
bool
type
;
// stateful or stateless
std
::
string
id
;
cFSM
*
fsm
;
// cMessage *sTimer;
...
...
@@ -62,4 +67,20 @@ public:
void
performStateTransition
(
SessionEvent
&
event
,
unsigned
applId
,
DiameterPeer
*
peer
,
DiameterMessage
*
msg
);
};
class
DiameterSessionTable
{
private:
typedef
std
::
vector
<
DiameterSession
*>
SessionTable
;
SessionTable
sessions
;
public:
DiameterSessionTable
();
virtual
~
DiameterSessionTable
();
DiameterSession
*
find
(
std
::
string
id
);
DiameterSession
*
at
(
unsigned
i
)
{
return
sessions
.
at
(
i
);
}
void
push_back
(
DiameterSession
*
session
)
{
sessions
.
push_back
(
session
);
}
void
erase
(
unsigned
start
,
unsigned
end
);
unsigned
size
()
{
return
sessions
.
size
();}
// void deleteSessions();
};
#endif
/* DIAMETERSESSION_H_ */
src/applications/diameter/peer/DiameterPeer.cc
浏览文件 @
6b2aa9e5
...
...
@@ -29,8 +29,8 @@ DiameterPeer::DiameterPeer(DiameterBase *module) {
this
->
module
=
module
;
this
->
dFQDN
=
""
;
this
->
dFQDN
=
""
;
this
->
oFQDN
=
module
->
fqdn
;
this
->
oRealm
=
module
->
realm
;
this
->
oFQDN
=
module
->
getFqdn
()
;
this
->
oRealm
=
module
->
getRealm
()
;
char
fsmname
[
24
];
sprintf
(
fsmname
,
"fsm-%s"
,
oFQDN
.
data
());
...
...
@@ -464,8 +464,8 @@ void DiameterPeer::sendCER(DiameterConnection *conn) {
cer
->
setHdr
(
DiameterUtils
().
createHeader
(
CapabilitiesExchange
,
1
,
0
,
0
,
0
,
appl
->
applId
,
uniform
(
0
,
10000
),
uniform
(
0
,
10000
)));
cer
->
pushAvp
(
DiameterUtils
().
createAddressAVP
(
AVP_HostIPAddress
,
0
,
1
,
0
,
0
,
module
->
getServerSocket
().
getLocalAddresses
().
at
(
0
)));
cer
->
pushAvp
(
DiameterUtils
().
createUnsigned32AVP
(
AVP_VendorId
,
0
,
1
,
0
,
0
,
module
->
vendorId
));
cer
->
pushAvp
(
DiameterUtils
().
createUTF8StringAVP
(
AVP_ProductName
,
0
,
1
,
0
,
0
,
module
->
productName
));
cer
->
pushAvp
(
DiameterUtils
().
createUnsigned32AVP
(
AVP_VendorId
,
0
,
1
,
0
,
0
,
module
->
getVendorId
()
));
cer
->
pushAvp
(
DiameterUtils
().
createUTF8StringAVP
(
AVP_ProductName
,
0
,
1
,
0
,
0
,
module
->
getProductName
()
));
if
(
appl
)
{
AVP
*
authApplId
=
DiameterUtils
().
createUnsigned32AVP
(
AVP_AuthApplId
,
0
,
1
,
0
,
0
,
appl
->
applId
);
...
...
@@ -486,8 +486,8 @@ void DiameterPeer::sendCEA(DiameterConnection *conn, DiameterMessage *cer, unsig
cea
->
pushAvp
(
DiameterUtils
().
createUnsigned32AVP
(
AVP_ResultCode
,
0
,
1
,
0
,
0
,
resCode
));
cea
->
pushAvp
(
DiameterUtils
().
createAddressAVP
(
AVP_HostIPAddress
,
0
,
1
,
0
,
0
,
module
->
getServerSocket
().
getLocalAddresses
().
at
(
0
)));
cea
->
pushAvp
(
DiameterUtils
().
createUnsigned32AVP
(
AVP_VendorId
,
0
,
1
,
0
,
0
,
module
->
vendorId
));
cea
->
pushAvp
(
DiameterUtils
().
createUTF8StringAVP
(
AVP_ProductName
,
0
,
1
,
0
,
0
,
module
->
productName
));
cea
->
pushAvp
(
DiameterUtils
().
createUnsigned32AVP
(
AVP_VendorId
,
0
,
1
,
0
,
0
,
module
->
getVendorId
()
));
cea
->
pushAvp
(
DiameterUtils
().
createUTF8StringAVP
(
AVP_ProductName
,
0
,
1
,
0
,
0
,
module
->
getProductName
()
));
if
(
appl
)
{
std
::
vector
<
AVP
*>
avps
;
...
...
src/applications/diameter/session/DiameterSessionTable.cc
已删除
100644 → 0
浏览文件 @
95e34a80
//
// 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 "DiameterSessionTable.h"
#include <algorithm>
DiameterSessionTable
::
DiameterSessionTable
()
{
// TODO Auto-generated constructor stub
}
DiameterSessionTable
::~
DiameterSessionTable
()
{
// TODO Auto-generated destructor stub
}
DiameterSession
*
DiameterSessionTable
::
find
(
std
::
string
id
)
{
for
(
unsigned
i
=
0
;
i
<
sessions
.
size
();
i
++
)
{
if
(
sessions
.
at
(
i
)
->
getId
()
==
id
)
return
sessions
.
at
(
i
);
}
return
NULL
;
}
void
DiameterSessionTable
::
erase
(
unsigned
start
,
unsigned
end
)
{
SessionTable
::
iterator
first
=
sessions
.
begin
()
+
start
;
SessionTable
::
iterator
last
=
sessions
.
begin
()
+
end
;
SessionTable
::
iterator
i
=
first
;
for
(;
i
!=
last
;
++
i
)
delete
*
i
;
sessions
.
erase
(
first
,
last
);
}
src/applications/diameter/session/DiameterSessionTable.h
已删除
100644 → 0
浏览文件 @
95e34a80
//
// 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 DIAMETERSESSIONTABLE_H_
#define DIAMETERSESSIONTABLE_H_
#include "DiameterSession.h"
class
DiameterSessionTable
{
private:
typedef
std
::
vector
<
DiameterSession
*>
SessionTable
;
SessionTable
sessions
;
public:
DiameterSessionTable
();
virtual
~
DiameterSessionTable
();
DiameterSession
*
find
(
std
::
string
id
);
DiameterSession
*
at
(
unsigned
i
)
{
return
sessions
.
at
(
i
);
}
void
push_back
(
DiameterSession
*
session
)
{
sessions
.
push_back
(
session
);
}
void
erase
(
unsigned
start
,
unsigned
end
);
unsigned
size
()
{
return
sessions
.
size
();}
// void deleteSessions();
};
#endif
/* DIAMETERSESSIONTABLE_H_ */
src/applications/diameter/utils/DiameterMessage.h
浏览文件 @
6b2aa9e5
...
...
@@ -21,6 +21,10 @@
#include "INETDefs.h"
#include "DiameterMessage_m.h"
/*
* Class for Diameter message. This class inherits the message
* base class from .msg file and adds the vector with the AVPs.
*/
class
DiameterMessage
:
public
DiameterMessage_Base
{
protected:
typedef
std
::
vector
<
AVPPtr
>
AVPVector
;
...
...
@@ -29,17 +33,42 @@ public:
DiameterMessage
(
const
char
*
name
=
NULL
,
int
kind
=
0
)
:
DiameterMessage_Base
(
name
,
kind
)
{}
DiameterMessage
(
const
DiameterMessage
&
other
)
:
DiameterMessage_Base
(
other
.
getName
())
{
operator
=
(
other
);}
virtual
~
DiameterMessage
();
DiameterMessage
&
operator
=
(
const
DiameterMessage
&
other
);
virtual
DiameterMessage
*
dup
()
const
{
return
new
DiameterMessage
(
*
this
);}
/*
* Methods overridden but not used. You should use instead pushAvp or insertAvp.
*/
virtual
void
setAvpsArraySize
(
unsigned
int
size
);
virtual
void
setAvps
(
unsigned
int
k
,
const
AVPPtr
&
avps_var
);
/*
* Getter methods.
*/
virtual
unsigned
int
getAvpsArraySize
()
const
;
virtual
AVPPtr
&
getAvps
(
unsigned
int
k
);
/*
* Method for pushing AVP at the end of the vector.
*/
void
pushAvp
(
AVPPtr
avp
)
{
avps
.
push_back
(
avp
);
}
/*
* Method for inserting AVP at a given position in the vector.
*/
void
insertAvp
(
unsigned
pos
,
AVPPtr
avp
);
/*
* Method for printing the message contents. Currently it prints info
* only for the header.
*/
void
print
();
/*
* Method for finding a AVP with a given AVP code within the vector.
* It returns NULL if the AVP is not found.
*/
AVPPtr
findAvp
(
unsigned
avpCode
);
};
...
...
src/applications/diameter/utils/DiameterSerializer.h
浏览文件 @
6b2aa9e5
...
...
@@ -21,17 +21,40 @@
#include "DiameterMessage.h"
#include "SCTPMessage_m.h"
/*
* Class for serializing and parsing of Diameter messages.
* This class will be used to serialize a Diameter message before sending it
* to SCTP layer and parsing the message when it comes from SCTP layer.
*/
class
DiameterSerializer
{
private:
/*
* Method returns the length of the Diameter message. The length includes
* the header, all the AVPs (header + payload) and offset bytes, if it is
* needed.
*/
unsigned
getMessageLength
(
DiameterMessage
*
msg
);
/*
* Methods for serializing and parsing of Diameter header.
*/
unsigned
serializeHeader
(
DiameterHeader
hdr
,
unsigned
len
,
char
*
p
);
unsigned
parseHeader
(
DiameterHeader
*
hdr
,
char
*
p
);
public:
DiameterSerializer
();
virtual
~
DiameterSerializer
();
/*
* Methods for serializing and parsing of Diameter AVP.
*/
unsigned
serializeAVP
(
AVP
*
avp
,
char
*
p
);
unsigned
parseAVP
(
AVP
*
avp
,
char
*
p
);
/*
* Methods for serializing and parsing of Diameter Message. Serialize method
* will generate directly a SCTP message with the resulted bytes and parse
* method will process a SCTP message and generate the appropriate Diameter message.
*/
SCTPSimpleMessage
*
serialize
(
DiameterMessage
*
msg
);
DiameterMessage
*
parse
(
const
SCTPSimpleMessage
*
msg
);
};
...
...
src/applications/diameter/utils/DiameterUtils.h
浏览文件 @
6b2aa9e5
...
...
@@ -22,25 +22,31 @@
#include "DiameterMessage_m.h"
#define IPV4_ADDRESS_TYPE 1
#define IPV4_ADDRESS_SIZE 4
/*
* Diameter utility class. It is used for creating and processing Diameter header and AVPs.
*/
class
DiameterUtils
{
private:
AVP
*
createBaseAVP
(
unsigned
avpCode
,
bool
vendFlag
,
bool
manFlag
,
bool
privFlag
,
unsigned
vendorId
);
public:
DiameterUtils
();
virtual
~
DiameterUtils
();
/*
* Methods for Diameter header and AVP creation.
*/
DiameterHeader
createHeader
(
unsigned
commandCode
,
bool
reqFlag
,
bool
prxyFlag
,
bool
errFlag
,
bool
retrFlag
,
unsigned
applId
,
unsigned
hopByHopId
,
unsigned
endToEndId
);
AVP
*
createBaseAVP
(
unsigned
avpCode
,
bool
vendFlag
,
bool
manFlag
,
bool
privFlag
,
unsigned
vendorId
);
AVP
*
createOctetStringAVP
(
unsigned
avpCode
,
bool
vendFlag
,
bool
manFlag
,
bool
privFlag
,
unsigned
vendorId
,
unsigned
len
,
const
char
*
str
);
AVP
*
createUTF8StringAVP
(
unsigned
avpCode
,
bool
vendFlag
,
bool
manFlag
,
bool
privFlag
,
unsigned
vendorId
,
std
::
string
str
);
AVP
*
createAddressAVP
(
unsigned
avpCode
,
bool
vendFlag
,
bool
manFlag
,
bool
privFlag
,
unsigned
vendorId
,
IPvXAddress
addr
);
AVP
*
createUnsigned32AVP
(
unsigned
avpCode
,
bool
vendFlag
,
bool
manFlag
,
bool
privFlag
,
unsigned
vendorId
,
unsigned
val
);
AVP
*
createInteger32AVP
(
unsigned
avpCode
,
bool
vendFlag
,
bool
manFlag
,
bool
privFlag
,
unsigned
vendorId
,
int
val
);
AVP
*
createGroupedAVP
(
unsigned
avpCode
,
bool
vendFlag
,
bool
manFlag
,
bool
privFlag
,
unsigned
vendorId
,
std
::
vector
<
AVP
*>
avps
);
DiameterHeader
createHeader
(
unsigned
commandCode
,
bool
reqFlag
,
bool
prxyFlag
,
bool
errFlag
,
bool
retrFlag
,
unsigned
applId
,
unsigned
hopByHopId
,
unsigned
endToEndId
);
/*
* Methods for Diameter header and AVP processing.
*/
unsigned
processUnsigned32AVP
(
AVP
*
unsigned32AVP
);
int
processInteger32AVP
(
AVP
*
integer32AVP
);
char
*
processOctetStringAVP
(
AVP
*
octetStringAVP
);
...
...
@@ -48,10 +54,20 @@ public:
IPvXAddress
processAddressAVP
(
AVP
*
addressAVP
);
std
::
vector
<
AVP
*>
processGroupedAVP
(
AVP
*
groupedAVP
);
/*
* Methods for finding AVP or arrays of AVPs in grouped AVPs.
*/
AVP
*
findAVP
(
unsigned
avpCode
,
std
::
vector
<
AVP
*>
avps
);
std
::
vector
<
AVP
*>
findAVPs
(
unsigned
avpCode
,
std
::
vector
<
AVP
*>
avps
);
/*
* Method for printing the name of a AVP code.
*/
const
char
*
avpName
(
unsigned
avpCode
);
/*
* Method for cleaning grouped AVPs.
*/
void
deleteGroupedAVP
(
std
::
vector
<
AVP
*>
avps
);
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录