ocs init
This commit is contained in:
1559
plat/diameter/extensions/sh_app/dict_dcca.c
Normal file
1559
plat/diameter/extensions/sh_app/dict_dcca.c
Normal file
File diff suppressed because it is too large
Load Diff
859
plat/diameter/extensions/sh_app/dict_dcca_3gpp.c
Normal file
859
plat/diameter/extensions/sh_app/dict_dcca_3gpp.c
Normal file
@@ -0,0 +1,859 @@
|
||||
/*
|
||||
* Dictionary definitions of objects specified in DCCA (Nokia, 3GPP).
|
||||
*/
|
||||
#include "extension.h"
|
||||
|
||||
|
||||
/* The content of this file follows the same structure as dict_base_proto.c */
|
||||
|
||||
#define CHECK_dict_new( _type, _data, _parent, _ref ) \
|
||||
CHECK_FCT( fd_dict_new( fd_g_config->cnf_dict, (_type), (_data), (_parent), (_ref)) );
|
||||
|
||||
#define CHECK_dict_search( _type, _criteria, _what, _result ) \
|
||||
CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) );
|
||||
|
||||
struct local_rules_definition {
|
||||
char *avp_name;
|
||||
enum rule_position position;
|
||||
int min;
|
||||
int max;
|
||||
};
|
||||
|
||||
#define RULE_ORDER( _position ) ((((_position) == RULE_FIXED_HEAD) || ((_position) == RULE_FIXED_TAIL)) ? 1 : 0 )
|
||||
|
||||
#define PARSE_loc_rules( _rulearray, _parent) { \
|
||||
int __ar; \
|
||||
for (__ar=0; __ar < sizeof(_rulearray) / sizeof((_rulearray)[0]); __ar++) { \
|
||||
struct dict_rule_data __data = { NULL, \
|
||||
(_rulearray)[__ar].position, \
|
||||
0, \
|
||||
(_rulearray)[__ar].min, \
|
||||
(_rulearray)[__ar].max}; \
|
||||
__data.rule_order = RULE_ORDER(__data.rule_position); \
|
||||
CHECK_FCT( fd_dict_search( \
|
||||
fd_g_config->cnf_dict, \
|
||||
DICT_AVP, \
|
||||
AVP_BY_NAME, \
|
||||
(_rulearray)[__ar].avp_name, \
|
||||
&__data.rule_avp, 0 ) ); \
|
||||
if ( !__data.rule_avp ) { \
|
||||
TRACE_DEBUG(INFO, "AVP Not found: '%s'", (_rulearray)[__ar].avp_name ); \
|
||||
return ENOENT; \
|
||||
} \
|
||||
CHECK_FCT_DO( fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &__data, _parent, NULL), \
|
||||
{ \
|
||||
TRACE_DEBUG(INFO, "Error on rule with AVP '%s'", \
|
||||
(_rulearray)[__ar].avp_name ); \
|
||||
return EINVAL; \
|
||||
} ); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define enumval_def_u32( _val_, _str_ ) \
|
||||
{ _str_, { .u32 = _val_ }}
|
||||
|
||||
#define enumval_def_os( _len_, _val_, _str_ ) \
|
||||
{ _str_, { .os = { .data = (unsigned char *)_val_, .len = _len_ }}}
|
||||
|
||||
|
||||
int dict_dcca_3gpp_entry(char * conffile)
|
||||
{
|
||||
TRACE_ENTRY("%p", conffile);
|
||||
|
||||
#if 0
|
||||
/* Applications section */
|
||||
{
|
||||
/* Create the vendors */
|
||||
{
|
||||
struct dict_vendor_data vendor_data = { 10415, "3GPP" };
|
||||
CHECK_FCT(fd_dict_new(fd_g_config->cnf_dict, DICT_VENDOR, &vendor_data, NULL, NULL));
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* AVP section */
|
||||
{
|
||||
struct dict_object * Address_type;
|
||||
struct dict_object * UTF8String_type;
|
||||
struct dict_object * DiameterIdentity_type;
|
||||
struct dict_object * DiameterURI_type;
|
||||
struct dict_object * Time_type;
|
||||
|
||||
CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "Address", &Address_type);
|
||||
CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "UTF8String", &UTF8String_type);
|
||||
CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "DiameterIdentity", &DiameterIdentity_type);
|
||||
CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "DiameterURI", &DiameterURI_type);
|
||||
CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "Time", &Time_type);
|
||||
|
||||
/* Reporting-Reason */
|
||||
{
|
||||
/*
|
||||
Enumerated. Will be present if quota was
|
||||
exhausted for one or more metering types. Only
|
||||
one Reporting-Reason AVP can be present in the
|
||||
Used-Service-Unit AVP. (Note that the Reporting-
|
||||
Reason AVP may be present also at the MSCC
|
||||
level; see below.)
|
||||
The following values are supported:
|
||||
|
||||
QUOTA_EXHAUSTED(3); Quota for the
|
||||
associated metering type has been
|
||||
exhausted. With this reporting reason there is
|
||||
only one metering type in this Used-Service-
|
||||
Unit AVP.
|
||||
|
||||
OTHER_QUOTA_TYPE(5); Quota for one or
|
||||
more of the other metering types has been
|
||||
exhausted. With this reporting reason there
|
||||
may be multiple metering types in Used-
|
||||
Service-Unit AVP.
|
||||
|
||||
POOL_EXHAUSTED(8); Quota from the
|
||||
credit pool has been exhausted. This reporting
|
||||
reason is used if the quota for the associated
|
||||
metering type was granted from a credit pool
|
||||
by using the GSU-Pool-Reference AVP in the
|
||||
CCA. With this reporting reason there is only
|
||||
one metering type in the Used-Service-Unit
|
||||
AVP.
|
||||
*/
|
||||
|
||||
struct dict_object *type;
|
||||
struct dict_type_data tdata = { AVP_TYPE_INTEGER32, "Enumerated(Reporting-Reason)" , NULL, NULL, NULL };
|
||||
// struct dict_enumval_data t_1 = { "QHT", { .i32 = 1 }};
|
||||
// struct dict_enumval_data t_2 = { "FINAL", { .i32 = 2 }};
|
||||
struct dict_enumval_data t_3 = { "QUOTA_EXHAUSTED", { .i32 = 3 }};
|
||||
// struct dict_enumval_data t_4 = { "VALIDITY_TIME", { .i32 = 4 }};
|
||||
struct dict_enumval_data t_5 = { "OTHER_QUOTA_TYPE", { .i32 = 5 }};
|
||||
// struct dict_enumval_data t_6 = { "RATING_CONDITION_CHANGE", { .i32 = 6 }};
|
||||
// struct dict_enumval_data t_7 = { "FORCED_REAUTHORIZATION", { .i32 = 7 }};
|
||||
struct dict_enumval_data t_8 = { "POOL_EXHAUSTED", { .i32 = 8 }};
|
||||
|
||||
struct dict_avp_data data = {
|
||||
872, /* Code */
|
||||
10415, /* Vendor */
|
||||
"Reporting-Reason", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_INTEGER32 /* base type of data */
|
||||
};
|
||||
/* Create the Enumerated type, and then the AVP */
|
||||
CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
|
||||
CHECK_dict_new( DICT_ENUMVAL, &t_3 , type, NULL);
|
||||
CHECK_dict_new( DICT_ENUMVAL, &t_5 , type, NULL);
|
||||
CHECK_dict_new( DICT_ENUMVAL, &t_8 , type, NULL);
|
||||
CHECK_dict_new( DICT_AVP, &data , type, NULL);
|
||||
}
|
||||
|
||||
/* Trigger */
|
||||
{
|
||||
/*
|
||||
Grouped. The presence of the Trigger AVP in the
|
||||
CCR identifies the event(s) triggering the CCR.
|
||||
*/
|
||||
|
||||
struct dict_avp_data data = {
|
||||
1264, /* Code */
|
||||
10415, /* Vendor */
|
||||
"Trigger", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_GROUPED /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
|
||||
}
|
||||
|
||||
/* Trigger-Type */
|
||||
{
|
||||
/*
|
||||
Enumerated. One or more of these AVPs may be
|
||||
present. Indicates the event that triggered the
|
||||
MSCC. Supported values are:
|
||||
|
||||
CHANGE_IN_SGSN_IP_ADDRESS (1), a change in the SGSN address.
|
||||
|
||||
CHANGEINQOS_ANY (2), a change in the QoS profile
|
||||
|
||||
CHANGEINRAT (4), a change in radio access technology
|
||||
|
||||
*/
|
||||
|
||||
struct dict_object *type;
|
||||
struct dict_type_data tdata = { AVP_TYPE_INTEGER32, "Enumerated(Trigger-Type)" , NULL, NULL, NULL };
|
||||
struct dict_enumval_data t_1 = { "CHANGE_IN_SGSN_IP_ADDRESS", { .i32 = 1 }};
|
||||
struct dict_enumval_data t_2 = { "CHANGEINQOS_ANY", { .i32 = 2 }};
|
||||
struct dict_enumval_data t_4 = { "CHANGEINRAT", { .i32 = 4 }};
|
||||
|
||||
struct dict_avp_data data = {
|
||||
870, /* Code */
|
||||
10415, /* Vendor */
|
||||
"Trigger-Type", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_INTEGER32 /* base type of data */
|
||||
};
|
||||
/* Create the Enumerated type, and then the AVP */
|
||||
CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
|
||||
CHECK_dict_new( DICT_ENUMVAL, &t_1 , type, NULL);
|
||||
CHECK_dict_new( DICT_ENUMVAL, &t_2 , type, NULL);
|
||||
CHECK_dict_new( DICT_ENUMVAL, &t_4 , type, NULL);
|
||||
CHECK_dict_new( DICT_AVP, &data , type, NULL);
|
||||
}
|
||||
|
||||
/* Service-Information */
|
||||
{
|
||||
/*
|
||||
Grouped. The Service-Information purpose is to
|
||||
allow the transmission of additional 3GPP service
|
||||
specific information elements (3GPP 32.299
|
||||
Rel7).
|
||||
Service-Information :: = < AVP Header: 873>
|
||||
* [ Subscription-Id ]
|
||||
[ AoC-Information ]
|
||||
[ PS-Information ]
|
||||
[ WLAN-Information ]
|
||||
[ IMS-Information ]
|
||||
[ MMS-Information ]
|
||||
[ LCS-Information ]
|
||||
[ PoC-Information ]
|
||||
[ MBMS-Information ]
|
||||
[ SMS-Information ]
|
||||
[ MMTel-Information ]
|
||||
[ Service-Generic-Information ]
|
||||
[ IM-Information ]
|
||||
[ DCD-Information ]
|
||||
*/
|
||||
|
||||
struct dict_avp_data data = {
|
||||
873, /* Code */
|
||||
10415, /* Vendor */
|
||||
"Service-Information", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_GROUPED /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
|
||||
}
|
||||
|
||||
/* PS-Information */
|
||||
{
|
||||
/*
|
||||
Grouped. Its purpose is to allow the transmission
|
||||
of additional PS service specific information
|
||||
elements (3GPP 32.299 Rel7).
|
||||
*/
|
||||
|
||||
struct dict_avp_data data = {
|
||||
874, /* Code */
|
||||
10415, /* Vendor */
|
||||
"PS-Information", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_GROUPED /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
|
||||
}
|
||||
|
||||
/* PDP-Address */
|
||||
{
|
||||
/*
|
||||
Address. Present only in the initial CCR. Contains
|
||||
the user equipment IP address. This AVP is
|
||||
defined in 3GPP 32.299 Rel7.
|
||||
*/
|
||||
|
||||
struct dict_avp_data data = {
|
||||
1227, /* Code */
|
||||
10415, /* Vendor */
|
||||
"PDP-Address", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , Address_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-IMSI */
|
||||
{
|
||||
/*
|
||||
IMSI encoded in UTF-8 per 3GPP TS 23.003. No
|
||||
padding. Maximum length of data: 15.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
1, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-IMSI", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-Charging-Id */
|
||||
{
|
||||
/*
|
||||
Unsigned32. (3GPP TS 29.061 Rel7) . The
|
||||
charging identifier for the PDP context. The Flexi
|
||||
ISN generates the 3GPP charging ID for both
|
||||
virtual and normal PDP contexts with one excep-
|
||||
tion. If the Flexi ISN acts as a NAS server and the
|
||||
charging ID selection is set to NAS Client, the
|
||||
charging ID will be the NAand not the 3GPP charging ID of Flexi ISN.
|
||||
Present in the initial CCR only.S client
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
2, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-Charging-Id", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_UNSIGNED32 /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-PDP-Type */
|
||||
{
|
||||
/*
|
||||
Enumerated. (3GPP TS 29.061 Rel7 ). Type of
|
||||
PDP context, for example, IP or PPP. Present in
|
||||
the initial CCR only.
|
||||
0 = IPv4
|
||||
1 = PPP
|
||||
2 = IPv6
|
||||
3 = IPv4v6
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
3, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-PDP-Type", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_UNSIGNED32 /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-CG-Address */
|
||||
{
|
||||
/*
|
||||
OctetString. (3GPP TS 29.061 Rel4). The address
|
||||
of the charging gateway that has been marked as
|
||||
the default charging gateway for the PDP context.
|
||||
The address is expressed as a four-byte integer.
|
||||
Present in the initial CCR only.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
4, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-CG-Address", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , Address_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-GPRS-Negotiated-QoS-Profile */
|
||||
{
|
||||
/*
|
||||
UTF8String. (3GPP TS 29.061 Rel7 ). The QoS
|
||||
profile applied by the Flexi ISN. In update and ter-
|
||||
mination requests, this AVP is present only when
|
||||
the CCR has been triggered by a PDP context
|
||||
update affecting the negotiated QoS
|
||||
Each octet is described by two UTF-8-encoded
|
||||
characters denoting the hexadecimal
|
||||
representation.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
5, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-GPRS-Negotiated-QoS-Profile", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-SGSN-Address */
|
||||
{
|
||||
/*
|
||||
OctetString. (3GPP TS 29.061 Rel4). The address
|
||||
of the charging gateway that has been marked as
|
||||
the default charging gateway for the PDP context.
|
||||
The address is expressed as a four-byte integer.
|
||||
Present in the initial CCR only.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
6, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-SGSN-Address", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , Address_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-GGSN-Address */
|
||||
{
|
||||
/*
|
||||
OctetString. (3GPP TS 29.061 Rel4). Usually the
|
||||
IP address of Flexi ISN. The only exception is
|
||||
when the Flexi ISN acts as a NAS server and the
|
||||
charging ID selection is set to NAS Client; then the
|
||||
GGSN IP address will be the NAIP address. Present in the initial CCR only.S client
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
7, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-GGSN-Address", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , Address_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-IMSI-MCC-MNC */
|
||||
{
|
||||
/*
|
||||
UTF8String. MCC and MNC extracted from the
|
||||
user's IMSI (first 5 or 6 digits, as applicable from
|
||||
the presented IMSI). The MCC-MNCs are
|
||||
extracted from the tables configured in FlexiISN
|
||||
configuration under the General and Roaming
|
||||
configurations.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
8, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-IMSI-MCC-MNC", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-GGSN-MCC-MNC */
|
||||
{
|
||||
/*
|
||||
UTF8String. (3GPP TS 29.061 Rel7 ). Contains
|
||||
the mobile country and network code of the PLMN
|
||||
that the Flexi ISN belongs to. Present in the initial
|
||||
CCR only. The first entry in the list of local PLMNs
|
||||
in the Flexi ISN configuration determines the value
|
||||
of this AVP.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
9, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-GGSN-MCC-MNC", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-NSAPI */
|
||||
{
|
||||
/*
|
||||
UTF8String. (3GPP TS 29.061 Rel7 ). Indicates
|
||||
the NSAPI of the PDP context. Contains one octet
|
||||
consisting of a single digit. Present in the initial
|
||||
CCR only.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
10, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-NSAPI", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-Session-Stop-Indicator */
|
||||
{
|
||||
/*
|
||||
OctetString. (3GPP TS 29.061 Rel4). The
|
||||
presence of this AVP indicates that the last
|
||||
context of the PDP session has been deleted. May
|
||||
be present in the termination CCR only. Contains
|
||||
one octet that has a value of 0xff.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
11, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-Session-Stop-Indicator", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-Selection-Mode */
|
||||
{
|
||||
/*
|
||||
UTF8String. (3GPP TS 29.061 Rel7 ). Consists of
|
||||
one octet containing the selection mode as
|
||||
received from SGSN in the Create PDP Context
|
||||
Request. Present in the initial CCR only.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
12, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-Selection-Mode", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-Charging-Characteristics */
|
||||
{
|
||||
/*
|
||||
UTF8String. (3GPP TS 29.061 Rel7 ). The
|
||||
charging characteristics for the PDP context.
|
||||
Present in the initial CCR only. Consists of four
|
||||
octets. Each octet contains a single UTF-8
|
||||
encoded digit. The content of the charging charac-
|
||||
teristics is described in 3GPP TS 32.215.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
13, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-Charging-Characteristics", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-CG-IPv6-Address */
|
||||
{
|
||||
/*
|
||||
UTF8String.. (3GPP TS 29.061 Rel? (<=10) ). The
|
||||
IPv6 address of the charging gateway.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
14, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-CG-IPv6-Address", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-SGSN-IPv6-Address */
|
||||
{
|
||||
/*
|
||||
UTF8String.. (3GPP TS 29.061 Rel? (<=10) ). The
|
||||
IPv6 address of the SGSN.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
15, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-SGSN-IPv6-Address", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-GGSN-IPv6-Address */
|
||||
{
|
||||
/*
|
||||
UTF8String.. (3GPP TS 29.061 Rel? (<=10) ). The
|
||||
IPv6 address of the GGSN.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
16, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-GGSN-IPv6-Address", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-GGSN-IPv6-DNS-Servers */
|
||||
{
|
||||
/*
|
||||
UTF8String.. (3GPP TS 29.061 Rel? (<=10) ). List
|
||||
of IPv6 addresses of DNS servers for an APN in
|
||||
order of preference (max. 15 servers, 16 bytes
|
||||
each).
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
17, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-GGSN-IPv6-DNS-Servers", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-SGSN-MCC-MNC */
|
||||
{
|
||||
/*
|
||||
UTF8String. (3GPP TS 29.061 Rel7 ). MCC and
|
||||
MNC extracted from the RAI within Create or
|
||||
Update PDP Context Request. In update and ter-
|
||||
mination requests, this AVP is present only when
|
||||
the CCR has been triggered by a routing area
|
||||
update.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
18, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-SGSN-MCC-MNC", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
|
||||
}
|
||||
|
||||
/* Missing: 3GPP-Teardown-Indicator (19) */
|
||||
|
||||
/* 3GPP-IMEISV */
|
||||
{
|
||||
/*
|
||||
IMEI(SV) encoded as sequence of UTF8 characters.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
20, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-IMEISV", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-RAT-Type */
|
||||
{
|
||||
/*
|
||||
OctetString. (3GPP TS 29.061 Rel7 ) Defines the
|
||||
method used to access the network. Consists of a
|
||||
single octet. The following values may be sent:
|
||||
UTRAN (1), GERAN (2), WLAN (3), NAS (254),
|
||||
Unspecified (255).
|
||||
This AVP is included in the initial CCR and in
|
||||
update or termination CCRs if the value changes.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
21, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-RAT-Type", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-User-Location-Info */
|
||||
{
|
||||
/*
|
||||
OctetString. (3GPP TS 29.061 Rel7 ) Contains
|
||||
information about the user's current geographical
|
||||
location as received from the SGSN. Present
|
||||
always in initial CCR if the value is known and in
|
||||
update and termination CCRs if the value
|
||||
changes.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
22, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-User-Location-Info", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
|
||||
}
|
||||
|
||||
/* 3GPP-MS-TimeZone */
|
||||
{
|
||||
/*
|
||||
OctetString. (3GPP TS 29.061 Rel7 ) 3GPP-MS-
|
||||
TimeZone is AVP is present always in the initial CCR if the
|
||||
value is known and in the update and termination
|
||||
CCRs if the value changes. This IE is encoded
|
||||
according to 3GPP TS 29.061 Rel7
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
23, /* Code */
|
||||
10415, /* Vendor */
|
||||
"3GPP-MS-TimeZone", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
|
||||
}
|
||||
|
||||
/* Missing: 3GPP-CAMEL-Charging-Info (24) */
|
||||
/* Missing: 3GPP-Packet-Filter (25) */
|
||||
/* Missing: 3GPP-Negotiated-DSCP (26) */
|
||||
/* Missing: 3GPP-Allocate-IP-Type (27) */
|
||||
|
||||
/* PDP-Context-Type */
|
||||
{
|
||||
/*
|
||||
Enumerated. Indicates the type of a PDP context
|
||||
and is only included in CCR initial.
|
||||
|
||||
values are 0 for primary and 1 for secondary
|
||||
(3GPP 32.299 Rel7)
|
||||
*/
|
||||
struct dict_object *type;
|
||||
struct dict_type_data tdata = { AVP_TYPE_INTEGER32, "Enumerated(PDP-Context-Type)" , NULL, NULL, NULL };
|
||||
struct dict_enumval_data t_0 = { "PRIMARY", { .i32 = 0 }};
|
||||
struct dict_enumval_data t_1 = { "SECONDARY", { .i32 = 1 }};
|
||||
|
||||
struct dict_avp_data data = {
|
||||
1247, /* Code */
|
||||
10415, /* Vendor */
|
||||
"PDP-Context-Type", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_INTEGER32 /* base type of data */
|
||||
};
|
||||
/* Create the Enumerated type, and then the AVP */
|
||||
CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
|
||||
CHECK_dict_new( DICT_ENUMVAL, &t_0 , type, NULL);
|
||||
CHECK_dict_new( DICT_ENUMVAL, &t_1 , type, NULL);
|
||||
CHECK_dict_new( DICT_AVP, &data , type, NULL);
|
||||
}
|
||||
|
||||
/* IMS-Information */
|
||||
{
|
||||
/*
|
||||
Grouped. Its purpose is to allow the transmission
|
||||
of additional IMS service specific information ele-
|
||||
ments. (3GPP 32.299 Rel7)
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
876, /* Code */
|
||||
10415, /* Vendor */
|
||||
"IMS-Information", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_GROUPED /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
|
||||
}
|
||||
|
||||
/* IMS-Charging-Identifier */
|
||||
{
|
||||
/*
|
||||
UTF8String. Contains the IMS charging identifier
|
||||
as given to the Flexi ISN by the IMS. This AVP is
|
||||
defined in 3GPP TS 32.225. This AVP is present
|
||||
in IMS sessions only. Present in the initial CCR
|
||||
only.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
841, /* Code */
|
||||
10415, /* Vendor */
|
||||
"IMS-Charging-Identifier", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_OCTETSTRING /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Max-Requested-Bandwidth-UL */
|
||||
{
|
||||
/*
|
||||
Unsigned32. The Max-Requested-Bandwidth-
|
||||
UL/DL AVP indicates the maximum allowed bit
|
||||
rate (in bits per second) for the uplink direction.
|
||||
(Re-used from 3GPP 29.214)
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
516, /* Code */
|
||||
10415, /* Vendor */
|
||||
"Max-Requested-Bandwidth-UL", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_UNSIGNED32 /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
|
||||
}
|
||||
|
||||
/* Max-Requested-Bandwidth-DL */
|
||||
{
|
||||
/*
|
||||
Unsigned32. The Max-Requested-Bandwidth-
|
||||
UL/DL AVP indicates the maximum allowed bit
|
||||
rate (in bits per second) for the uplink direction.
|
||||
*/
|
||||
struct dict_avp_data data = {
|
||||
515, /* Code */
|
||||
10415, /* Vendor */
|
||||
"Max-Requested-Bandwidth-DL", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */
|
||||
AVP_TYPE_UNSIGNED32 /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
|
||||
}
|
||||
|
||||
/* QoS-Information */
|
||||
{
|
||||
/*
|
||||
Grouped. This is the QoS that the DCCA
|
||||
server requests from Flexi ISN to be applied for
|
||||
this PDP context. This AVP and all AVPs con-
|
||||
tained within are described in 3GPP TS 29.212
|
||||
Release 7. The ARP AVP is introduced with
|
||||
Release 8. The relevant types are defined on
|
||||
table 5.3.1 of TS 29.212.
|
||||
*/
|
||||
|
||||
struct dict_avp_data data = {
|
||||
1016, /* Code */
|
||||
10415, /* Vendor */
|
||||
"QoS-Information", /* Name */
|
||||
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */
|
||||
AVP_FLAG_VENDOR, /* Fixed flag values */
|
||||
AVP_TYPE_GROUPED /* base type of data */
|
||||
};
|
||||
CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
TRACE_DEBUG(INFO, "Extension 'Dictionary definitions for DCCA 3GPP' initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// EXTENSION_ENTRY("dict_dcca_3gpp", dict_dcca_3gpp_entry, "dict_dcca");
|
||||
3789
plat/diameter/extensions/sh_app/gx_app.c
Normal file
3789
plat/diameter/extensions/sh_app/gx_app.c
Normal file
File diff suppressed because it is too large
Load Diff
965
plat/diameter/extensions/sh_app/sh_app.c
Normal file
965
plat/diameter/extensions/sh_app/sh_app.c
Normal file
@@ -0,0 +1,965 @@
|
||||
/*********************************************************************************************************
|
||||
* Software License Agreement (BSD License) *
|
||||
* Author: Sebastien Decugis <sdecugis@freediameter.net> *
|
||||
* *
|
||||
* Copyright (c) 2013, WIDE Project and NICT *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Redistribution and use of this software in source and binary forms, with or without modification, are *
|
||||
* permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* * Redistributions of source code must retain the above *
|
||||
* copyright notice, this list of conditions and the *
|
||||
* following disclaimer. *
|
||||
* *
|
||||
* * Redistributions in binary form must reproduce the above *
|
||||
* copyright notice, this list of conditions and the *
|
||||
* following disclaimer in the documentation and/or other *
|
||||
* materials provided with the distribution. *
|
||||
* *
|
||||
* * Neither the name of the WIDE Project or NICT nor the *
|
||||
* names of its contributors may be used to endorse or *
|
||||
* promote products derived from this software without *
|
||||
* specific prior written permission of WIDE Project and *
|
||||
* NICT. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
|
||||
*********************************************************************************************************/
|
||||
|
||||
/*
|
||||
* Test application for freeDiameter.
|
||||
*/
|
||||
|
||||
#include "sh_app.h"
|
||||
#include "sh_conf.h"
|
||||
|
||||
|
||||
/* Initialize the configuration */
|
||||
struct ta_conf * ta_conf = NULL;
|
||||
static struct ta_conf _conf;
|
||||
static pthread_t ta_stats_th = (pthread_t)NULL;
|
||||
#if 0
|
||||
static int ta_init_peer_addr(struct peer_info* inf)
|
||||
{
|
||||
// uint16_t str;
|
||||
// int ev;
|
||||
|
||||
/* Initialize the server addresses */
|
||||
{
|
||||
struct addrinfo hints, *ai, *aip;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_flags = AI_NUMERICSERV;
|
||||
hints.ai_family = AF_INET;
|
||||
getaddrinfo("localhost", _stringize(TEST_PORT), &hints, &ai);
|
||||
aip = ai;
|
||||
while (aip) {
|
||||
ASSERT( 0 == fd_ep_add_merge( &inf->pi_endpoints, aip->ai_addr, aip->ai_addrlen, EP_FL_DISC | EP_ACCEPTALL ));
|
||||
aip = aip->ai_next;
|
||||
};
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
/* fj added 20170114. when the peer was free. we can reconnect to peer here*/
|
||||
static void peer_free_cb(struct peer_info *died_peer, void *cb_data)
|
||||
{
|
||||
LOG_N("peer_free_cb.%p %p", died_peer, cb_data);
|
||||
SH_CONF_S *ptr = (SH_CONF_S *)cb_data;
|
||||
if(NULL == died_peer && MODE_CLI == ta_conf->mode)
|
||||
{
|
||||
struct peer_info inf;
|
||||
memset(&inf, 0, sizeof(inf));
|
||||
inf.pi_diamid = strdup(ptr->pi_diamid_peer);//strdup(g_sh_conf_ext.pi_diamid_peer);
|
||||
inf.config.pic_flags.sec = PI_SEC_NONE;
|
||||
inf.config.pic_port = ptr->peer_port;
|
||||
// ta_init_peer_addr( (struct peer_info*)(&inf.pi_endpoints) );
|
||||
|
||||
ASSERT( 0 == fd_peer_add(&inf, __FILE__, peer_free_cb, ptr));//NULL));
|
||||
}
|
||||
}
|
||||
static int ta_conf_init(void)
|
||||
{
|
||||
ta_conf = &_conf;
|
||||
memset(ta_conf, 0, sizeof(struct ta_conf));
|
||||
|
||||
/* Set the default values */
|
||||
ta_conf->vendor_id = SH_VND_ID;
|
||||
ta_conf->appli_id = SH_APP_ID;
|
||||
ta_conf->cmd_id = 0xfffffe;
|
||||
ta_conf->avp_id = 0xffffff;
|
||||
ta_conf->long_avp_len = 5000;
|
||||
|
||||
ta_conf->mode = g_sh_conf_ext.mode;
|
||||
/* fj added 20170114. only diameter client connect to peer. In this case, connect to peer when started. */
|
||||
if(MODE_CLI == ta_conf->mode)
|
||||
{
|
||||
if (g_sh_conf_ext.pi_diamid_peer != NULL)
|
||||
{
|
||||
struct peer_info inf;
|
||||
memset(&inf, 0, sizeof(inf));
|
||||
inf.pi_diamid = strdup(g_sh_conf_ext.pi_diamid_peer);
|
||||
inf.config.pic_flags.sec = PI_SEC_NONE;
|
||||
inf.config.pic_port = g_sh_conf_ext.peer_port;
|
||||
// ta_init_peer_addr( (struct peer_info*)(&inf.pi_endpoints) );
|
||||
|
||||
ASSERT( 0 == fd_peer_add(&inf, __FILE__, peer_free_cb, &g_sh_conf_ext));
|
||||
}
|
||||
|
||||
int i=0;
|
||||
SH_CONF_S *pcfg = NULL;
|
||||
for (i=0; i<rolkset.smslknum; i++)
|
||||
{
|
||||
pcfg = &rolkset.smslk[i].cfg;
|
||||
if (pcfg->pi_diamid_peer != NULL)
|
||||
{
|
||||
struct peer_info inf;
|
||||
memset(&inf, 0, sizeof(inf));
|
||||
inf.pi_diamid = strdup(pcfg->pi_diamid_peer);
|
||||
inf.config.pic_flags.sec = PI_SEC_NONE;
|
||||
inf.config.pic_port = pcfg->peer_port;
|
||||
// ta_init_peer_addr( (struct peer_info*)(&inf.pi_endpoints) );
|
||||
|
||||
ASSERT( 0 == fd_peer_add(&inf, __FILE__, peer_free_cb, pcfg));
|
||||
}
|
||||
}
|
||||
for (i=0; i<rolkset.voicelknum; i++)
|
||||
{
|
||||
pcfg = &rolkset.voicelk[i].cfg;
|
||||
if (pcfg->pi_diamid_peer != NULL)
|
||||
{
|
||||
struct peer_info inf;
|
||||
memset(&inf, 0, sizeof(inf));
|
||||
inf.pi_diamid = strdup(pcfg->pi_diamid_peer);
|
||||
inf.config.pic_flags.sec = PI_SEC_NONE;
|
||||
inf.config.pic_port = pcfg->peer_port;
|
||||
// ta_init_peer_addr( (struct peer_info*)(&inf.pi_endpoints) );
|
||||
|
||||
ASSERT( 0 == fd_peer_add(&inf, __FILE__, peer_free_cb, pcfg));
|
||||
}
|
||||
}
|
||||
/*if (g_rosms_conf_ext.pi_diamid_peer != NULL)
|
||||
{
|
||||
struct peer_info inf;
|
||||
memset(&inf, 0, sizeof(inf));
|
||||
inf.pi_diamid = strdup(g_rosms_conf_ext.pi_diamid_peer);
|
||||
inf.config.pic_flags.sec = PI_SEC_NONE;
|
||||
inf.config.pic_port = g_rosms_conf_ext.peer_port;
|
||||
// ta_init_peer_addr( (struct peer_info*)(&inf.pi_endpoints) );
|
||||
|
||||
ASSERT( 0 == fd_peer_add(&inf, __FILE__, peer_free_cb, &g_rosms_conf_ext));
|
||||
}
|
||||
|
||||
if (g_rovoice_conf_ext.pi_diamid_peer != NULL)
|
||||
{
|
||||
struct peer_info inf;
|
||||
memset(&inf, 0, sizeof(inf));
|
||||
inf.pi_diamid = strdup(g_rovoice_conf_ext.pi_diamid_peer);
|
||||
inf.config.pic_flags.sec = PI_SEC_NONE;
|
||||
inf.config.pic_port = g_rovoice_conf_ext.peer_port;
|
||||
// ta_init_peer_addr( (struct peer_info*)(&inf.pi_endpoints) );
|
||||
|
||||
ASSERT( 0 == fd_peer_add(&inf, __FILE__, peer_free_cb, &g_rovoice_conf_ext));
|
||||
}*/
|
||||
}
|
||||
|
||||
ta_conf->dest_realm = strdup(fd_g_config->cnf_diamrlm);
|
||||
ta_conf->signal = TEST_APP_DEFAULT_SIGNAL;
|
||||
ta_conf->bench_concur = 100;
|
||||
ta_conf->bench_duration = 10;
|
||||
|
||||
/* Initialize the mutex */
|
||||
CHECK_POSIX( pthread_mutex_init(&ta_conf->stats_lock, NULL) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ta_conf_dump(void)
|
||||
{
|
||||
if (!TRACE_BOOL(INFO))
|
||||
return;
|
||||
fd_log_debug( "------- app_test configuration dump: ---------");
|
||||
fd_log_debug( " Vendor Id .......... : %u", ta_conf->vendor_id);
|
||||
fd_log_debug( " Application Id ..... : %u", ta_conf->appli_id);
|
||||
fd_log_debug( " Command Id ......... : %u", ta_conf->cmd_id);
|
||||
fd_log_debug( " AVP Id ............. : %u", ta_conf->avp_id);
|
||||
fd_log_debug( " Long AVP Id ........ : %u", ta_conf->long_avp_id);
|
||||
fd_log_debug( " Long AVP len ....... : %zu", ta_conf->long_avp_len);
|
||||
fd_log_debug( " Mode ............... : %s%s%s", ta_conf->mode & MODE_SERV ? "Serv" : "", ta_conf->mode & MODE_CLI ? "Cli" : "", ta_conf->mode & MODE_BENCH ? " (Benchmark)" : "");
|
||||
fd_log_debug( " Destination Realm .. : %s", ta_conf->dest_realm ?: "- none -");
|
||||
fd_log_debug( " Destination Host ... : %s", ta_conf->dest_host ?: "- none -");
|
||||
fd_log_debug( " Signal ............. : %i", ta_conf->signal);
|
||||
fd_log_debug( "------- /app_test configuration dump ---------");
|
||||
}
|
||||
|
||||
/* Function to display statistics periodically */
|
||||
static void * ta_stats(void * arg) {
|
||||
|
||||
struct timespec start, now;
|
||||
struct ta_stats copy;
|
||||
|
||||
/* Get the start time */
|
||||
CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &start), );
|
||||
|
||||
/* Now, loop until canceled */
|
||||
while (1) {
|
||||
/* Display statistics every XX seconds */
|
||||
sleep(ta_conf->bench_duration + 3);
|
||||
|
||||
/* Now, get the current stats */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), );
|
||||
memcpy(©, &ta_conf->stats, sizeof(struct ta_stats));
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), );
|
||||
|
||||
/* Get the current execution time */
|
||||
CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &now), );
|
||||
|
||||
/* Now, display everything */
|
||||
fd_log_debug( "------- app_test statistics ---------");
|
||||
if (now.tv_nsec >= start.tv_nsec) {
|
||||
fd_log_debug( " Executing for: %d.%06ld sec",
|
||||
(int)(now.tv_sec - start.tv_sec),
|
||||
(long)(now.tv_nsec - start.tv_nsec) / 1000);
|
||||
} else {
|
||||
fd_log_debug( " Executing for: %d.%06ld sec",
|
||||
(int)(now.tv_sec - 1 - start.tv_sec),
|
||||
(long)(now.tv_nsec + 1000000000 - start.tv_nsec) / 1000);
|
||||
}
|
||||
|
||||
if (ta_conf->mode & MODE_SERV) {
|
||||
fd_log_debug( " Server: %llu message(s) echoed", copy.nb_echoed);
|
||||
}
|
||||
if (ta_conf->mode & MODE_CLI) {
|
||||
fd_log_debug( " Client:");
|
||||
fd_log_debug( " %llu message(s) sent", copy.nb_sent);
|
||||
fd_log_debug( " %llu error(s) received", copy.nb_errs);
|
||||
fd_log_debug( " %llu answer(s) received", copy.nb_recv);
|
||||
fd_log_debug( " fastest: %ld.%06ld sec.", copy.shortest / 1000000, copy.shortest % 1000000);
|
||||
fd_log_debug( " slowest: %ld.%06ld sec.", copy.longest / 1000000, copy.longest % 1000000);
|
||||
fd_log_debug( " Average: %ld.%06ld sec.", copy.avg / 1000000, copy.avg % 1000000);
|
||||
}
|
||||
fd_log_debug( "-------------------------------------");
|
||||
}
|
||||
|
||||
return NULL; /* never called */
|
||||
}
|
||||
|
||||
static struct fd_hook_hdl * hookhdl[2] = { NULL, NULL };
|
||||
static void ta_hook_cb_silent(enum fd_hook_type type, struct msg * msg, struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, void * regdata) {
|
||||
}
|
||||
static void ta_hook_cb_oneline(enum fd_hook_type type, struct msg * msg, struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, void * regdata) {
|
||||
char * buf = NULL;
|
||||
size_t len;
|
||||
|
||||
CHECK_MALLOC_DO( fd_msg_dump_summary(&buf, &len, NULL, msg, NULL, 0, 0),
|
||||
{ LOG_E("Error while dumping a message"); return; } );
|
||||
|
||||
LOG_N("{%d} %s: %s", type, (char *)other ?:"<nil>", buf ?:"<nil>");
|
||||
|
||||
free(buf);
|
||||
}
|
||||
|
||||
extern int sh_dict_init(char * conffile);
|
||||
extern int dict_dcca_3gpp_entry(char * conffile);
|
||||
extern int dict_dcca_entry(char * conffile);
|
||||
extern struct dict_object * sh_appli;
|
||||
extern struct dict_object * sh_vendor;
|
||||
extern struct dict_object *hw_vendor;
|
||||
extern struct dict_object *uname_vendor_5535;
|
||||
|
||||
|
||||
extern int app_gx_entry(char * conffile);
|
||||
/* entry point */
|
||||
static int ta_entry(char * conffile)
|
||||
{
|
||||
TRACE_ENTRY("%p", conffile);
|
||||
|
||||
/* Initialize configuration */
|
||||
CHECK_FCT( ta_conf_init() );
|
||||
|
||||
/* Parse configuration file */
|
||||
/* fj added 2016/06/21 */
|
||||
#if 0
|
||||
if (conffile != NULL) {
|
||||
CHECK_FCT( ta_conf_handle(conffile) );
|
||||
}
|
||||
#endif
|
||||
|
||||
TRACE_DEBUG(INFO, "Extension Test_App initialized with configuration: '%s'", conffile);
|
||||
ta_conf_dump();
|
||||
|
||||
/* Install objects definitions for this test application */
|
||||
#if 0
|
||||
CHECK_FCT( ta_dict_init() );
|
||||
#else
|
||||
CHECK_FCT( sh_dict_init(NULL) );
|
||||
CHECK_FCT( dict_dcca_3gpp_entry(NULL) );
|
||||
CHECK_FCT( dict_dcca_entry(NULL) );
|
||||
#endif
|
||||
|
||||
/* gx entry */
|
||||
app_gx_entry(NULL);
|
||||
|
||||
|
||||
/* Install the handlers for incoming messages */
|
||||
if (ta_conf->mode & MODE_SERV) {
|
||||
CHECK_FCT( sh_serv_init() );
|
||||
}
|
||||
|
||||
/* Start the signal handler thread */
|
||||
if (ta_conf->mode & MODE_CLI) {
|
||||
if (ta_conf->mode & MODE_BENCH) {
|
||||
CHECK_FCT( ta_bench_init() );
|
||||
} else {
|
||||
CHECK_FCT( sh_cli_init() );
|
||||
}
|
||||
}
|
||||
|
||||
/* Advertise the support for the test application in the peer */
|
||||
CHECK_FCT( fd_disp_app_support ( sh_appli, sh_vendor, 1, 0 ) );
|
||||
|
||||
CHECK_FCT( fd_disp_app_support ( sh_appli, hw_vendor, 1, 0 ) );
|
||||
|
||||
CHECK_FCT( fd_disp_app_support ( sh_appli, uname_vendor_5535, 1, 0 ) );
|
||||
|
||||
if (ta_conf->mode & MODE_BENCH) {
|
||||
/* Register an empty hook to disable the default handling */
|
||||
CHECK_FCT( fd_hook_register( HOOK_MASK( HOOK_DATA_RECEIVED, HOOK_MESSAGE_RECEIVED, HOOK_MESSAGE_LOCAL, HOOK_MESSAGE_SENT, HOOK_MESSAGE_ROUTING_FORWARD, HOOK_MESSAGE_ROUTING_LOCAL ),
|
||||
ta_hook_cb_silent, NULL, NULL, &hookhdl[0]) );
|
||||
CHECK_FCT( fd_hook_register( HOOK_MASK( HOOK_MESSAGE_ROUTING_ERROR, HOOK_MESSAGE_DROPPED ),
|
||||
ta_hook_cb_oneline, NULL, NULL, &hookhdl[1]) );
|
||||
|
||||
}
|
||||
|
||||
/* Start the statistics thread */
|
||||
CHECK_POSIX( pthread_create(&ta_stats_th, NULL, ta_stats, NULL) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Unload */
|
||||
void fd_ext_fini(void)
|
||||
{
|
||||
if (ta_conf->mode & MODE_CLI)
|
||||
sh_cli_finit();
|
||||
if (ta_conf->mode & MODE_SERV)
|
||||
sh_serv_fini();
|
||||
if (hookhdl[0])
|
||||
fd_hook_unregister( hookhdl[0] );
|
||||
if (hookhdl[1])
|
||||
fd_hook_unregister( hookhdl[1] );
|
||||
CHECK_FCT_DO( fd_thr_term(&ta_stats_th), );
|
||||
CHECK_POSIX_DO( pthread_mutex_destroy(&ta_conf->stats_lock), );
|
||||
}
|
||||
|
||||
/*
|
||||
* fj added 2016/06/21
|
||||
* parse config file
|
||||
*
|
||||
*/
|
||||
|
||||
/* fj added 2016/06/20 */
|
||||
/* The cryptographic data */
|
||||
static char ca_data[] = "-----BEGIN CERTIFICATE-----\n"
|
||||
"MIIEqjCCA5KgAwIBAgIJANKgDwdlDYQDMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD\n"
|
||||
"VQQGEwJKUDEOMAwGA1UECAwFVG9reW8xEDAOBgNVBAcMB0tvZ2FuZWkxDTALBgNV\n"
|
||||
"BAoMBFdJREUxDzANBgNVBAsMBkFBQSBXRzEfMB0GA1UEAwwWY2hhdnJvdXguY293\n"
|
||||
"YWRkaWN0Lm9yZzEiMCAGCSqGSIb3DQEJARYTc2RlY3VnaXNAbmljdC5nby5qcDAe\n"
|
||||
"Fw0wOTEwMDUwODUxNDRaFw0xOTEwMDMwODUxNDRaMIGUMQswCQYDVQQGEwJKUDEO\n"
|
||||
"MAwGA1UECAwFVG9reW8xEDAOBgNVBAcMB0tvZ2FuZWkxDTALBgNVBAoMBFdJREUx\n"
|
||||
"DzANBgNVBAsMBkFBQSBXRzEfMB0GA1UEAwwWY2hhdnJvdXguY293YWRkaWN0Lm9y\n"
|
||||
"ZzEiMCAGCSqGSIb3DQEJARYTc2RlY3VnaXNAbmljdC5nby5qcDCCASIwDQYJKoZI\n"
|
||||
"hvcNAQEBBQADggEPADCCAQoCggEBAM5c6w4NnngTvGNWcJzbo0Kklp+kvUNQNgGu\n"
|
||||
"myvz826qPp07HTSyJrIcgFnuYDR0Nd130Ot9u5osqpQhHTvolxDE87Tii8i3hJSj\n"
|
||||
"TTY9K0ZwGb4AZ6QkuyMXS1jtOY657HqjpGZqT/2Syh0i7dM/hqSXFw0SPbyq+W1H\n"
|
||||
"SVFWa1CTkPywFWAzwdr5WKah77uZ1dxWqgPgUdcZOiIQtLRp5n3fg40Nwso5YdwS\n"
|
||||
"64+ebBX1pkhrCQ8AGc8O61Ep1JTXcO7jqQmPgzjiN+FeostI1Dp73S3MqleTAHjR\n"
|
||||
"hqZ77VF7nkroMM9btMHJBaxnfwc2ewULUJwnuOiGWrvMq/9Z4J8CAwEAAaOB/DCB\n"
|
||||
"+TAdBgNVHQ4EFgQUkqpVn7N3gmiJ7X5zQ2bki+7qv4UwgckGA1UdIwSBwTCBvoAU\n"
|
||||
"kqpVn7N3gmiJ7X5zQ2bki+7qv4WhgZqkgZcwgZQxCzAJBgNVBAYTAkpQMQ4wDAYD\n"
|
||||
"VQQIDAVUb2t5bzEQMA4GA1UEBwwHS29nYW5laTENMAsGA1UECgwEV0lERTEPMA0G\n"
|
||||
"A1UECwwGQUFBIFdHMR8wHQYDVQQDDBZjaGF2cm91eC5jb3dhZGRpY3Qub3JnMSIw\n"
|
||||
"IAYJKoZIhvcNAQkBFhNzZGVjdWdpc0BuaWN0LmdvLmpwggkA0qAPB2UNhAMwDAYD\n"
|
||||
"VR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAJy0XLk8j8YLSTt2/VMy9TAUx\n"
|
||||
"esXUiZj0Ung+gkr7A1K0NnwYxDzG2adMhf13upHoydu2ErLMmD6F77x+QuY/q7nc\n"
|
||||
"ZvO0tvcoAP6ToSDwiypU5dnTmnfkgwVwzFkNCi1sGRosEm8c/c/8MfK0I0nVdj1/\n"
|
||||
"BIkIG7tTDVi9JvkWYl0UlSKWTZKrntVwCmscfC02DGb+GoLbO9+QmiNM5Y3yOYZ4\n"
|
||||
"Pc7SSoKLL0rwJBmpPNs7boYsweeSuCAVu0shRfgC90odXcej2EN5ETfCuU1evXNW\n"
|
||||
"5cA+zZsDK/nWJwxBaW0CxAHX579FElFWlK4+BnzhZRdDhmJDnN5dh4ekJGM6Lg==\n"
|
||||
"-----END CERTIFICATE-----\n";
|
||||
|
||||
/* Client:
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 5 (0x5)
|
||||
Signature Algorithm: sha1WithRSAEncryption
|
||||
Issuer: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=chavroux.cowaddict.org/emailAddress=sdecugis@nict.go.jp
|
||||
Validity
|
||||
Not Before: Oct 27 04:04:05 2009 GMT
|
||||
Not After : Oct 25 04:04:05 2019 GMT
|
||||
Subject: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=client.test/emailAddress=client@test
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
RSA Public Key: (1024 bit)
|
||||
Modulus (1024 bit):
|
||||
00:bd:eb:50:1e:9d:7a:cd:9d:bb:e7:bc:4e:38:4a:
|
||||
b2:cc:9e:b4:89:77:01:ef:d1:c6:19:29:00:fe:ce:
|
||||
3c:62:05:13:b1:8c:ff:31:7a:0f:c1:2e:4b:3c:0c:
|
||||
40:1e:36:4e:76:da:0a:64:43:fc:1e:ea:0c:97:b2:
|
||||
57:9c:9c:8c:90:bd:eb:23:7b:b8:b7:5c:03:ed:6f:
|
||||
48:55:8a:88:08:38:c5:cd:33:b7:ab:a8:3a:6f:7f:
|
||||
13:10:65:a5:50:b9:f4:8b:cc:2e:e9:79:58:a6:11:
|
||||
f0:58:45:41:ef:36:b3:35:cb:14:ec:82:0c:ad:11:
|
||||
6a:ea:64:ef:28:a2:6e:47:45
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Basic Constraints:
|
||||
CA:FALSE
|
||||
Netscape Comment:
|
||||
OpenSSL Generated Certificate
|
||||
X509v3 Subject Key Identifier:
|
||||
BE:B3:89:4F:9D:8F:6C:20:C4:D0:3E:6A:05:11:82:50:54:49:70:A2
|
||||
X509v3 Authority Key Identifier:
|
||||
keyid:92:AA:55:9F:B3:77:82:68:89:ED:7E:73:43:66:E4:8B:EE:EA:BF:85
|
||||
|
||||
Signature Algorithm: sha1WithRSAEncryption
|
||||
a3:88:f5:15:b5:ad:20:60:a1:85:19:3f:b9:5e:1e:be:31:7f:
|
||||
84:7a:c2:18:3a:63:6a:67:1f:46:86:4d:10:d6:1d:ad:a2:c8:
|
||||
0b:95:33:fa:e4:05:f4:b8:70:34:77:f7:85:6e:70:46:ac:39:
|
||||
54:a9:5f:ea:5e:d1:33:bb:c9:a3:42:81:41:90:25:b5:92:8b:
|
||||
e8:6e:3e:97:06:dd:9a:cc:29:61:34:5a:d3:1c:5d:ad:d1:a3:
|
||||
eb:6a:47:b4:d0:c2:17:89:e1:e2:2d:36:18:50:1a:e7:d4:fc:
|
||||
38:2e:47:0b:39:50:87:2f:aa:07:64:f8:9a:4d:47:01:da:10:
|
||||
d8:97:c7:a6:13:bc:0e:ca:63:c1:f2:09:fb:f8:6a:a4:5f:08:
|
||||
b5:ad:ed:4f:71:b9:89:7f:43:27:85:72:e7:8d:a8:4a:cc:f6:
|
||||
36:ca:8a:ae:82:b5:a8:42:41:99:87:84:7c:f0:90:fd:ca:96:
|
||||
37:a2:e0:d9:fa:dd:a4:c9:f1:50:b7:e5:e6:8f:af:83:8c:23:
|
||||
b6:20:cc:66:e3:08:60:13:02:8f:42:3a:07:91:a7:38:b2:72:
|
||||
16:fd:bd:a9:60:f0:e2:9f:23:f3:c0:99:e3:17:bc:00:7c:b3:
|
||||
89:9c:ea:fa:3e:f6:69:a1:98:c2:ec:46:da:70:b6:f9:c3:93:
|
||||
a7:fc:36:dd
|
||||
*/
|
||||
/*
|
||||
static char client_cert_data[] ="-----BEGIN CERTIFICATE-----\n"
|
||||
"MIIDiTCCAnGgAwIBAgIBBTANBgkqhkiG9w0BAQUFADCBlDELMAkGA1UEBhMCSlAx\n"
|
||||
"DjAMBgNVBAgMBVRva3lvMRAwDgYDVQQHDAdLb2dhbmVpMQ0wCwYDVQQKDARXSURF\n"
|
||||
"MQ8wDQYDVQQLDAZBQUEgV0cxHzAdBgNVBAMMFmNoYXZyb3V4LmNvd2FkZGljdC5v\n"
|
||||
"cmcxIjAgBgkqhkiG9w0BCQEWE3NkZWN1Z2lzQG5pY3QuZ28uanAwHhcNMDkxMDI3\n"
|
||||
"MDQwNDA1WhcNMTkxMDI1MDQwNDA1WjCBgTELMAkGA1UEBhMCSlAxDjAMBgNVBAgM\n"
|
||||
"BVRva3lvMRAwDgYDVQQHDAdLb2dhbmVpMQ0wCwYDVQQKDARXSURFMQ8wDQYDVQQL\n"
|
||||
"DAZBQUEgV0cxFDASBgNVBAMMC2NsaWVudC50ZXN0MRowGAYJKoZIhvcNAQkBFgtj\n"
|
||||
"bGllbnRAdGVzdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAvetQHp16zZ27\n"
|
||||
"57xOOEqyzJ60iXcB79HGGSkA/s48YgUTsYz/MXoPwS5LPAxAHjZOdtoKZEP8HuoM\n"
|
||||
"l7JXnJyMkL3rI3u4t1wD7W9IVYqICDjFzTO3q6g6b38TEGWlULn0i8wu6XlYphHw\n"
|
||||
"WEVB7zazNcsU7IIMrRFq6mTvKKJuR0UCAwEAAaN7MHkwCQYDVR0TBAIwADAsBglg\n"
|
||||
"hkgBhvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0O\n"
|
||||
"BBYEFL6ziU+dj2wgxNA+agURglBUSXCiMB8GA1UdIwQYMBaAFJKqVZ+zd4Joie1+\n"
|
||||
"c0Nm5Ivu6r+FMA0GCSqGSIb3DQEBBQUAA4IBAQCjiPUVta0gYKGFGT+5Xh6+MX+E\n"
|
||||
"esIYOmNqZx9Ghk0Q1h2tosgLlTP65AX0uHA0d/eFbnBGrDlUqV/qXtEzu8mjQoFB\n"
|
||||
"kCW1kovobj6XBt2azClhNFrTHF2t0aPrake00MIXieHiLTYYUBrn1Pw4LkcLOVCH\n"
|
||||
"L6oHZPiaTUcB2hDYl8emE7wOymPB8gn7+GqkXwi1re1PcbmJf0MnhXLnjahKzPY2\n"
|
||||
"yoqugrWoQkGZh4R88JD9ypY3ouDZ+t2kyfFQt+Xmj6+DjCO2IMxm4whgEwKPQjoH\n"
|
||||
"kac4snIW/b2pYPDinyPzwJnjF7wAfLOJnOr6PvZpoZjC7EbacLb5w5On/Dbd\n"
|
||||
"-----END CERTIFICATE-----\n";
|
||||
static char client_priv_data[] ="-----BEGIN RSA PRIVATE KEY-----\n"
|
||||
"MIICXgIBAAKBgQC961AenXrNnbvnvE44SrLMnrSJdwHv0cYZKQD+zjxiBROxjP8x\n"
|
||||
"eg/BLks8DEAeNk522gpkQ/we6gyXslecnIyQvesje7i3XAPtb0hViogIOMXNM7er\n"
|
||||
"qDpvfxMQZaVQufSLzC7peVimEfBYRUHvNrM1yxTsggytEWrqZO8oom5HRQIDAQAB\n"
|
||||
"AoGBAIYnsOLPby3LnC5n8AEHkyHDgdgQvsd/MSYYtuFHIZRD7dNfu+xhQru9TdvO\n"
|
||||
"84Pj7K07/FczRuc3gUmu6wBv/UIP9To15RHZh+/n537nybGus5S4IYKVvap477To\n"
|
||||
"0rQDf9ec27iw77gxb7moQ9Otuxwbv0h0Z+1EVLI8d8jHOq0BAkEA9YNr0R+7KXBS\n"
|
||||
"48yT43g5HpOFkTZzNXWVdpSvYGneb56wslk5Eatp235I4uz/a7Rej5v99W0M3nSe\n"
|
||||
"/AgHfYn75QJBAMYH/pBx/WkrLj+pPaARlNwInCIC5zUhr6B0IKCt2tvy5eyuc5sd\n"
|
||||
"AoTFaU+cSI+ZqsRzY8jMKkonktxBg48oJ+ECQQCt4AtlqcFVkbVCm8pJGQXq/7Ni\n"
|
||||
"qlthiwr1Vkv2TkQ4bPza8pGWT/3Cc2ePPyWN08n8jw+G11p72cAW4mDbqfN5AkEA\n"
|
||||
"mNYKrkiLn+NnqlJf8W4gSUGL3uQGtYbuGRQHKnuDckWhFm39YzWcgAQsJvkjN1EN\n"
|
||||
"7thvpsWLzfeE7ODTPGVtgQJATObxYJOt6rms3fAStwuXW3ET77TA1ja4XsUEe5Yu\n"
|
||||
"JpcQOruJb9XwndqzNbL0dSUePb9gFiBCGKYOyreNTTRTmw==\n"
|
||||
"-----END RSA PRIVATE KEY-----\n";
|
||||
*/
|
||||
|
||||
/* Server:
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 4 (0x4)
|
||||
Signature Algorithm: sha1WithRSAEncryption
|
||||
Issuer: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=chavroux.cowaddict.org/emailAddress=sdecugis@nict.go.jp
|
||||
Validity
|
||||
Not Before: Oct 27 04:03:39 2009 GMT
|
||||
Not After : Oct 25 04:03:39 2019 GMT
|
||||
Subject: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=serv.test/emailAddress=serv@test
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
RSA Public Key: (1024 bit)
|
||||
Modulus (1024 bit):
|
||||
00:a6:f7:1c:a9:90:5b:fa:c8:f6:a3:04:0c:d0:8b:
|
||||
45:c3:90:f7:2d:c2:c9:d7:bd:66:8a:7c:1c:51:89:
|
||||
40:9e:cd:70:57:cb:00:47:a3:e8:76:8b:00:b3:c9:
|
||||
c3:0d:b1:b9:2a:08:9f:52:92:82:d3:18:c1:d8:d1:
|
||||
b8:1e:fd:71:fe:23:ec:19:e9:6d:9d:fd:ae:88:bc:
|
||||
39:44:7a:37:ad:c6:88:d1:64:7c:b1:d4:3c:a9:30:
|
||||
c4:de:51:02:c4:48:4f:25:3e:2f:93:ae:25:32:66:
|
||||
9a:dc:f4:44:45:ff:7f:12:49:97:0d:01:8d:13:9a:
|
||||
d3:8f:9e:2d:62:95:02:0a:c7
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Basic Constraints:
|
||||
CA:FALSE
|
||||
Netscape Comment:
|
||||
OpenSSL Generated Certificate
|
||||
X509v3 Subject Key Identifier:
|
||||
0C:33:C4:7F:39:D0:34:FF:F8:61:A1:46:8B:49:1D:A3:57:B3:4D:58
|
||||
X509v3 Authority Key Identifier:
|
||||
keyid:92:AA:55:9F:B3:77:82:68:89:ED:7E:73:43:66:E4:8B:EE:EA:BF:85
|
||||
|
||||
Signature Algorithm: sha1WithRSAEncryption
|
||||
87:f5:49:a6:04:f9:98:9a:f1:1a:68:ce:06:ae:4c:0c:08:eb:
|
||||
ba:98:e7:3f:df:22:7f:35:88:1d:b7:8a:f3:89:a3:68:0d:53:
|
||||
45:eb:23:a1:dd:6b:dc:b0:80:58:0c:10:0b:49:74:ea:a8:b6:
|
||||
8c:2e:c6:73:dc:7a:74:c7:59:3e:79:5a:d2:5c:15:0b:f1:d8:
|
||||
19:37:2a:c0:22:75:10:3f:4c:e9:a1:e0:eb:b2:9e:09:70:3d:
|
||||
2a:4c:fe:9c:99:36:4b:aa:6c:e1:8b:9c:aa:e1:29:1f:49:6b:
|
||||
14:db:12:ae:cf:68:4a:dd:03:e1:3b:ad:79:b4:54:84:1d:bb:
|
||||
ac:45:c4:85:f1:03:65:65:96:23:ae:e7:97:3c:5c:db:ce:55:
|
||||
34:5d:c3:73:ec:cd:f6:0f:a5:81:5f:c2:ab:a3:42:fa:36:7f:
|
||||
83:ef:db:0f:cd:62:0b:ea:d9:4f:73:35:68:5f:23:d5:0a:be:
|
||||
ff:7f:23:9a:af:0d:a5:f8:3e:3a:f0:63:1c:e1:d2:96:81:cf:
|
||||
7b:5a:6b:d0:9b:67:56:9e:aa:a9:e8:f1:6c:fb:54:2b:1a:f4:
|
||||
ef:16:5a:be:1d:a9:c8:d6:cc:f7:42:8c:fe:83:2c:84:8c:80:
|
||||
fb:1c:88:f6:35:1c:ae:43:72:fa:68:30:9c:25:8b:db:2c:84:
|
||||
87:76:9d:b9
|
||||
*/
|
||||
static char server_cert_data[] ="-----BEGIN CERTIFICATE-----\n"
|
||||
"MIIDhDCCAmygAwIBAgIBBDANBgkqhkiG9w0BAQUFADCBlDELMAkGA1UEBhMCSlAx\n"
|
||||
"DjAMBgNVBAgMBVRva3lvMRAwDgYDVQQHDAdLb2dhbmVpMQ0wCwYDVQQKDARXSURF\n"
|
||||
"MQ8wDQYDVQQLDAZBQUEgV0cxHzAdBgNVBAMMFmNoYXZyb3V4LmNvd2FkZGljdC5v\n"
|
||||
"cmcxIjAgBgkqhkiG9w0BCQEWE3NkZWN1Z2lzQG5pY3QuZ28uanAwHhcNMDkxMDI3\n"
|
||||
"MDQwMzM5WhcNMTkxMDI1MDQwMzM5WjB9MQswCQYDVQQGEwJKUDEOMAwGA1UECAwF\n"
|
||||
"VG9reW8xEDAOBgNVBAcMB0tvZ2FuZWkxDTALBgNVBAoMBFdJREUxDzANBgNVBAsM\n"
|
||||
"BkFBQSBXRzESMBAGA1UEAwwJc2Vydi50ZXN0MRgwFgYJKoZIhvcNAQkBFglzZXJ2\n"
|
||||
"QHRlc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKb3HKmQW/rI9qMEDNCL\n"
|
||||
"RcOQ9y3Cyde9Zop8HFGJQJ7NcFfLAEej6HaLALPJww2xuSoIn1KSgtMYwdjRuB79\n"
|
||||
"cf4j7BnpbZ39roi8OUR6N63GiNFkfLHUPKkwxN5RAsRITyU+L5OuJTJmmtz0REX/\n"
|
||||
"fxJJlw0BjROa04+eLWKVAgrHAgMBAAGjezB5MAkGA1UdEwQCMAAwLAYJYIZIAYb4\n"
|
||||
"QgENBB8WHU9wZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBQM\n"
|
||||
"M8R/OdA0//hhoUaLSR2jV7NNWDAfBgNVHSMEGDAWgBSSqlWfs3eCaIntfnNDZuSL\n"
|
||||
"7uq/hTANBgkqhkiG9w0BAQUFAAOCAQEAh/VJpgT5mJrxGmjOBq5MDAjrupjnP98i\n"
|
||||
"fzWIHbeK84mjaA1TResjod1r3LCAWAwQC0l06qi2jC7Gc9x6dMdZPnla0lwVC/HY\n"
|
||||
"GTcqwCJ1ED9M6aHg67KeCXA9Kkz+nJk2S6ps4YucquEpH0lrFNsSrs9oSt0D4Tut\n"
|
||||
"ebRUhB27rEXEhfEDZWWWI67nlzxc285VNF3Dc+zN9g+lgV/Cq6NC+jZ/g+/bD81i\n"
|
||||
"C+rZT3M1aF8j1Qq+/38jmq8Npfg+OvBjHOHSloHPe1pr0JtnVp6qqejxbPtUKxr0\n"
|
||||
"7xZavh2pyNbM90KM/oMshIyA+xyI9jUcrkNy+mgwnCWL2yyEh3aduQ==\n"
|
||||
"-----END CERTIFICATE-----\n";
|
||||
static char server_priv_data[] ="-----BEGIN RSA PRIVATE KEY-----\n"
|
||||
"MIICXQIBAAKBgQCm9xypkFv6yPajBAzQi0XDkPctwsnXvWaKfBxRiUCezXBXywBH\n"
|
||||
"o+h2iwCzycMNsbkqCJ9SkoLTGMHY0bge/XH+I+wZ6W2d/a6IvDlEejetxojRZHyx\n"
|
||||
"1DypMMTeUQLESE8lPi+TriUyZprc9ERF/38SSZcNAY0TmtOPni1ilQIKxwIDAQAB\n"
|
||||
"AoGAZv3Ddm0P79CLIt9asEFY1VvUvSuMqkGwwPfx1/HcJJkBFYapM4fN22G/Gyf3\n"
|
||||
"47ifSWhsLtklTeXVnVMwSh14dJaJQuSEnaFnUUWfjiRbEAXZnMFwAIiaszEZbPap\n"
|
||||
"NUNpcGl06FZrphYAMkjOVUfjCjfOZDAvL4JGpo271Zx4l0ECQQDYoFFQpBCPx0PK\n"
|
||||
"TWUmvatXI/Amo94XkGfofbdeeI8PiAJBO5UI6rmjjIVwsJwO9dQb/IlP1/OnBeJv\n"
|
||||
"p9YW5uixAkEAxVAOKu7mpGu0Q/K2iEUUYDX9YHf253kgkdIDF4iZk4Tcecjoxuru\n"
|
||||
"fIWu9dMtyDVV+HT2X4cNEnO1/oS3kJII9wJBAJkdwDwiqz4lV6o/yFZ4zAoc8dsu\n"
|
||||
"CoZXYMq5SYox5tTQit928OHLn4mVgqBjhPsiEVnyx0+zUZpmE2ZemHm5nxECQHfE\n"
|
||||
"FBVzVYRP6+eil7E3XRrZKqc3qiLunxpkA4RxYebtKnaxwLmdOI1VB9InEQ8JcNmT\n"
|
||||
"BUkOzJx6p+mJ3XJfchkCQQDWmbMYYJajsjlS4YpdUUj7cBSotA6vtkNVHFr0/ak/\n"
|
||||
"S+tLkMNuruaInWizK+BKYTIJLlQDf5u5NTrw41vye5Hv\n"
|
||||
"-----END RSA PRIVATE KEY-----\n";
|
||||
|
||||
/* Expired:
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 6 (0x6)
|
||||
Signature Algorithm: sha1WithRSAEncryption
|
||||
Issuer: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=chavroux.cowaddict.org/emailAddress=sdecugis@nict.go.jp
|
||||
Validity
|
||||
Not Before: Oct 27 04:06:35 2009 GMT
|
||||
Not After : Oct 28 04:06:35 2009 GMT
|
||||
Subject: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=expired.test/emailAddress=expired@test
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
RSA Public Key: (1024 bit)
|
||||
Modulus (1024 bit):
|
||||
00:e3:17:15:54:85:dc:cf:c7:a0:32:4a:49:7d:55:
|
||||
75:9b:29:15:db:7e:87:17:d9:0e:65:44:53:d7:19:
|
||||
37:27:c7:c6:fe:c6:dc:72:2b:dc:86:1a:ff:24:6c:
|
||||
63:3f:75:9c:0a:14:e1:70:06:79:d4:b9:26:d4:68:
|
||||
4c:28:38:ba:34:60:56:02:3d:94:55:4a:1f:4e:5a:
|
||||
f0:a5:71:4c:3e:71:69:39:ad:bc:aa:55:35:fb:73:
|
||||
5b:5f:6c:30:71:8e:8a:b6:a5:06:cc:ee:dd:29:c7:
|
||||
52:0d:a7:9c:0f:a1:ba:52:11:e2:1b:b9:74:6b:08:
|
||||
87:11:d2:ec:a9:ac:63:63:4f
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Basic Constraints:
|
||||
CA:FALSE
|
||||
Netscape Comment:
|
||||
OpenSSL Generated Certificate
|
||||
X509v3 Subject Key Identifier:
|
||||
1C:AF:66:42:5B:AD:AA:A5:9B:D9:AE:3A:C1:5A:AC:2F:CC:CE:22:6C
|
||||
X509v3 Authority Key Identifier:
|
||||
keyid:92:AA:55:9F:B3:77:82:68:89:ED:7E:73:43:66:E4:8B:EE:EA:BF:85
|
||||
|
||||
Signature Algorithm: sha1WithRSAEncryption
|
||||
60:8f:55:55:59:82:0f:64:cb:b8:11:c8:44:ce:bf:69:07:0d:
|
||||
be:c2:34:be:42:6a:78:15:39:9f:be:8a:17:d6:43:42:c9:7c:
|
||||
f1:6d:5d:aa:c3:1b:4d:b0:f0:b6:73:46:2a:87:cd:55:56:a3:
|
||||
6d:cc:de:a8:28:6a:53:85:9e:e5:68:b7:3c:f5:72:13:7b:d0:
|
||||
21:f2:91:49:35:e0:37:1e:28:19:d5:1b:cc:e1:32:1e:7f:b0:
|
||||
86:df:43:a4:47:0f:29:0b:eb:51:60:9a:f5:ca:50:f4:2d:59:
|
||||
cd:fc:50:9d:29:ed:45:98:de:a2:5c:d1:b5:7a:34:ad:7a:73:
|
||||
48:8b:a2:9b:89:8e:4a:2e:2a:04:19:d6:62:6a:0d:f0:96:f2:
|
||||
f0:d0:22:77:3b:7f:b1:2a:f4:3b:17:47:5e:38:07:09:65:ad:
|
||||
1d:ea:46:69:6a:96:b6:6b:3b:5c:cc:6e:30:d7:cb:53:69:59:
|
||||
c2:63:78:2b:03:d4:d4:f7:17:29:99:9a:43:ff:78:0a:af:42:
|
||||
c5:b3:8d:09:38:5b:30:70:28:c1:97:ab:fd:7f:87:9a:ec:f2:
|
||||
97:44:ff:f5:b9:41:30:d1:c6:32:98:69:34:c4:39:30:6f:e2:
|
||||
d3:b2:70:97:66:ee:41:f5:ae:0f:09:f0:ed:60:96:67:a9:8a:
|
||||
cd:d6:95:f2
|
||||
*/
|
||||
/*
|
||||
static char expired_cert_data[]="-----BEGIN CERTIFICATE-----\n"
|
||||
"MIIDizCCAnOgAwIBAgIBBjANBgkqhkiG9w0BAQUFADCBlDELMAkGA1UEBhMCSlAx\n"
|
||||
"DjAMBgNVBAgMBVRva3lvMRAwDgYDVQQHDAdLb2dhbmVpMQ0wCwYDVQQKDARXSURF\n"
|
||||
"MQ8wDQYDVQQLDAZBQUEgV0cxHzAdBgNVBAMMFmNoYXZyb3V4LmNvd2FkZGljdC5v\n"
|
||||
"cmcxIjAgBgkqhkiG9w0BCQEWE3NkZWN1Z2lzQG5pY3QuZ28uanAwHhcNMDkxMDI3\n"
|
||||
"MDQwNjM1WhcNMDkxMDI4MDQwNjM1WjCBgzELMAkGA1UEBhMCSlAxDjAMBgNVBAgM\n"
|
||||
"BVRva3lvMRAwDgYDVQQHDAdLb2dhbmVpMQ0wCwYDVQQKDARXSURFMQ8wDQYDVQQL\n"
|
||||
"DAZBQUEgV0cxFTATBgNVBAMMDGV4cGlyZWQudGVzdDEbMBkGCSqGSIb3DQEJARYM\n"
|
||||
"ZXhwaXJlZEB0ZXN0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDjFxVUhdzP\n"
|
||||
"x6AySkl9VXWbKRXbfocX2Q5lRFPXGTcnx8b+xtxyK9yGGv8kbGM/dZwKFOFwBnnU\n"
|
||||
"uSbUaEwoOLo0YFYCPZRVSh9OWvClcUw+cWk5rbyqVTX7c1tfbDBxjoq2pQbM7t0p\n"
|
||||
"x1INp5wPobpSEeIbuXRrCIcR0uyprGNjTwIDAQABo3sweTAJBgNVHRMEAjAAMCwG\n"
|
||||
"CWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNV\n"
|
||||
"HQ4EFgQUHK9mQlutqqWb2a46wVqsL8zOImwwHwYDVR0jBBgwFoAUkqpVn7N3gmiJ\n"
|
||||
"7X5zQ2bki+7qv4UwDQYJKoZIhvcNAQEFBQADggEBAGCPVVVZgg9ky7gRyETOv2kH\n"
|
||||
"Db7CNL5CangVOZ++ihfWQ0LJfPFtXarDG02w8LZzRiqHzVVWo23M3qgoalOFnuVo\n"
|
||||
"tzz1chN70CHykUk14DceKBnVG8zhMh5/sIbfQ6RHDykL61FgmvXKUPQtWc38UJ0p\n"
|
||||
"7UWY3qJc0bV6NK16c0iLopuJjkouKgQZ1mJqDfCW8vDQInc7f7Eq9DsXR144Bwll\n"
|
||||
"rR3qRmlqlrZrO1zMbjDXy1NpWcJjeCsD1NT3FymZmkP/eAqvQsWzjQk4WzBwKMGX\n"
|
||||
"q/1/h5rs8pdE//W5QTDRxjKYaTTEOTBv4tOycJdm7kH1rg8J8O1glmepis3WlfI=\n"
|
||||
"-----END CERTIFICATE-----\n";
|
||||
static char expired_priv_data[]="-----BEGIN RSA PRIVATE KEY-----\n"
|
||||
"MIICXgIBAAKBgQDjFxVUhdzPx6AySkl9VXWbKRXbfocX2Q5lRFPXGTcnx8b+xtxy\n"
|
||||
"K9yGGv8kbGM/dZwKFOFwBnnUuSbUaEwoOLo0YFYCPZRVSh9OWvClcUw+cWk5rbyq\n"
|
||||
"VTX7c1tfbDBxjoq2pQbM7t0px1INp5wPobpSEeIbuXRrCIcR0uyprGNjTwIDAQAB\n"
|
||||
"AoGASwPoDui9XYHTIGm7xwRA+kVjLAOq+qy//aHJlEeHGcP7r1PfpHNqwH4QhGat\n"
|
||||
"jlv6dLYbFld9TVDwS8A8UBkVIPLWnCysd5tF2A4C5akx6ouW6HliW/JheYrgl8AV\n"
|
||||
"PVeR3bm91UbnpC0ABVlw87jp1Ovyr60Suo4jsoJz+CyTa2ECQQD0LJWpnwn1jIlR\n"
|
||||
"DGkLi7F3E70JJcdhTWzBjGFD+Na+/2ZO0MKLhK+O1WUkKa0oi+e5P1JOnGIpTI8c\n"
|
||||
"BJOO415RAkEA7hauapYuqGI/auSPH8/nFB5z1G94RTxo2a5THKcG5MqS/8N3ubFj\n"
|
||||
"i2PPS0lEYVjqoHEsZUsMnDmXp6KDKMAfnwJBAIp+T1UqM8fmsmwaEerOjRXxSCNM\n"
|
||||
"Hk5+T9Vn/jNDjOpAipLhrbbcx4bIWtmsGd8Jm6Fi3RhhcvvhxLorjlZZeEECQQCf\n"
|
||||
"IaPD88sNmlUewdLzhUbCiLQMadCuHflKfRxpyy1tYAQuVFxCTdDlynkzra25ju+K\n"
|
||||
"+vmcXjP4evnk/lbBtt+rAkEAgOr4Apgs3nMppngPV5yFx0NDqH2n8PlEAM1Il4Qs\n"
|
||||
"IuuK18v0KwlUGAfEEmCiNh1e1qkLmD0CnI2QjYAjcLQUhw==\n"
|
||||
"-----END RSA PRIVATE KEY-----\n";
|
||||
*/
|
||||
|
||||
/* Unknown CA certificate :
|
||||
Certificate:
|
||||
Data:
|
||||
Version: 3 (0x2)
|
||||
Serial Number: 1 (0x1)
|
||||
Signature Algorithm: sha1WithRSAEncryption
|
||||
Issuer: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=chavroux.cowaddict.org/emailAddress=sdecugis@nict.go.jp
|
||||
Validity
|
||||
Not Before: Oct 28 08:04:40 2009 GMT
|
||||
Not After : Oct 28 08:04:40 2010 GMT
|
||||
Subject: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=unknown.cs/emailAddress=unknown@ca
|
||||
Subject Public Key Info:
|
||||
Public Key Algorithm: rsaEncryption
|
||||
RSA Public Key: (1024 bit)
|
||||
Modulus (1024 bit):
|
||||
00:e6:3a:d5:8a:14:c8:15:d0:f0:5c:03:c3:af:33:
|
||||
51:2c:17:b7:65:ac:45:e8:48:2d:ae:70:fd:7c:79:
|
||||
3a:c7:80:c8:50:53:d0:19:d8:3a:26:a8:16:4d:4c:
|
||||
04:17:09:df:69:9b:59:2b:89:c8:e0:60:bb:1d:37:
|
||||
82:d2:3f:17:39:c9:8f:5d:76:e1:0f:6e:08:9a:8f:
|
||||
16:4a:ea:83:86:f9:bd:15:14:56:68:87:79:05:f9:
|
||||
5f:66:11:bd:22:46:26:64:be:57:16:51:66:41:50:
|
||||
ac:f2:b1:ca:d0:38:11:4b:4c:b2:ee:25:36:6e:d3:
|
||||
b9:63:72:c4:84:82:1c:2b:27
|
||||
Exponent: 65537 (0x10001)
|
||||
X509v3 extensions:
|
||||
X509v3 Basic Constraints:
|
||||
CA:FALSE
|
||||
Netscape Comment:
|
||||
OpenSSL Generated Certificate
|
||||
X509v3 Subject Key Identifier:
|
||||
BA:5A:9D:D2:B0:4B:72:D6:1F:00:11:0B:B5:7B:59:DF:08:38:81:BE
|
||||
X509v3 Authority Key Identifier:
|
||||
keyid:52:C5:A4:63:B8:DB:AC:F2:92:34:2F:72:56:71:C8:11:8E:76:E6:DF
|
||||
|
||||
Signature Algorithm: sha1WithRSAEncryption
|
||||
90:8f:3b:bd:e3:a1:ca:6a:92:a6:fd:f0:64:ae:46:83:32:35:
|
||||
61:80:57:8b:30:12:70:02:e1:51:d9:87:c8:af:d9:4b:b9:6d:
|
||||
bf:ab:86:5f:19:1f:dc:af:84:67:bf:3c:bf:33:f3:7c:c6:81:
|
||||
7b:e4:e9:26:1d:bc:d6:8c:ab:72:94:7f:85:33:95:d9:24:ec:
|
||||
fd:7b:d2:fd:50:3e:e5:61:4f:75:51:ae:c6:4a:ec:df:cf:aa:
|
||||
73:a5:08:f7:f3:9a:40:66:48:f0:8e:9b:43:b1:30:f3:e3:c8:
|
||||
36:3f:68:36:6a:1c:aa:16:40:49:b4:73:9a:71:f1:17:6c:0b:
|
||||
d3:e1:a7:b7:40:de:2c:3c:36:7c:d4:dd:d6:94:c9:d7:5f:f5:
|
||||
ae:35:56:e8:cc:65:9c:bb:3d:e8:7a:ca:0e:ed:78:03:41:cb:
|
||||
fd:80:81:de:f9:de:b2:14:4b:81:24:36:de:29:c1:06:11:86:
|
||||
8c:a9:b0:0c:c7:57:cf:79:a7:3a:84:0c:27:dc:86:6d:cb:44:
|
||||
2d:26:dc:7e:fb:17:d6:b2:3d:31:03:d3:f1:ab:5d:91:5d:94:
|
||||
e4:94:88:70:96:b3:7c:0f:15:fe:c8:c6:4d:99:37:ab:09:0c:
|
||||
da:ba:b6:0e:fa:5e:bb:4b:ce:04:21:06:09:a9:2c:27:86:76:
|
||||
cc:ee:73:6f
|
||||
*/
|
||||
/*
|
||||
static char notrust_ca_data[] = "-----BEGIN CERTIFICATE-----\n"
|
||||
"MIIEqjCCA5KgAwIBAgIJAP3UMghSlH9PMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD\n"
|
||||
"VQQGEwJKUDEOMAwGA1UECAwFVG9reW8xEDAOBgNVBAcMB0tvZ2FuZWkxDTALBgNV\n"
|
||||
"BAoMBFdJREUxDzANBgNVBAsMBkFBQSBXRzEfMB0GA1UEAwwWY2hhdnJvdXguY293\n"
|
||||
"YWRkaWN0Lm9yZzEiMCAGCSqGSIb3DQEJARYTc2RlY3VnaXNAbmljdC5nby5qcDAe\n"
|
||||
"Fw0wOTEwMjgwODAzNDRaFw0xOTEwMjYwODAzNDRaMIGUMQswCQYDVQQGEwJKUDEO\n"
|
||||
"MAwGA1UECAwFVG9reW8xEDAOBgNVBAcMB0tvZ2FuZWkxDTALBgNVBAoMBFdJREUx\n"
|
||||
"DzANBgNVBAsMBkFBQSBXRzEfMB0GA1UEAwwWY2hhdnJvdXguY293YWRkaWN0Lm9y\n"
|
||||
"ZzEiMCAGCSqGSIb3DQEJARYTc2RlY3VnaXNAbmljdC5nby5qcDCCASIwDQYJKoZI\n"
|
||||
"hvcNAQEBBQADggEPADCCAQoCggEBALKW9iSUggF5mbvYe1Xk128Csfiijx+fwH5y\n"
|
||||
"ZqWrHNt0YG/tZSwyCDMWBLXTeuYsntg5y0mcpsrN8v02tvrPiCzDfRPyz3mG68us\n"
|
||||
"DPEEgQ1kqL2Gsti2DUcsdyZcDM+4rgsWRivgOTVyoNimv5f+xgmPYoElkgelLwZK\n"
|
||||
"WxGt1VCebOxP3qZA3hSHWE1hJgL4svful7RD1PbwPzidxJKITyAiJoPKWQA9cjSa\n"
|
||||
"gVzRQ7S4vmYALJn7xe+dMFRcfAK8RMv7/gJF6Rw7zufW0DIZK98KZs6aL0lmMPVk\n"
|
||||
"f31N2uvndf+cjy0n4luwEoXY+TeJZY205lbwHrzR0rH75FSm0RsCAwEAAaOB/DCB\n"
|
||||
"+TAdBgNVHQ4EFgQUUsWkY7jbrPKSNC9yVnHIEY525t8wgckGA1UdIwSBwTCBvoAU\n"
|
||||
"UsWkY7jbrPKSNC9yVnHIEY525t+hgZqkgZcwgZQxCzAJBgNVBAYTAkpQMQ4wDAYD\n"
|
||||
"VQQIDAVUb2t5bzEQMA4GA1UEBwwHS29nYW5laTENMAsGA1UECgwEV0lERTEPMA0G\n"
|
||||
"A1UECwwGQUFBIFdHMR8wHQYDVQQDDBZjaGF2cm91eC5jb3dhZGRpY3Qub3JnMSIw\n"
|
||||
"IAYJKoZIhvcNAQkBFhNzZGVjdWdpc0BuaWN0LmdvLmpwggkA/dQyCFKUf08wDAYD\n"
|
||||
"VR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEACANo6IR3OQlQaXHJaprVVDvl\n"
|
||||
"oMJC0FRbVCK503sbmWTJL98UqxRdsTZNIL07gXlK0oUKyiNijIXiLG8d5IlUrDxF\n"
|
||||
"H/Vsu6s8k3/PpAUVeiO2oygWqvU5NGvt0jg54MrOJKhYYPWrzbmHty+cAXyoNzOR\n"
|
||||
"+W5RX6HRQgxvZWQq2Ok46VX622R1nNjFmCBYT7I7/gWG+hkbIAoH6d9sULLjpC+B\n"
|
||||
"bI+L/N7ac9/Og8pGIgpUI60Gn5zO93+E+Nhg+1BlcDHGnQD6vFNs8LYp5CCX/Zj1\n"
|
||||
"tWFVXZnx58odaU3M4t9/ZQnkZdx9YJIroETbN0PoqlnSagBjgUvbWwn4YCotCA==\n"
|
||||
"-----END CERTIFICATE-----\n";
|
||||
|
||||
static char notrust_cert_data[]="-----BEGIN CERTIFICATE-----\n"
|
||||
"MIIDhjCCAm6gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBlDELMAkGA1UEBhMCSlAx\n"
|
||||
"DjAMBgNVBAgMBVRva3lvMRAwDgYDVQQHDAdLb2dhbmVpMQ0wCwYDVQQKDARXSURF\n"
|
||||
"MQ8wDQYDVQQLDAZBQUEgV0cxHzAdBgNVBAMMFmNoYXZyb3V4LmNvd2FkZGljdC5v\n"
|
||||
"cmcxIjAgBgkqhkiG9w0BCQEWE3NkZWN1Z2lzQG5pY3QuZ28uanAwHhcNMDkxMDI4\n"
|
||||
"MDgwNDQwWhcNMTAxMDI4MDgwNDQwWjB/MQswCQYDVQQGEwJKUDEOMAwGA1UECAwF\n"
|
||||
"VG9reW8xEDAOBgNVBAcMB0tvZ2FuZWkxDTALBgNVBAoMBFdJREUxDzANBgNVBAsM\n"
|
||||
"BkFBQSBXRzETMBEGA1UEAwwKdW5rbm93bi5jczEZMBcGCSqGSIb3DQEJARYKdW5r\n"
|
||||
"bm93bkBjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA5jrVihTIFdDwXAPD\n"
|
||||
"rzNRLBe3ZaxF6EgtrnD9fHk6x4DIUFPQGdg6JqgWTUwEFwnfaZtZK4nI4GC7HTeC\n"
|
||||
"0j8XOcmPXXbhD24Imo8WSuqDhvm9FRRWaId5BflfZhG9IkYmZL5XFlFmQVCs8rHK\n"
|
||||
"0DgRS0yy7iU2btO5Y3LEhIIcKycCAwEAAaN7MHkwCQYDVR0TBAIwADAsBglghkgB\n"
|
||||
"hvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYE\n"
|
||||
"FLpandKwS3LWHwARC7V7Wd8IOIG+MB8GA1UdIwQYMBaAFFLFpGO426zykjQvclZx\n"
|
||||
"yBGOdubfMA0GCSqGSIb3DQEBBQUAA4IBAQCQjzu946HKapKm/fBkrkaDMjVhgFeL\n"
|
||||
"MBJwAuFR2YfIr9lLuW2/q4ZfGR/cr4Rnvzy/M/N8xoF75OkmHbzWjKtylH+FM5XZ\n"
|
||||
"JOz9e9L9UD7lYU91Ua7GSuzfz6pzpQj385pAZkjwjptDsTDz48g2P2g2ahyqFkBJ\n"
|
||||
"tHOacfEXbAvT4ae3QN4sPDZ81N3WlMnXX/WuNVbozGWcuz3oesoO7XgDQcv9gIHe\n"
|
||||
"+d6yFEuBJDbeKcEGEYaMqbAMx1fPeac6hAwn3IZty0QtJtx++xfWsj0xA9Pxq12R\n"
|
||||
"XZTklIhwlrN8DxX+yMZNmTerCQzaurYO+l67S84EIQYJqSwnhnbM7nNv\n"
|
||||
"-----END CERTIFICATE-----\n";
|
||||
static char notrust_priv_data[]="-----BEGIN RSA PRIVATE KEY-----\n"
|
||||
"MIICXQIBAAKBgQDmOtWKFMgV0PBcA8OvM1EsF7dlrEXoSC2ucP18eTrHgMhQU9AZ\n"
|
||||
"2DomqBZNTAQXCd9pm1kricjgYLsdN4LSPxc5yY9dduEPbgiajxZK6oOG+b0VFFZo\n"
|
||||
"h3kF+V9mEb0iRiZkvlcWUWZBUKzyscrQOBFLTLLuJTZu07ljcsSEghwrJwIDAQAB\n"
|
||||
"AoGAeRec1SGVE5Rvt5XrSK0vFofq2DlCE6hTDpszWFLTDbe4pDdRDybhfw+Nm15O\n"
|
||||
"EGgK8BrbTcEMvKdkAzv9POQeLDE8JImgesHZFxN3jnkK+b762BGRDt57DzvMJsfj\n"
|
||||
"1LBle+UBnZB1CvjrINvu+tNMVPlUpjIstbpMq0D+s01+ijECQQD8MHTv/M+Uc86u\n"
|
||||
"1SFywgs+eQPQ8g0OoTLxzqo6YhW8FtwLjoRCZx2TNQS5gYBuQrixd/yE0Spfv9aS\n"
|
||||
"UtlAaOc1AkEA6bVufggHVHcgiWqS8CHzb6g/GRxQixVshOsoVLMkCSz04zlwIfXF\n"
|
||||
"c03hh5RJVv7jmuBmhHbayujMgvinw75oawJAQb9oXUDt5Wgj1FTgeYi5YbovEoRo\n"
|
||||
"fw3ruDsHCl2UCQt0ptarCJzVixFhf/ORRi3C9RGxFfdqMrhS+qb62N4AmQJBALYU\n"
|
||||
"T1BLiwJoiWXmLTJ/EP0V9Irov2uMtm5cE6DhrJqlduksz8r1gu7RZ3tMsVLg5Iy+\n"
|
||||
"dcCQJOffNa54caQUTZ8CQQDTs/70Nr6F6ktrtmtU/S7lIitpQJCu9u/SPyBYPmFZ\n"
|
||||
"9Axy6Ee66Php+eWDNP4Ln4axrapD0732wD8DcmGDVHij\n"
|
||||
"-----END RSA PRIVATE KEY-----\n";
|
||||
*/
|
||||
|
||||
/* Diffie-Hellman parameters, generated with GNUTLS certtool:
|
||||
certtool --generate-dh-params
|
||||
Generator: 06
|
||||
|
||||
Prime: ea:c3:75:0b:32:cf:d9:17:98:5c:da:d1
|
||||
e0:1d:b9:7c:be:29:60:b0:6f:68:a9:f6
|
||||
8d:75:05:59:69:04:ae:39:7c:2b:74:04
|
||||
3c:e2:da:28:8a:9b:93:aa:67:05:a7:3e
|
||||
06:3e:0d:31:63:88:55:ad:5a:bd:41:22
|
||||
b7:58:a7:45:b3:d5:03:ad:de:3c:8d:69
|
||||
42:bf:84:3d:c1:90:e7:39:6a:4b:87:01
|
||||
19:e5:f3:a4:e5:8e:e2:45:d5:0c:6b:17
|
||||
22:2b:2e:50:83:91:0c:5b:82:fc:72:27
|
||||
49:3b:9f:29:11:53:c7:90:b8:8d:87:73
|
||||
1a:7b:05:ab:cb:30:59:16:71:30:60:1b
|
||||
4c:80:15:3a:a2:d3:47:b7:4a:61:de:64
|
||||
7e:79:de:88:53:b7:7a:c6:a2:9a:bb:55
|
||||
40:2d:7a:71:c7:41:b5:29:df:d7:5c:fb
|
||||
42:e4:d8:5e:0b:99:d3:3c:93:0f:33:51
|
||||
8b:f4:60:e4:c5:b5:58:21:c0:51:c4:43
|
||||
25:7c:37:fe:5c:d3:62:6c:2a:af:a7:2a
|
||||
82:d5:d3:e2:bb:5d:ad:84:15:f6:78:d9
|
||||
d5:a8:f7:f0:48:5c:8d:e0:3d:04:ac:cf
|
||||
aa:34:3f:5d:f2:0d:3d:ee:ec:b8:d8:e8
|
||||
ad:dc:d3:40:59:a0:fd:45:62:47:63:c0
|
||||
bd:f5:df:8b
|
||||
*/
|
||||
static char dh_params_data[] = "-----BEGIN DH PARAMETERS-----\n"
|
||||
"MIIBCAKCAQEA6sN1CzLP2ReYXNrR4B25fL4pYLBvaKn2jXUFWWkErjl8K3QEPOLa\n"
|
||||
"KIqbk6pnBac+Bj4NMWOIVa1avUEit1inRbPVA63ePI1pQr+EPcGQ5zlqS4cBGeXz\n"
|
||||
"pOWO4kXVDGsXIisuUIORDFuC/HInSTufKRFTx5C4jYdzGnsFq8swWRZxMGAbTIAV\n"
|
||||
"OqLTR7dKYd5kfnneiFO3esaimrtVQC16ccdBtSnf11z7QuTYXguZ0zyTDzNRi/Rg\n"
|
||||
"5MW1WCHAUcRDJXw3/lzTYmwqr6cqgtXT4rtdrYQV9njZ1aj38EhcjeA9BKzPqjQ/\n"
|
||||
"XfINPe7suNjordzTQFmg/UViR2PAvfXfiwIBBg==\n"
|
||||
"-----END DH PARAMETERS-----\n";
|
||||
|
||||
|
||||
|
||||
int fddparse(struct fd_config * conf)
|
||||
{
|
||||
return shParse(conf);
|
||||
|
||||
#if 0
|
||||
/* sctp */
|
||||
conf->cnf_sec_data.tls_disabled = 1;
|
||||
conf->cnf_port_tls = 0; // DIAMETER_SECURE_PORT;
|
||||
conf->cnf_sctp_str = 10;
|
||||
conf->cnf_flags.no_fwd = 1;
|
||||
conf->cnf_flags.no_ip4 = 0;
|
||||
conf->cnf_flags.no_ip6 = 0;
|
||||
conf->cnf_flags.no_tcp = 1;
|
||||
conf->cnf_flags.no_sctp = 0;
|
||||
conf->cnf_flags.pr_tcp = 0;
|
||||
conf->cnf_flags.tls_alg = 0;
|
||||
|
||||
/* tcp */
|
||||
conf->cnf_sec_data.tls_disabled = 0;
|
||||
conf->cnf_port_tls = 0;
|
||||
conf->cnf_sctp_str = 10;
|
||||
conf->cnf_flags.no_fwd = 1;
|
||||
conf->cnf_flags.no_ip4 = 0;
|
||||
conf->cnf_flags.no_ip6 = 0;
|
||||
conf->cnf_flags.no_tcp = 0;
|
||||
conf->cnf_flags.no_sctp = 1;
|
||||
conf->cnf_flags.pr_tcp = 1;
|
||||
conf->cnf_flags.tls_alg = 0;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
gnutls_datum_t ca = { (uint8_t *)ca_data, sizeof(ca_data) };
|
||||
gnutls_datum_t server_cert = { (uint8_t *)server_cert_data, sizeof(server_cert_data) };
|
||||
gnutls_datum_t server_priv = { (uint8_t *)server_priv_data, sizeof(server_priv_data) };
|
||||
// gnutls_datum_t client_cert = { (uint8_t *)client_cert_data, sizeof(client_cert_data) };
|
||||
// gnutls_datum_t client_priv = { (uint8_t *)client_priv_data, sizeof(client_priv_data) };
|
||||
// gnutls_datum_t expired_cert = { (uint8_t *)expired_cert_data, sizeof(expired_cert_data) };
|
||||
// gnutls_datum_t expired_priv = { (uint8_t *)expired_priv_data, sizeof(expired_priv_data) };
|
||||
// gnutls_datum_t notrust_ca = { (uint8_t *)notrust_ca_data, sizeof(notrust_ca_data) };
|
||||
// gnutls_datum_t notrust_cert = { (uint8_t *)notrust_cert_data, sizeof(notrust_cert_data) };
|
||||
// gnutls_datum_t notrust_priv = { (uint8_t *)notrust_priv_data, sizeof(notrust_priv_data) };
|
||||
gnutls_datum_t dh_params = { (uint8_t *)dh_params_data, sizeof(dh_params_data) };
|
||||
|
||||
int ret;
|
||||
|
||||
/* Set the CA parameter in the config */
|
||||
CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( conf->cnf_sec_data.credentials,
|
||||
&ca,
|
||||
GNUTLS_X509_FMT_PEM), );
|
||||
assert( 1 == ret );
|
||||
|
||||
#ifdef GNUTLS_VERSION_300
|
||||
{
|
||||
/* We import these CA in the trust list */
|
||||
gnutls_x509_crt_t * calist;
|
||||
unsigned int cacount = 0;
|
||||
|
||||
CHECK_GNUTLS_DO( ret = gnutls_x509_crt_list_import2(&calist, &cacount, &ca, GNUTLS_X509_FMT_PEM,
|
||||
GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED), );
|
||||
CHECK( 1, cacount );
|
||||
|
||||
CHECK_GNUTLS_DO( ret = gnutls_x509_trust_list_add_cas (conf->cnf_sec_data.trustlist, calist, cacount, 0), );
|
||||
CHECK( 1, ret );
|
||||
}
|
||||
|
||||
/* Use certificate verification during the handshake */
|
||||
gnutls_certificate_set_verify_function (conf->cnf_sec_data.credentials, fd_tls_verify_credentials_2);
|
||||
|
||||
#endif /* GNUTLS_VERSION_300 */
|
||||
|
||||
|
||||
/* Set the server credentials (in config) */
|
||||
CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( conf->cnf_sec_data.credentials,
|
||||
&server_cert,
|
||||
&server_priv,
|
||||
GNUTLS_X509_FMT_PEM), );
|
||||
assert( GNUTLS_E_SUCCESS == ret );
|
||||
|
||||
/* Set the default priority */
|
||||
CHECK_GNUTLS_DO( ret = gnutls_priority_init( &conf->cnf_sec_data.prio_cache, "NORMAL"/*GNUTLS_DEFAULT_PRIORITY*/, NULL), );
|
||||
assert( GNUTLS_E_SUCCESS == ret );
|
||||
|
||||
/* Set default DH params */
|
||||
CHECK_GNUTLS_DO( ret = gnutls_dh_params_import_pkcs3( conf->cnf_sec_data.dh_cache, &dh_params, GNUTLS_X509_FMT_PEM), );
|
||||
assert( GNUTLS_E_SUCCESS == ret );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fd_sh_avp_search_avp ( struct avp * groupedavp, struct dict_object * what, struct avp ** avp )
|
||||
{
|
||||
struct avp * nextavp;
|
||||
struct avp_hdr * nextavphdr;
|
||||
struct dict_avp_data dictdata;
|
||||
|
||||
|
||||
TRACE_ENTRY("%p %p %p", groupedavp, what, avp);
|
||||
|
||||
CHECK_FCT( fd_dict_getval(what, &dictdata) );
|
||||
|
||||
// Loop only in the group AVP
|
||||
CHECK_FCT( fd_msg_browse(groupedavp, MSG_BRW_FIRST_CHILD, (void *)&nextavp, NULL) );
|
||||
CHECK_FCT( fd_msg_avp_hdr( nextavp, &nextavphdr ) );
|
||||
|
||||
while (nextavphdr) {
|
||||
|
||||
if ( (nextavphdr->avp_code == dictdata.avp_code) && (nextavphdr->avp_vendor == dictdata.avp_vendor) ) // always 0 if no Vendor flag
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Otherwise move to next AVP in the grouped AVP
|
||||
CHECK_FCT( fd_msg_browse(nextavp, MSG_BRW_NEXT, (void *)&nextavp, NULL) );
|
||||
|
||||
if(nextavp!=NULL)
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_hdr( nextavp, &nextavphdr ) );
|
||||
}
|
||||
else
|
||||
nextavphdr=NULL;
|
||||
}
|
||||
if (avp)
|
||||
*avp = nextavp;
|
||||
|
||||
if (avp && nextavp) {
|
||||
struct dictionary * dict;
|
||||
CHECK_FCT( fd_dict_getdict( what, &dict) );
|
||||
CHECK_FCT_DO( fd_msg_parse_dict( nextavp, dict, NULL ), );
|
||||
}
|
||||
|
||||
if (avp || nextavp)
|
||||
return 0;
|
||||
else
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
|
||||
EXTENSION_ENTRY("test_app", ta_entry);
|
||||
538
plat/diameter/extensions/sh_app/sh_app.h
Normal file
538
plat/diameter/extensions/sh_app/sh_app.h
Normal file
@@ -0,0 +1,538 @@
|
||||
/*********************************************************************************************************
|
||||
* Software License Agreement (BSD License) *
|
||||
* Author: Sebastien Decugis <sdecugis@freediameter.net> *
|
||||
* *
|
||||
* Copyright (c) 2013, WIDE Project and NICT *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Redistribution and use of this software in source and binary forms, with or without modification, are *
|
||||
* permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* * Redistributions of source code must retain the above *
|
||||
* copyright notice, this list of conditions and the *
|
||||
* following disclaimer. *
|
||||
* *
|
||||
* * Redistributions in binary form must reproduce the above *
|
||||
* copyright notice, this list of conditions and the *
|
||||
* following disclaimer in the documentation and/or other *
|
||||
* materials provided with the distribution. *
|
||||
* *
|
||||
* * Neither the name of the WIDE Project or NICT nor the *
|
||||
* names of its contributors may be used to endorse or *
|
||||
* promote products derived from this software without *
|
||||
* specific prior written permission of WIDE Project and *
|
||||
* NICT. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
|
||||
*********************************************************************************************************/
|
||||
|
||||
/* Header file for the app_test extension.
|
||||
*
|
||||
* This extension provides a way to send configurable messages on the network
|
||||
*
|
||||
* See the app_test.conf.sample file for the format of the configuration file.
|
||||
*/
|
||||
#ifndef __SH_APP_H__
|
||||
#define __SH_APP_H__
|
||||
|
||||
#include "extension.h"
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
#define SH_VND_ID 10415
|
||||
#define SH_APP_ID_OLD 16777217
|
||||
#define SH_APP_ID 4
|
||||
|
||||
#define HW_VND_ID 2011
|
||||
|
||||
/* Mode for the extension */
|
||||
#define MODE_SERV 0x1
|
||||
#define MODE_CLI 0x2
|
||||
#define MODE_BENCH 0x4
|
||||
|
||||
|
||||
|
||||
#ifndef TEST_APP_DEFAULT_SIGNAL
|
||||
#define TEST_APP_DEFAULT_SIGNAL SIGUSR1
|
||||
#endif /* TEST_APP_DEFAULT_SIGNAL */
|
||||
|
||||
#if 0
|
||||
/* encode avp */
|
||||
#define SEARCH_AVP_OLD_(name, vendor_id, retval) \
|
||||
__avp.avp_code = 0; \
|
||||
__avp.avp_name = name; \
|
||||
__avp.avp_vendor = vendor_id; \
|
||||
LOG_D("SEARCH_AVP_ avpName:%s avpVendorID:%d", name, SH_VND_ID); \
|
||||
CHECK_FCT_DO( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &__avp, retval, ENOENT), goto out )
|
||||
#endif
|
||||
#define SEARCH_AVP_(name, vendor_id, retval) \
|
||||
{ struct dict_avp_request tmp_avp;\
|
||||
tmp_avp.avp_code = 0; \
|
||||
tmp_avp.avp_name = name; \
|
||||
tmp_avp.avp_vendor = vendor_id; \
|
||||
LOG_D("SEARCH_AVP_ avpName:%s avpVendorID:%d", name, SH_VND_ID); \
|
||||
CHECK_FCT_DO( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &tmp_avp, retval, ENOENT), goto out ); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define EN_GRPAVP_U32(udr_search_name, vendor_id, udr, u32_val) \
|
||||
{ \
|
||||
SEARCH_AVP_(udr_search_name, vendor_id, &udr); \
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( udr, 0, &avp ), goto out ); \
|
||||
val.u32 = u32_val; \
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); \
|
||||
CHECK_FCT_DO( fd_msg_avp_add( grpavp, MSG_BRW_LAST_CHILD, avp ), goto out ); \
|
||||
}
|
||||
#define EN_GRPAVP_U32_(udr_search_name, vendor_id, udr, u32_val, grpavp) \
|
||||
{ \
|
||||
SEARCH_AVP_(udr_search_name, vendor_id, &udr); \
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( udr, 0, &avp ), goto out ); \
|
||||
val.u32 = u32_val; \
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); \
|
||||
CHECK_FCT_DO( fd_msg_avp_add( grpavp, MSG_BRW_LAST_CHILD, avp ), goto out ); \
|
||||
}
|
||||
#define EN_GRPAVP_U64(udr_search_name, vendor_id, udr, u64_val) \
|
||||
{ \
|
||||
SEARCH_AVP_(udr_search_name, vendor_id, &udr); \
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( udr, 0, &avp ), goto out ); \
|
||||
val.u64 = u64_val; \
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); \
|
||||
CHECK_FCT_DO( fd_msg_avp_add( grpavp, MSG_BRW_LAST_CHILD, avp ), goto out ); \
|
||||
}
|
||||
|
||||
#define EN_GRPAVP_U64_(udr_search_name, vendor_id, udr, u64_val, grpavp) \
|
||||
{ \
|
||||
SEARCH_AVP_(udr_search_name, vendor_id, &udr); \
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( udr, 0, &avp ), goto out ); \
|
||||
val.u64 = u64_val; \
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); \
|
||||
CHECK_FCT_DO( fd_msg_avp_add( grpavp, MSG_BRW_LAST_CHILD, avp ), goto out ); \
|
||||
}
|
||||
#define EN_GRPAVP_STR(udr_search_name, vendor_id, udr, str, grpavp) \
|
||||
{ \
|
||||
SEARCH_AVP_(udr_search_name, vendor_id, &udr); \
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( udr, 0, &avp ), goto out ); \
|
||||
val.os.data = (uint8_t*)(str); \
|
||||
val.os.len = strlen(str); \
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); \
|
||||
CHECK_FCT_DO( fd_msg_avp_add( grpavp, MSG_BRW_LAST_CHILD, avp ), goto out ); \
|
||||
}
|
||||
#define EN_GRPAVP_STR_BCD(udr_search_name, vendor_id, udr, str, str_len, grpavp) \
|
||||
{ \
|
||||
SEARCH_AVP_(udr_search_name, vendor_id, &udr); \
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( udr, 0, &avp ), goto out ); \
|
||||
val.os.data = (uint8_t*)(str); \
|
||||
memcpy(val.os.data, str, str_len);\
|
||||
val.os.len = str_len; \
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); \
|
||||
CHECK_FCT_DO( fd_msg_avp_add( grpavp, MSG_BRW_LAST_CHILD, avp ), goto out ); \
|
||||
}
|
||||
|
||||
#define EN_AVP_U32(udr, u32_val, msg_name, log_info) \
|
||||
{ \
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( udr, 0, &avp ), goto out ); \
|
||||
val.u32 = u32_val; \
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); \
|
||||
CHECK_FCT_DO( fd_msg_avp_add( msg_name, MSG_BRW_LAST_CHILD, avp ), goto out ); \
|
||||
LOG_N("%s\n", log_info); \
|
||||
}
|
||||
|
||||
#define EN_AVP_STR(udr, str, msg_name, log_info) \
|
||||
{ \
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( udr, 0, &avp ) , goto out ); \
|
||||
val.os.data = (unsigned char *)(str); \
|
||||
val.os.len = strlen(str); \
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); \
|
||||
CHECK_FCT_DO( fd_msg_avp_add( msg_name, MSG_BRW_LAST_CHILD, avp ), goto out ); \
|
||||
LOG_N("%s\n", log_info); \
|
||||
}
|
||||
|
||||
#define EN_AVP_BCDSTR(udr, str, tmplen, msg_name, log_info) \
|
||||
{ \
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( udr, 0, &avp ) , goto out ); \
|
||||
val.os.data = (unsigned char *)(str); \
|
||||
val.os.len = tmplen; \
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out ); \
|
||||
CHECK_FCT_DO( fd_msg_avp_add( msg_name, MSG_BRW_LAST_CHILD, avp ), goto out ); \
|
||||
LOG_N("%s\n", log_info); \
|
||||
}
|
||||
|
||||
/* parse avp */
|
||||
#define PARSE_GRPAVP_U32(grpavp, obj, avp, avphdr, tip, val) \
|
||||
CHECK_FCT( fd_sh_avp_search_avp ( grpavp, obj, &avp) ); \
|
||||
if(avp != NULL) \
|
||||
{ \
|
||||
CHECK_FCT( fd_msg_avp_hdr( avp, &avphdr ) ); \
|
||||
}
|
||||
// LOG_N("fj %s:%d", tip, val);
|
||||
|
||||
#define PARSE_GRPAVP_U64(grpavp, obj, avp, avphdr, tip, val) \
|
||||
CHECK_FCT( fd_sh_avp_search_avp ( grpavp, obj, &avp) ); \
|
||||
if(avp != NULL) \
|
||||
{ \
|
||||
CHECK_FCT( fd_msg_avp_hdr( avp, &avphdr ) ); \
|
||||
}
|
||||
// LOG_N("fj %s:%lu", tip, val);
|
||||
|
||||
|
||||
#define PARSE_GRPAVP_STR(grpavp, obj, avp, avphdr, tip, val) \
|
||||
CHECK_FCT( fd_sh_avp_search_avp ( grpavp, obj, &avp) ); \
|
||||
if(avp != NULL) \
|
||||
{ \
|
||||
CHECK_FCT( fd_msg_avp_hdr( avp, &avphdr ) ); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define PARSE_AVP_U32(msg, obj, avp, avphdr, tip, val) \
|
||||
CHECK_FCT( fd_msg_search_avp ( msg, obj, &avp) ); \
|
||||
if(avp != NULL) \
|
||||
{ \
|
||||
CHECK_FCT( fd_msg_avp_hdr( avp, &avphdr ) ); \
|
||||
}
|
||||
// LOG_N("fj %s:%d", tip, val);
|
||||
|
||||
#define PARSE_AVP_STR(msg, obj, avp, avphdr, tip, val) \
|
||||
CHECK_FCT( fd_msg_search_avp ( msg, obj, &avp) ); \
|
||||
if(avp != NULL) \
|
||||
{ \
|
||||
CHECK_FCT( fd_msg_avp_hdr( avp, &avphdr ) ); \
|
||||
}
|
||||
// LOG_N("fj %s:%s", tip, val);
|
||||
|
||||
|
||||
|
||||
/* udr avp */
|
||||
/*
|
||||
< Session-Id >
|
||||
[ DRMP ]
|
||||
{ Vendor-Specific-Application-Id }
|
||||
{ Auth-Session-State }
|
||||
{ Origin-Host }
|
||||
{ Origin-Realm }
|
||||
[ Destination-Host ]
|
||||
{ Destination-Realm }
|
||||
*[ Supported-Features ]
|
||||
{ User-Identity }
|
||||
[ Wildcarded-Public-Identity ]
|
||||
[ Wildcarded-IMPU ]
|
||||
[ Server-Name ]
|
||||
*[ Service-Indication ]
|
||||
*{ Data-Reference }
|
||||
*[ Identity-Set ]
|
||||
[ Requested-Domain ]
|
||||
[ Current-Location ]
|
||||
*[ DSAI-Tag ]
|
||||
[ Session-Priority ]
|
||||
[ User-Name ]
|
||||
[ Requested-Nodes ]
|
||||
[ Serving-Node-Indication ]
|
||||
[ Pre-paging-Supported ]
|
||||
[ Local-Time-Zone-Indication ]
|
||||
[ UDR-Flags ]
|
||||
[ Call-Reference-Info ]
|
||||
[ OC-Supported-Features ]
|
||||
*[ AVP ]
|
||||
*[ Proxy-Info ]
|
||||
*[ Route-Record ]
|
||||
*/
|
||||
struct sh_udr_msg{
|
||||
struct dict_object * udr_session_id ;
|
||||
struct dict_object * udr_drmp;
|
||||
|
||||
struct dict_object * udr_vendor_specific_application_id;
|
||||
struct dict_object * udr_auth_application_d;
|
||||
struct dict_object * udr_acct_application_id;
|
||||
|
||||
struct dict_object * udr_auth_session_state;
|
||||
struct dict_object * udr_origin_host;
|
||||
struct dict_object * udr_origin_realm;
|
||||
struct dict_object * udr_destination_host;
|
||||
struct dict_object * udr_destination_realm;
|
||||
|
||||
struct dict_object * udr_supported_features;
|
||||
struct dict_object * udr_vendor_id;
|
||||
struct dict_object * udr_feature_list_id;
|
||||
struct dict_object * udr_feature_list;
|
||||
|
||||
struct dict_object * udr_user_identity;
|
||||
struct dict_object * udr_public_identity;
|
||||
struct dict_object * udr_msisdn;
|
||||
|
||||
struct dict_object * udr_wildcarded_public_identity;
|
||||
struct dict_object * udr_wildcarded_impu;
|
||||
struct dict_object * udr_server_name;
|
||||
struct dict_object * udr_service_indication;
|
||||
struct dict_object * udr_data_reference;
|
||||
struct dict_object * udr_identity_set;
|
||||
struct dict_object * udr_requested_domain;
|
||||
struct dict_object * udr_current_location;
|
||||
struct dict_object * udr_dsai_tag;
|
||||
struct dict_object * udr_session_priority;
|
||||
struct dict_object * udr_user_name;
|
||||
struct dict_object * udr_requested_nodes;
|
||||
struct dict_object * udr_serving_node_indication;
|
||||
struct dict_object * udr_pre_paging_supported;
|
||||
struct dict_object * udr_local_time_zone_indication;
|
||||
struct dict_object * udr_udr_flags;
|
||||
|
||||
struct dict_object * udr_call_reference_info;
|
||||
struct dict_object * udr_call_reference_number;
|
||||
struct dict_object * udr_as_number;
|
||||
|
||||
struct dict_object * udr_oc_supported_features;
|
||||
struct dict_object * udr_oc_feature_vector;
|
||||
|
||||
struct dict_object * udr_proxy_info;
|
||||
struct dict_object * udr_route_record;
|
||||
};
|
||||
|
||||
/* uda avp */
|
||||
/*
|
||||
< Session-Id >
|
||||
[ DRMP ]
|
||||
{ Vendor-Specific-Application-Id }
|
||||
[ Result-Code ]
|
||||
[ Experimental-Result ]
|
||||
{ Auth-Session-State }
|
||||
{ Origin-Host }
|
||||
{ Origin-Realm }
|
||||
*[ Supported-Features ]
|
||||
[ Wildcarded-Public-Identity ]
|
||||
[ Wildcarded-IMPU ]
|
||||
[ User-Data ]
|
||||
[ OC-Supported-Features ]
|
||||
[ OC-OLR ]
|
||||
*[ AVP ]
|
||||
*[ Failed-AVP ]
|
||||
*[ Proxy-Info ]
|
||||
*[ Route-Record ]
|
||||
*/
|
||||
struct sh_uda_msg{
|
||||
struct dict_object * uda_session_id;
|
||||
struct dict_object * uda_drmp;
|
||||
|
||||
struct dict_object * uda_vendor_specific_application_id;
|
||||
struct dict_object * uda_vendor_id;
|
||||
struct dict_object * uda_auth_application_d;
|
||||
struct dict_object * uda_acct_application_id;
|
||||
|
||||
struct dict_object * uda_result_code;
|
||||
|
||||
struct dict_object * uda_experimental_result;
|
||||
struct dict_object * uda_experimental_result_code;
|
||||
|
||||
struct dict_object * uda_auth_session_state;
|
||||
struct dict_object * uda_origin_host;
|
||||
struct dict_object * uda_origin_realm;
|
||||
|
||||
struct dict_object * uda_supported_features;
|
||||
struct dict_object * uda_feature_list_id;
|
||||
struct dict_object * uda_feature_list;
|
||||
|
||||
struct dict_object * uda_wildcarded_public_identity;
|
||||
struct dict_object * uda_wildcarded_impu;
|
||||
struct dict_object * uda_user_data;
|
||||
struct dict_object * uda_oc_supported_features;
|
||||
struct dict_object * uda_oc_feature_vector;
|
||||
|
||||
struct dict_object * uda_oc_olr;
|
||||
struct dict_object * uda_oc_sequence_number;
|
||||
struct dict_object * uda_oc_report_type;
|
||||
struct dict_object * uda_oc_reduction_percentage;
|
||||
struct dict_object * uda_oc_validity_duration;
|
||||
|
||||
struct dict_object * uda_failed_avp;
|
||||
struct dict_object * uda_proxy_info;
|
||||
struct dict_object * uda_route_record;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
< Profile-Update-Request > ::= < Diameter Header: 307, REQ, PXY, 16777217 >
|
||||
< Session-Id >
|
||||
[ DRMP ]
|
||||
{ Vendor-Specific-Application-Id }
|
||||
{ Auth-Session-State }
|
||||
{ Origin-Host }
|
||||
{ Origin-Realm }
|
||||
[ Destination-Host ]
|
||||
{ Destination-Realm }
|
||||
*[ Supported-Features ]
|
||||
{ User-Identity }
|
||||
[ Wildcarded-Public-Identity ]
|
||||
[ Wildcarded-IMPU ]
|
||||
[ User-Name ]
|
||||
*{ Data-Reference }
|
||||
{ User-Data }
|
||||
[ OC-Supported-Features ]
|
||||
*[ AVP ]
|
||||
*[ Proxy-Info ]
|
||||
*[ Route-Record ]
|
||||
*/
|
||||
struct sh_pur_msg{
|
||||
struct dict_object * pur_session_id ;
|
||||
struct dict_object * pur_drmp;
|
||||
|
||||
struct dict_object * pur_vendor_specific_application_id;
|
||||
struct dict_object * pur_auth_application_d;
|
||||
struct dict_object * pur_acct_application_id;
|
||||
|
||||
struct dict_object * pur_auth_session_state;
|
||||
struct dict_object * pur_origin_host;
|
||||
struct dict_object * pur_origin_realm;
|
||||
struct dict_object * pur_destination_host;
|
||||
struct dict_object * pur_destination_realm;
|
||||
|
||||
struct dict_object * pur_supported_features;
|
||||
struct dict_object * pur_vendor_id;
|
||||
struct dict_object * pur_feature_list_id;
|
||||
struct dict_object * pur_feature_list;
|
||||
|
||||
struct dict_object * pur_user_identity;
|
||||
struct dict_object * pur_public_identity;
|
||||
struct dict_object * pur_msisdn;
|
||||
|
||||
struct dict_object * pur_wildcarded_public_identity;
|
||||
struct dict_object * pur_wildcarded_impu;
|
||||
struct dict_object * pur_user_name;
|
||||
struct dict_object * pur_data_reference;
|
||||
|
||||
struct dict_object * pur_user_date;
|
||||
|
||||
struct dict_object * pur_oc_supported_features;
|
||||
struct dict_object * pur_oc_feature_vector;
|
||||
|
||||
struct dict_object * pur_proxy_info;
|
||||
struct dict_object * udr_route_record;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
< Profile-Update-Answer > ::=< Diameter Header: 307, PXY, 16777217 >
|
||||
< Session-Id >
|
||||
[ DRMP ]
|
||||
{ Vendor-Specific-Application-Id }
|
||||
[ Result-Code ]
|
||||
[ Experimental-Result ]
|
||||
{ Auth-Session-State }
|
||||
{ Origin-Host }
|
||||
{ Origin-Realm }
|
||||
[ Wildcarded-Public-Identity ]
|
||||
[ Wildcarded-IMPU ]
|
||||
[ Repository-Data-ID ]
|
||||
[ Data-Reference ]
|
||||
*[ Supported-Features ]
|
||||
[ OC-Supported-Features ]
|
||||
[ OC-OLR ]
|
||||
*[ AVP ]
|
||||
*[ Failed-AVP ]
|
||||
*[ Proxy-Info ]
|
||||
*[ Route-Record ]
|
||||
*/
|
||||
struct sh_pua_msg{
|
||||
struct dict_object * pua_session_id ;
|
||||
struct dict_object * pua_drmp;
|
||||
|
||||
struct dict_object * pua_vendor_specific_application_id;
|
||||
struct dict_object * pua_vendor_id;
|
||||
struct dict_object * pua_auth_application_d;
|
||||
struct dict_object * pua_acct_application_id;
|
||||
|
||||
struct dict_object * pua_result_code;
|
||||
|
||||
struct dict_object * pua_experimental_result;
|
||||
struct dict_object * pua_experimental_result_code;
|
||||
|
||||
struct dict_object * pua_auth_session_state;
|
||||
|
||||
struct dict_object * pua_origin_host;
|
||||
struct dict_object * pua_origin_realm;
|
||||
|
||||
struct dict_object * pua_wildcarded_public_identity;
|
||||
struct dict_object * pua_wildcarded_impu;
|
||||
|
||||
struct dict_object * pua_repository_data_id;
|
||||
struct dict_object * pua_service_indication;
|
||||
struct dict_object * pua_sequence_number;
|
||||
|
||||
struct dict_object * pua_data_reference;
|
||||
|
||||
struct dict_object * pua_supported_features;
|
||||
struct dict_object * pua_feature_list_id;
|
||||
struct dict_object * pua_feature_list;
|
||||
|
||||
struct dict_object * pua_oc_supported_features;
|
||||
struct dict_object * pua_oc_feature_vector;
|
||||
|
||||
struct dict_object * pua_oc_olr;
|
||||
struct dict_object * pua_oc_sequence_number;
|
||||
struct dict_object * pua_oc_report_type;
|
||||
struct dict_object * pua_oc_reduction_percentage;
|
||||
struct dict_object * pua_oc_validity_duration;
|
||||
|
||||
struct dict_object * pua_proxy_info;
|
||||
struct dict_object * pua_route_record;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* The module configuration */
|
||||
struct ta_conf {
|
||||
uint32_t vendor_id; /* default 999999 */
|
||||
uint32_t appli_id; /* default 123456 */
|
||||
uint32_t cmd_id; /* default 234567 */
|
||||
uint32_t avp_id; /* default 345678 */
|
||||
uint32_t long_avp_id; /* default 0 */
|
||||
size_t long_avp_len; /* default 5000 */
|
||||
int mode; /* default MODE_SERV | MODE_CLI */
|
||||
char * dest_realm; /* default local realm */
|
||||
char * dest_host; /* default NULL */
|
||||
char * user_name; /* default NULL */
|
||||
int signal; /* default TEST_APP_DEFAULT_SIGNAL */
|
||||
int bench_concur; /* default 100 */
|
||||
int bench_duration; /* default 10 */
|
||||
struct ta_stats {
|
||||
unsigned long long nb_echoed; /* server */
|
||||
unsigned long long nb_sent; /* client */
|
||||
unsigned long long nb_recv; /* client */
|
||||
unsigned long long nb_errs; /* client */
|
||||
unsigned long shortest; /* fastest answer, in microseconds */
|
||||
unsigned long longest; /* slowest answer, in microseconds */
|
||||
unsigned long avg; /* average answer time, in microseconds */
|
||||
} stats;
|
||||
pthread_mutex_t stats_lock;
|
||||
};
|
||||
extern struct ta_conf * ta_conf;
|
||||
|
||||
/* Parse the configuration file */
|
||||
int ta_conf_handle(char * conffile);
|
||||
|
||||
/* Handle incoming messages (server) */
|
||||
int sh_serv_init(void);
|
||||
void sh_serv_fini(void);
|
||||
|
||||
/* Create outgoing message (client) */
|
||||
int sh_cli_init(void);
|
||||
void sh_cli_finit(void);
|
||||
|
||||
/* Benchmark flavour */
|
||||
int ta_bench_init(void);
|
||||
void ta_bench_fini(void);
|
||||
|
||||
/* Initialize dictionary definitions */
|
||||
int ta_dict_init(void);
|
||||
|
||||
|
||||
int fd_sh_avp_search_avp ( struct avp * groupedavp, struct dict_object * what, struct avp ** avp );
|
||||
|
||||
|
||||
#endif /* __SH_APP_H__ */
|
||||
344
plat/diameter/extensions/sh_app/sh_bench.c
Normal file
344
plat/diameter/extensions/sh_app/sh_bench.c
Normal file
@@ -0,0 +1,344 @@
|
||||
/*********************************************************************************************************
|
||||
* Software License Agreement (BSD License) *
|
||||
* Author: Sebastien Decugis <sdecugis@freediameter.net> *
|
||||
* *
|
||||
* Copyright (c) 2015, WIDE Project and NICT *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Redistribution and use of this software in source and binary forms, with or without modification, are *
|
||||
* permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* * Redistributions of source code must retain the above *
|
||||
* copyright notice, this list of conditions and the *
|
||||
* following disclaimer. *
|
||||
* *
|
||||
* * Redistributions in binary form must reproduce the above *
|
||||
* copyright notice, this list of conditions and the *
|
||||
* following disclaimer in the documentation and/or other *
|
||||
* materials provided with the distribution. *
|
||||
* *
|
||||
* * Neither the name of the WIDE Project or NICT nor the *
|
||||
* names of its contributors may be used to endorse or *
|
||||
* promote products derived from this software without *
|
||||
* specific prior written permission of WIDE Project and *
|
||||
* NICT. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
|
||||
*********************************************************************************************************/
|
||||
|
||||
/* Create and send a message, and receive it */
|
||||
|
||||
#include "sh_app.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef __APPLE__ /* they deprecated the semaphore there... */
|
||||
#include <semaphore.h>
|
||||
|
||||
#define my_sem_t sem_t
|
||||
#define my_sem_init sem_init
|
||||
#define my_sem_destroy sem_destroy
|
||||
#define my_sem_timedwait sem_timedwait
|
||||
#define my_sem_post sem_post
|
||||
|
||||
#else // on APPLE
|
||||
#include <sched.h>
|
||||
#include <dispatch/dispatch.h>
|
||||
|
||||
#define my_sem_t dispatch_semaphore_t
|
||||
|
||||
static int my_sem_init(my_sem_t * s, int pshared, unsigned int value ) {
|
||||
*s = dispatch_semaphore_create(value);
|
||||
if (*s == NULL)
|
||||
return ENOMEM;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int my_sem_destroy(my_sem_t *s) {
|
||||
dispatch_release(*s);
|
||||
*s = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int my_sem_timedwait(my_sem_t * s, struct timespec *ts) {
|
||||
struct timespec tsn;
|
||||
int64_t nsec;
|
||||
dispatch_time_t when;
|
||||
|
||||
CHECK_SYS( clock_gettime(CLOCK_REALTIME, &tsn) );
|
||||
|
||||
nsec = (ts->tv_sec * 1000000000) + ts->tv_nsec
|
||||
- (tsn.tv_sec * 1000000000) - tsn.tv_nsec;
|
||||
|
||||
when = dispatch_time ( DISPATCH_TIME_NOW, nsec );
|
||||
|
||||
return dispatch_semaphore_wait ( *s, when ) ? ETIMEDOUT : 0;
|
||||
}
|
||||
|
||||
static int my_sem_post(my_sem_t *s) {
|
||||
dispatch_semaphore_signal(*s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // APPLE
|
||||
|
||||
|
||||
|
||||
struct ta_mess_info {
|
||||
int32_t randval; /* a random value to store in Test-AVP */
|
||||
struct timespec ts; /* Time of sending the message */
|
||||
};
|
||||
|
||||
static my_sem_t ta_sem; /* To handle the concurrency */
|
||||
|
||||
/* Cb called when an answer is received */
|
||||
#if 0
|
||||
|
||||
static void sh_cb_udr_ans(void * data, struct msg ** msg)
|
||||
{
|
||||
|
||||
struct ta_mess_info * mi = (struct ta_mess_info *)data;
|
||||
struct timespec ts;
|
||||
struct avp * avp;
|
||||
struct avp_hdr * hdr;
|
||||
unsigned long dur;
|
||||
|
||||
CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &ts), return );
|
||||
|
||||
/* Value of Result Code */
|
||||
CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_res_code, &avp), return );
|
||||
if (avp) {
|
||||
CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return );
|
||||
}
|
||||
if (!avp || !hdr || hdr->avp_value->i32 != 2001) {
|
||||
/* error */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), );
|
||||
ta_conf->stats.nb_errs++;
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), );
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Check value of Test-AVP */
|
||||
CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_avp, &avp), return );
|
||||
if (avp) {
|
||||
CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return );
|
||||
ASSERT(hdr->avp_value->i32 == mi->randval);
|
||||
}
|
||||
|
||||
/* Compute how long it took */
|
||||
dur = ((ts.tv_sec - mi->ts.tv_sec) * 1000000) + ((ts.tv_nsec - mi->ts.tv_nsec) / 1000);
|
||||
|
||||
/* Add this value to the stats */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), );
|
||||
|
||||
if (ta_conf->stats.nb_recv) {
|
||||
/* Ponderate in the avg */
|
||||
ta_conf->stats.avg = (ta_conf->stats.avg * ta_conf->stats.nb_recv + dur) / (ta_conf->stats.nb_recv + 1);
|
||||
/* Min, max */
|
||||
if (dur < ta_conf->stats.shortest)
|
||||
ta_conf->stats.shortest = dur;
|
||||
if (dur > ta_conf->stats.longest)
|
||||
ta_conf->stats.longest = dur;
|
||||
} else {
|
||||
ta_conf->stats.shortest = dur;
|
||||
ta_conf->stats.longest = dur;
|
||||
ta_conf->stats.avg = dur;
|
||||
}
|
||||
ta_conf->stats.nb_recv++;
|
||||
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), );
|
||||
|
||||
end:
|
||||
/* Free the message */
|
||||
CHECK_FCT_DO(fd_msg_free(*msg), );
|
||||
*msg = NULL;
|
||||
|
||||
free(mi);
|
||||
|
||||
/* Post the semaphore */
|
||||
CHECK_SYS_DO( my_sem_post(&ta_sem), );
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Create a test message */
|
||||
static void ta_bench_test_message()
|
||||
{
|
||||
#if 0
|
||||
struct msg * req = NULL;
|
||||
struct avp * avp;
|
||||
union avp_value val;
|
||||
struct ta_mess_info * mi = NULL;
|
||||
|
||||
TRACE_DEBUG(FULL, "Creating a new message for sending.");
|
||||
|
||||
/* Create the request */
|
||||
CHECK_FCT_DO( fd_msg_new( ta_cmd_r, MSGFL_ALLOC_ETEID, &req ), goto out );
|
||||
|
||||
/* Create a new session */
|
||||
#define TEST_APP_SID_OPT "app_testb"
|
||||
CHECK_FCT_DO( fd_msg_new_session( req, (os0_t)TEST_APP_SID_OPT, CONSTSTRLEN(TEST_APP_SID_OPT) ), goto out );
|
||||
|
||||
/* Create the random value to store with the session */
|
||||
mi = malloc(sizeof(struct ta_mess_info));
|
||||
if (mi == NULL) {
|
||||
fd_log_debug("malloc failed: %s", strerror(errno));
|
||||
goto out;
|
||||
}
|
||||
|
||||
mi->randval = (int32_t)random();
|
||||
|
||||
/* Now set all AVPs values */
|
||||
|
||||
/* Set the Destination-Realm AVP */
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( ta_dest_realm, 0, &avp ), goto out );
|
||||
val.os.data = (unsigned char *)(ta_conf->dest_realm);
|
||||
val.os.len = strlen(ta_conf->dest_realm);
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out );
|
||||
}
|
||||
|
||||
/* Set the Destination-Host AVP if needed*/
|
||||
if (ta_conf->dest_host) {
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( ta_dest_host, 0, &avp ), goto out );
|
||||
val.os.data = (unsigned char *)(ta_conf->dest_host);
|
||||
val.os.len = strlen(ta_conf->dest_host);
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out );
|
||||
}
|
||||
|
||||
/* Set Origin-Host & Origin-Realm */
|
||||
CHECK_FCT_DO( fd_msg_add_origin ( req, 0 ), goto out );
|
||||
|
||||
/* Set the User-Name AVP if needed*/
|
||||
if (ta_conf->user_name) {
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( ta_user_name, 0, &avp ), goto out );
|
||||
val.os.data = (unsigned char *)(ta_conf->user_name);
|
||||
val.os.len = strlen(ta_conf->user_name);
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out );
|
||||
}
|
||||
|
||||
/* Set the Test-AVP AVP */
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( ta_avp, 0, &avp ), goto out );
|
||||
val.i32 = mi->randval;
|
||||
CHECK_FCT_DO( fd_msg_avp_setvalue( avp, &val ), goto out );
|
||||
CHECK_FCT_DO( fd_msg_avp_add( req, MSG_BRW_LAST_CHILD, avp ), goto out );
|
||||
}
|
||||
|
||||
CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &mi->ts), goto out );
|
||||
|
||||
/* Send the request */
|
||||
CHECK_FCT_DO( fd_msg_send( &req, sh_rec_uda, mi ), goto out );
|
||||
|
||||
/* Increment the counter */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), );
|
||||
ta_conf->stats.nb_sent++;
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), );
|
||||
|
||||
out:
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* The function called when the signal is received */
|
||||
static void ta_bench_start() {
|
||||
struct timespec end_time, now;
|
||||
struct ta_stats start, end;
|
||||
int nsec = 0;
|
||||
|
||||
/* Save the initial stats */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), );
|
||||
memcpy(&start, &ta_conf->stats, sizeof(struct ta_stats));
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), );
|
||||
|
||||
/* We will run for ta_conf->bench_duration seconds */
|
||||
LOG_N("Starting benchmark client, %ds", ta_conf->bench_duration);
|
||||
CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &end_time), );
|
||||
end_time.tv_sec += ta_conf->bench_duration;
|
||||
|
||||
/* Now loop until timeout is reached */
|
||||
do {
|
||||
/* Do not create more that NB_CONCURRENT_MESSAGES in paralel */
|
||||
int ret = my_sem_timedwait(&ta_sem, &end_time);
|
||||
if (ret == -1) {
|
||||
ret = errno;
|
||||
if (ret != ETIMEDOUT) {
|
||||
CHECK_POSIX_DO(ret, ); /* Just to log it */
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update the current time */
|
||||
CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &now), );
|
||||
|
||||
if (!TS_IS_INFERIOR(&now, &end_time))
|
||||
break;
|
||||
|
||||
/* Create and send a new test message */
|
||||
ta_bench_test_message();
|
||||
} while (1);
|
||||
|
||||
do {
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), );
|
||||
CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &now), ); /* Re-read the time because we might have spent some time wiating for the mutex */
|
||||
memcpy(&end, &ta_conf->stats, sizeof(struct ta_stats));
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), );
|
||||
|
||||
/* Now, display the statistics */
|
||||
LOG_N( "------- app_test Benchmark results, end sending +%ds ---------", nsec);
|
||||
if (now.tv_nsec >= end_time.tv_nsec) {
|
||||
LOG_N( " Executing for: %d.%06ld sec",
|
||||
(int)(now.tv_sec + ta_conf->bench_duration - end_time.tv_sec),
|
||||
(long)(now.tv_nsec - end_time.tv_nsec) / 1000);
|
||||
} else {
|
||||
LOG_N( " Executing for: %d.%06ld sec",
|
||||
(int)(now.tv_sec + ta_conf->bench_duration - 1 - end_time.tv_sec),
|
||||
(long)(now.tv_nsec + 1000000000 - end_time.tv_nsec) / 1000);
|
||||
}
|
||||
LOG_N( " %llu messages sent", end.nb_sent - start.nb_sent);
|
||||
LOG_N( " %llu error(s) received", end.nb_errs - start.nb_errs);
|
||||
LOG_N( " %llu answer(s) received", end.nb_recv - start.nb_recv);
|
||||
LOG_N( " Overall:");
|
||||
LOG_N( " fastest: %ld.%06ld sec.", end.shortest / 1000000, end.shortest % 1000000);
|
||||
LOG_N( " slowest: %ld.%06ld sec.", end.longest / 1000000, end.longest % 1000000);
|
||||
LOG_N( " Average: %ld.%06ld sec.", end.avg / 1000000, end.avg % 1000000);
|
||||
LOG_N( " Throughput: %llu messages / sec", (end.nb_recv - start.nb_recv) / (( now.tv_sec + ta_conf->bench_duration - end_time.tv_sec ) + ((now.tv_nsec - end_time.tv_nsec) / 1000000000)));
|
||||
LOG_N( "-------------------------------------");
|
||||
|
||||
nsec ++;
|
||||
sleep(1);
|
||||
} while ( (end.nb_sent - start.nb_sent) > (end.nb_errs - start.nb_errs) + (end.nb_recv - start.nb_recv) );
|
||||
LOG_N( "--------------- Test Complete --------------");
|
||||
|
||||
}
|
||||
|
||||
|
||||
int ta_bench_init(void)
|
||||
{
|
||||
CHECK_SYS( my_sem_init( &ta_sem, 0, ta_conf->bench_concur) );
|
||||
|
||||
CHECK_FCT( fd_event_trig_regcb(ta_conf->signal, "test_app.bench", ta_bench_start ) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ta_bench_fini(void)
|
||||
{
|
||||
// CHECK_FCT_DO( fd_sig_unregister(ta_conf->signal), /* continue */ );
|
||||
|
||||
CHECK_SYS_DO( my_sem_destroy(&ta_sem), );
|
||||
|
||||
return;
|
||||
};
|
||||
997
plat/diameter/extensions/sh_app/sh_cli.c
Normal file
997
plat/diameter/extensions/sh_app/sh_cli.c
Normal file
@@ -0,0 +1,997 @@
|
||||
/*********************************************************************************************************
|
||||
* Software License Agreement (BSD License) *
|
||||
* Author: Sebastien Decugis <sdecugis@freediameter.net> *
|
||||
* *
|
||||
* Copyright (c) 2013, WIDE Project and NICT *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Redistribution and use of this software in source and binary forms, with or without modification, are *
|
||||
* permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* * Redistributions of source code must retain the above *
|
||||
* copyright notice, this list of conditions and the *
|
||||
* following disclaimer. *
|
||||
* *
|
||||
* * Redistributions in binary form must reproduce the above *
|
||||
* copyright notice, this list of conditions and the *
|
||||
* following disclaimer in the documentation and/or other *
|
||||
* materials provided with the distribution. *
|
||||
* *
|
||||
* * Neither the name of the WIDE Project or NICT nor the *
|
||||
* names of its contributors may be used to endorse or *
|
||||
* promote products derived from this software without *
|
||||
* specific prior written permission of WIDE Project and *
|
||||
* NICT. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
|
||||
*********************************************************************************************************/
|
||||
|
||||
/* Create and send a message, and receive it */
|
||||
|
||||
/* Note that we use both sessions and the argument to answer callback to pass the same value.
|
||||
* This is just for the purpose of checking everything went OK.
|
||||
*/
|
||||
#include "sh_app.h"
|
||||
#include <stdio.h>
|
||||
#include "sh_conf.h"
|
||||
|
||||
// static struct disp_hdl * sh_hdl_fb = NULL; /* handler for fallback cb */
|
||||
extern struct dict_object * sh_appli;
|
||||
static struct disp_hdl * sh_hdl_uda = NULL; /* handler for PUR req cb */
|
||||
static struct disp_hdl * sh_hdl_pua = NULL; /* handler for PUR req cb */
|
||||
extern struct dict_object * uda_cmd;
|
||||
extern struct dict_object * pua_cmd;
|
||||
|
||||
|
||||
struct sess_state {
|
||||
int32_t randval; /* a random value to store in Test-AVP */
|
||||
struct timespec ts; /* Time of sending the message */
|
||||
} ;
|
||||
|
||||
|
||||
static struct session_handler * sh_cli_reg = NULL;
|
||||
|
||||
static struct sh_udr_msg g_udr_cmd;
|
||||
static struct sh_pur_msg g_pur_cmd;
|
||||
|
||||
static struct sh_uda_msg g_uda_cmd;
|
||||
static struct sh_pua_msg g_pua_cmd;
|
||||
|
||||
|
||||
//static struct dict_avp_request __avp;
|
||||
|
||||
static char * g_test_buf = NULL;
|
||||
static size_t g_test_len;
|
||||
#define FD_DUMP_TEST_PARAMS &g_test_buf, &g_test_len, NULL
|
||||
#define SH_TEST_ON 1
|
||||
|
||||
|
||||
#if 0
|
||||
static void sh_send_pur()
|
||||
{
|
||||
struct msg *pur_msg = NULL;
|
||||
struct avp *avp, *grpavp;
|
||||
union avp_value val;
|
||||
struct sess_state *mi = NULL, *svg;
|
||||
struct session *sess = NULL;
|
||||
|
||||
TRACE_DEBUG(FULL, "Creating a new message for sending.");
|
||||
|
||||
/* Create a new session */
|
||||
#define TEST_APP_SID_OPT "sh_app"
|
||||
|
||||
/* Create the message object from model */
|
||||
{
|
||||
struct dict_object * acr_model = NULL;
|
||||
|
||||
/* Now find the UDR dictionary object */
|
||||
ASSERT( 0 == fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Profile-Update-Request", &acr_model, ENOENT ) );
|
||||
|
||||
/* Create the instance, using the templates */
|
||||
ASSERT( 0 == fd_msg_new ( acr_model, MSGFL_ALLOC_ETEID, &pur_msg ) );
|
||||
|
||||
/* set application id */
|
||||
{
|
||||
struct msg_hdr * msg_hdr = NULL;
|
||||
ASSERT( 0 == fd_msg_hdr ( pur_msg, &msg_hdr ) );
|
||||
msg_hdr->msg_appl = SH_APP_ID;
|
||||
}
|
||||
|
||||
/* Check there is no child */
|
||||
ASSERT( ENOENT == fd_msg_browse ( pur_msg, MSG_BRW_FIRST_CHILD, NULL, NULL) );
|
||||
}
|
||||
|
||||
|
||||
CHECK_FCT_DO( fd_msg_new_session( pur_msg, (os0_t)TEST_APP_SID_OPT, CONSTSTRLEN(TEST_APP_SID_OPT) ), goto out );
|
||||
CHECK_FCT_DO( fd_msg_sess_get(fd_g_config->cnf_dict, pur_msg, &sess, NULL), goto out );
|
||||
|
||||
/* Create the random value to store with the session */
|
||||
mi = malloc(sizeof(struct sess_state));
|
||||
if (mi == NULL) {
|
||||
fd_log_debug("malloc failed: %s", strerror(errno));
|
||||
goto out;
|
||||
}
|
||||
|
||||
mi->randval = (int32_t)random();
|
||||
|
||||
/* Now resolve some other useful AVPs */
|
||||
/* resolve udr avps */
|
||||
SEARCH_AVP_("Session-Id", 0, &g_pur_cmd.pur_session_id);
|
||||
SEARCH_AVP_("DRMP", SH_VND_ID, &g_pur_cmd.pur_drmp);
|
||||
SEARCH_AVP_("Vendor-Specific-Application-Id", 0, &g_pur_cmd.pur_vendor_specific_application_id);
|
||||
SEARCH_AVP_("Auth-Session-State", 0, &g_pur_cmd.pur_auth_session_state);
|
||||
SEARCH_AVP_("Origin-Host", 0, &g_pur_cmd.pur_origin_host);
|
||||
SEARCH_AVP_("Origin-Realm", 0, &g_pur_cmd.pur_origin_realm);
|
||||
SEARCH_AVP_("Destination-Host", 0, &g_pur_cmd.pur_destination_host);
|
||||
SEARCH_AVP_("Destination-Realm", 0, &g_pur_cmd.pur_destination_realm);
|
||||
|
||||
SEARCH_AVP_("Supported-Features", SH_VND_ID, &g_pur_cmd.pur_supported_features);
|
||||
SEARCH_AVP_("User-Identity", SH_VND_ID, &g_pur_cmd.pur_user_identity);
|
||||
SEARCH_AVP_("Wildcarded-Public-Identity", SH_VND_ID, &g_pur_cmd.pur_wildcarded_public_identity);
|
||||
SEARCH_AVP_("Wildcarded-IMPU", SH_VND_ID, &g_pur_cmd.pur_wildcarded_impu);
|
||||
SEARCH_AVP_("User-Name", 0, &g_pur_cmd.pur_user_name);
|
||||
SEARCH_AVP_("Data-Reference", SH_VND_ID, &g_pur_cmd.pur_data_reference);
|
||||
|
||||
SEARCH_AVP_("User-Data", SH_VND_ID, &g_pur_cmd.pur_user_date);
|
||||
SEARCH_AVP_("OC-Supported-Features", SH_VND_ID, &g_pur_cmd.pur_oc_supported_features);
|
||||
|
||||
/* Now set all AVPs values */
|
||||
EN_AVP_U32(g_pur_cmd.pur_drmp, 0, pur_msg, "DRMP Ok")
|
||||
|
||||
/* Set Vendor-Specific-Application-Id AVP if needed*/
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( g_pur_cmd.pur_vendor_specific_application_id, 0, &grpavp ), goto out );
|
||||
|
||||
EN_GRPAVP_U32("Vendor-Id", 0, g_pur_cmd.pur_vendor_id, SH_VND_ID)
|
||||
EN_GRPAVP_U32("Auth-Application-Id", 0, g_pur_cmd.pur_auth_application_d, SH_APP_ID)
|
||||
EN_GRPAVP_U32("Acct-Application-Id", 0,g_pur_cmd.pur_acct_application_id, SH_APP_ID)
|
||||
|
||||
CHECK_FCT_DO( fd_msg_avp_add( pur_msg, MSG_BRW_LAST_CHILD, grpavp ), goto out );
|
||||
|
||||
LOG_D("Vendor-Specific-Application-Id Ok\n");
|
||||
}
|
||||
|
||||
EN_AVP_U32(g_pur_cmd.pur_auth_session_state, 1, pur_msg, "pur_auth_session_state Ok\n")
|
||||
|
||||
/* Set Origin-Host & Origin-Realm AVP */
|
||||
CHECK_FCT_DO( fd_msg_add_origin ( pur_msg, 0 ), goto out );
|
||||
|
||||
/* Set the Destination-Host AVP if needed*/
|
||||
if (ta_conf->dest_host) {
|
||||
EN_AVP_STR(g_pur_cmd.pur_destination_host, g_sh_conf_ext.pi_diamid_peer, pur_msg, "pur_origin_host Ok");
|
||||
}
|
||||
|
||||
/* Set the Destination-Realm AVP */
|
||||
EN_AVP_STR(g_pur_cmd.pur_destination_realm, g_sh_conf_ext.pi_diamid_realm_peer, pur_msg, "pur_origin_realm Ok");
|
||||
|
||||
/* Set the Supported-Features group AVP if needed*/
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( g_pur_cmd.pur_supported_features, 0, &grpavp ), goto out );
|
||||
|
||||
EN_GRPAVP_U32("Vendor-Id", 0, g_pur_cmd.pur_vendor_id, SH_VND_ID)
|
||||
EN_GRPAVP_U32("Feature-List-ID", SH_VND_ID,g_pur_cmd.pur_feature_list_id, 2)
|
||||
EN_GRPAVP_U32("Feature-List", SH_VND_ID,g_pur_cmd.pur_feature_list, 3)
|
||||
|
||||
CHECK_FCT_DO( fd_msg_avp_add( pur_msg, MSG_BRW_LAST_CHILD, grpavp ), goto out );
|
||||
|
||||
LOG_D("Supported-Features Ok\n");
|
||||
}
|
||||
|
||||
/* Set the User-Identity AVP if needed*/
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( g_pur_cmd.pur_user_identity, 0, &grpavp ), goto out );
|
||||
|
||||
EN_GRPAVP_STR("Public-Identity", SH_VND_ID, g_pur_cmd.pur_public_identity, "public_id", grpavp)
|
||||
EN_GRPAVP_STR("MSISDN", SH_VND_ID, g_pur_cmd.pur_msisdn, "12345", grpavp)
|
||||
|
||||
CHECK_FCT_DO( fd_msg_avp_add( pur_msg, MSG_BRW_LAST_CHILD, grpavp ), goto out );
|
||||
|
||||
LOG_D("pur_user_identity Ok\n");
|
||||
}
|
||||
|
||||
EN_AVP_STR( g_pur_cmd.pur_wildcarded_public_identity, "wildcarded_public_id", pur_msg, "wildcarded_public_id Ok")
|
||||
EN_AVP_STR( g_pur_cmd.pur_wildcarded_impu, "wildcarded_impu", pur_msg, "wildcarded_impu Ok")
|
||||
EN_AVP_STR( g_pur_cmd.pur_user_name, "User-Name", pur_msg, "user_name Ok")
|
||||
EN_AVP_U32( g_pur_cmd.pur_data_reference, 1,pur_msg, "Data-Reference Ok")
|
||||
EN_AVP_STR( g_pur_cmd.pur_user_date, "User-Data", pur_msg, "User-Data Ok")
|
||||
|
||||
/* Set the OC-Supported-Features AVP */
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( g_pur_cmd.pur_oc_supported_features, 0, &grpavp ), goto out);
|
||||
|
||||
EN_GRPAVP_U64("OC-Feature-Vector", SH_VND_ID, g_pur_cmd.pur_oc_feature_vector, 1)
|
||||
|
||||
CHECK_FCT_DO( fd_msg_avp_add( pur_msg, MSG_BRW_LAST_CHILD, grpavp ), goto out );
|
||||
|
||||
LOG_D("OC-Feature-Vector Ok\n");
|
||||
#if SH_TEST_ON
|
||||
fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, pur_msg, fd_g_config->cnf_dict, 0, 1));
|
||||
#endif
|
||||
}
|
||||
|
||||
CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &mi->ts), goto out );
|
||||
LOG_D("CLOCK_REALTIME Ok\n");
|
||||
|
||||
/* Keep a pointer to the session data for debug purpose, in real life we would not need it */
|
||||
svg = mi;
|
||||
|
||||
/* Store this value in the session */
|
||||
// CHECK_FCT_DO( fd_sess_state_store ( sh_cli_reg, sess, &mi ), goto out );
|
||||
LOG_D("sess Ok\n");
|
||||
|
||||
/* Log sending the message */
|
||||
fprintf(stderr, "SEND %x to '%s' (%s)\n", svg->randval, ta_conf->dest_realm, ta_conf->dest_host?:"-" );
|
||||
fflush(stderr);
|
||||
|
||||
// assert( 0 == fd_msg_source_set( pur_msg, "client.domain", CONSTSTRLEN("client.domain") ) );
|
||||
|
||||
/* Send the request */
|
||||
CHECK_FCT_DO( fd_msg_send( &pur_msg, NULL, svg ), goto out );
|
||||
LOG_D("fd_msg_send Ok\n");
|
||||
|
||||
/* Increment the counter */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), );
|
||||
ta_conf->stats.nb_sent++;
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), );
|
||||
|
||||
out:
|
||||
printf("end\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static void sh_send_udr()
|
||||
{
|
||||
struct msg *udr_msg = NULL;
|
||||
struct avp *avp, *grpavp;
|
||||
union avp_value val;
|
||||
struct sess_state *mi = NULL, *svg;
|
||||
struct session *sess = NULL;
|
||||
|
||||
TRACE_DEBUG(FULL, "Creating a new message for sending.");
|
||||
|
||||
/* Create a new session */
|
||||
#define TEST_APP_SID_OPT "sh_app"
|
||||
|
||||
/* Create the message object from model */
|
||||
{
|
||||
struct dict_object * acr_model = NULL;
|
||||
|
||||
/* Now find the UDR dictionary object */
|
||||
ASSERT( 0 == fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "User-Data-Request", &acr_model, ENOENT ) );
|
||||
|
||||
/* Create the instance, using the templates */
|
||||
ASSERT( 0 == fd_msg_new ( acr_model, MSGFL_ALLOC_ETEID, &udr_msg ) );
|
||||
|
||||
/* set application id */
|
||||
{
|
||||
struct msg_hdr * msg_hdr = NULL;
|
||||
ASSERT( 0 == fd_msg_hdr ( udr_msg, &msg_hdr ) );
|
||||
msg_hdr->msg_appl = SH_APP_ID;
|
||||
msg_hdr->msg_flags = msg_hdr->msg_flags & (~CMD_FLAG_PROXIABLE);
|
||||
}
|
||||
|
||||
/* Check there is no child */
|
||||
ASSERT( ENOENT == fd_msg_browse ( udr_msg, MSG_BRW_FIRST_CHILD, NULL, NULL) );
|
||||
}
|
||||
|
||||
|
||||
CHECK_FCT_DO( fd_msg_new_session( udr_msg, (os0_t)TEST_APP_SID_OPT, CONSTSTRLEN(TEST_APP_SID_OPT) ), goto out );
|
||||
CHECK_FCT_DO( fd_msg_sess_get(fd_g_config->cnf_dict, udr_msg, &sess, NULL), goto out );
|
||||
|
||||
/* Create the random value to store with the session */
|
||||
mi = malloc(sizeof(struct sess_state));
|
||||
if (mi == NULL) {
|
||||
fd_log_debug("malloc failed: %s", strerror(errno));
|
||||
goto out;
|
||||
}
|
||||
|
||||
mi->randval = (int32_t)random();
|
||||
|
||||
/* Now resolve some other useful AVPs */
|
||||
/* resolve udr avps */
|
||||
SEARCH_AVP_("Session-Id", 0, &g_udr_cmd.udr_session_id);
|
||||
SEARCH_AVP_("DRMP", SH_VND_ID, &g_udr_cmd.udr_drmp);
|
||||
SEARCH_AVP_("Vendor-Specific-Application-Id", 0, &g_udr_cmd.udr_vendor_specific_application_id);
|
||||
SEARCH_AVP_("Auth-Session-State", 0, &g_udr_cmd.udr_auth_session_state);
|
||||
SEARCH_AVP_("Origin-Host", 0, &g_udr_cmd.udr_origin_host);
|
||||
SEARCH_AVP_("Origin-Realm", 0, &g_udr_cmd.udr_origin_realm);
|
||||
SEARCH_AVP_("Destination-Host", 0, &g_udr_cmd.udr_destination_host);
|
||||
SEARCH_AVP_("Destination-Realm", 0, &g_udr_cmd.udr_destination_realm);
|
||||
|
||||
SEARCH_AVP_("Supported-Features", SH_VND_ID, &g_udr_cmd.udr_supported_features);
|
||||
SEARCH_AVP_("User-Identity", SH_VND_ID, &g_udr_cmd.udr_user_identity);
|
||||
SEARCH_AVP_("Wildcarded-Public-Identity", SH_VND_ID, &g_udr_cmd.udr_wildcarded_public_identity);
|
||||
SEARCH_AVP_("Wildcarded-IMPU", SH_VND_ID, &g_udr_cmd.udr_wildcarded_impu);
|
||||
SEARCH_AVP_("Server-Name", SH_VND_ID, &g_udr_cmd.udr_server_name);
|
||||
SEARCH_AVP_("Service-Indication", SH_VND_ID, &g_udr_cmd.udr_service_indication);
|
||||
SEARCH_AVP_("Data-Reference", SH_VND_ID, &g_udr_cmd.udr_data_reference);
|
||||
SEARCH_AVP_("Identity-Set", SH_VND_ID, &g_udr_cmd.udr_identity_set);
|
||||
SEARCH_AVP_("Requested-Domain", SH_VND_ID, &g_udr_cmd.udr_requested_domain);
|
||||
SEARCH_AVP_("Current-Location", SH_VND_ID, &g_udr_cmd.udr_current_location);
|
||||
SEARCH_AVP_("DSAI-Tag", SH_VND_ID, &g_udr_cmd.udr_dsai_tag);
|
||||
SEARCH_AVP_("Session-Priority", SH_VND_ID, &g_udr_cmd.udr_session_priority);
|
||||
SEARCH_AVP_("User-Name", 0, &g_udr_cmd.udr_user_name);
|
||||
SEARCH_AVP_("Requested-Nodes", SH_VND_ID, &g_udr_cmd.udr_requested_nodes);
|
||||
SEARCH_AVP_("Serving-Node-Indication", SH_VND_ID, &g_udr_cmd.udr_serving_node_indication);
|
||||
SEARCH_AVP_("Pre-paging-Supported", SH_VND_ID, &g_udr_cmd.udr_pre_paging_supported);
|
||||
SEARCH_AVP_("Local-Time-Zone-Indication", SH_VND_ID, &g_udr_cmd.udr_local_time_zone_indication);
|
||||
SEARCH_AVP_("UDR-Flags", SH_VND_ID, &g_udr_cmd.udr_udr_flags);
|
||||
SEARCH_AVP_("Call-Reference-Info", SH_VND_ID, &g_udr_cmd.udr_call_reference_info);
|
||||
SEARCH_AVP_("OC-Supported-Features", SH_VND_ID, &g_udr_cmd.udr_oc_supported_features);
|
||||
|
||||
/* Now set all AVPs values */
|
||||
EN_AVP_U32(g_udr_cmd.udr_drmp, 0, udr_msg, "DRMP Ok")
|
||||
|
||||
/* Set Vendor-Specific-Application-Id AVP if needed*/
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( g_udr_cmd.udr_vendor_specific_application_id, 0, &grpavp ), goto out );
|
||||
|
||||
EN_GRPAVP_U32("Vendor-Id", 0, g_udr_cmd.udr_vendor_id, SH_VND_ID)
|
||||
EN_GRPAVP_U32("Auth-Application-Id", 0, g_udr_cmd.udr_auth_application_d, SH_APP_ID)
|
||||
EN_GRPAVP_U32("Acct-Application-Id", 0,g_udr_cmd.udr_acct_application_id, SH_APP_ID)
|
||||
|
||||
CHECK_FCT_DO( fd_msg_avp_add( udr_msg, MSG_BRW_LAST_CHILD, grpavp ), goto out );
|
||||
|
||||
LOG_D("Vendor-Specific-Application-Id Ok\n");
|
||||
}
|
||||
|
||||
EN_AVP_U32(g_udr_cmd.udr_auth_session_state, 1, udr_msg, "udr_auth_session_state Ok\n")
|
||||
|
||||
/* Set Origin-Host & Origin-Realm AVP */
|
||||
CHECK_FCT_DO( fd_msg_add_origin ( udr_msg, 0 ), goto out );
|
||||
|
||||
/* Set the Destination-Host AVP if needed*/
|
||||
if (ta_conf->dest_host) {
|
||||
EN_AVP_STR(g_udr_cmd.udr_destination_host, g_sh_conf_ext.pi_diamid_peer, udr_msg, "udr_origin_host Ok");
|
||||
}
|
||||
|
||||
/* Set the Destination-Realm AVP */
|
||||
EN_AVP_STR(g_udr_cmd.udr_destination_realm, g_sh_conf_ext.pi_diamid_realm_peer, udr_msg, "udr_origin_realm Ok");
|
||||
|
||||
/* Set the Supported-Features group AVP if needed*/
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( g_udr_cmd.udr_supported_features, 0, &grpavp ), goto out );
|
||||
|
||||
EN_GRPAVP_U32("Vendor-Id", 0, g_udr_cmd.udr_vendor_id, 1)
|
||||
EN_GRPAVP_U32("Feature-List-ID", SH_VND_ID,g_udr_cmd.udr_feature_list_id, 2)
|
||||
EN_GRPAVP_U32("Feature-List", SH_VND_ID,g_udr_cmd.udr_feature_list, 3)
|
||||
|
||||
CHECK_FCT_DO( fd_msg_avp_add( udr_msg, MSG_BRW_LAST_CHILD, grpavp ), goto out );
|
||||
|
||||
LOG_D("Supported-Features Ok\n");
|
||||
}
|
||||
|
||||
/* Set the User-Identity AVP if needed*/
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( g_udr_cmd.udr_user_identity, 0, &grpavp ), goto out );
|
||||
|
||||
EN_GRPAVP_STR("Public-Identity", SH_VND_ID, g_udr_cmd.udr_public_identity, "public_id", grpavp)
|
||||
EN_GRPAVP_STR("MSISDN", SH_VND_ID, g_udr_cmd.udr_msisdn, "12345", grpavp)
|
||||
|
||||
CHECK_FCT_DO( fd_msg_avp_add( udr_msg, MSG_BRW_LAST_CHILD, grpavp ), goto out );
|
||||
|
||||
LOG_D("udr_user_identity Ok\n");
|
||||
}
|
||||
|
||||
EN_AVP_STR(g_udr_cmd.udr_wildcarded_public_identity, "Wildcarded-public-ID", udr_msg, "Wildcarded-Public-ID Ok")
|
||||
EN_AVP_STR( g_udr_cmd.udr_wildcarded_impu, "Wildcarded-IMPU", udr_msg, "Wildcarded-IMPU Ok")
|
||||
EN_AVP_STR( g_udr_cmd.udr_server_name, "Server-Name", udr_msg, "Server-Name Ok")
|
||||
EN_AVP_STR( g_udr_cmd.udr_service_indication, "Service-Indication", udr_msg, "Service-Indication Ok")
|
||||
EN_AVP_U32(g_udr_cmd.udr_data_reference, 1,udr_msg, "Data-Reference Ok")
|
||||
EN_AVP_U32(g_udr_cmd.udr_identity_set, 1,udr_msg, "Identity-Set Ok")
|
||||
|
||||
EN_AVP_U32(g_udr_cmd.udr_requested_domain, 2,udr_msg, "Req-Domain Ok")
|
||||
|
||||
EN_AVP_U32( g_udr_cmd.udr_current_location, 3, udr_msg, "Cur-Location Ok")
|
||||
EN_AVP_STR( g_udr_cmd.udr_dsai_tag, "DSAI-Tag", udr_msg, "DSAI-Tag Ok")
|
||||
|
||||
EN_AVP_U32( g_udr_cmd.udr_session_priority, 4, udr_msg, "Session-Priority Ok")
|
||||
EN_AVP_STR( g_udr_cmd.udr_user_name, "User-Name", udr_msg, "User-Name Ok")
|
||||
|
||||
/* Set User-Name AVP */
|
||||
EN_AVP_U32( g_udr_cmd.udr_requested_nodes, 5, udr_msg, "Requested-Nodes Ok")
|
||||
EN_AVP_U32( g_udr_cmd.udr_serving_node_indication, 6, udr_msg, "Serving-Node-Indication Ok")
|
||||
EN_AVP_U32( g_udr_cmd.udr_pre_paging_supported, 7, udr_msg, "Pre-paging-Supported Ok")
|
||||
EN_AVP_U32( g_udr_cmd.udr_local_time_zone_indication, 8, udr_msg, "Local-Time-Zone-Indication Ok")
|
||||
|
||||
EN_AVP_U32( g_udr_cmd.udr_udr_flags, 9, udr_msg, "UDR-Flags Ok")
|
||||
|
||||
/* Set the Call-Reference-Info AVP */
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( g_udr_cmd.udr_call_reference_info, 0, &grpavp ), goto out );
|
||||
|
||||
EN_GRPAVP_STR("Call-Reference-Number", SH_VND_ID, g_udr_cmd.udr_call_reference_number, "Call-Reference-Number", grpavp)
|
||||
EN_GRPAVP_STR("AS-Number", SH_VND_ID, g_udr_cmd.udr_as_number, "AS-Number", grpavp)
|
||||
|
||||
CHECK_FCT_DO( fd_msg_avp_add( udr_msg, MSG_BRW_LAST_CHILD, grpavp ), goto out );
|
||||
|
||||
LOG_D("Call-Reference-Info Ok\n");
|
||||
}
|
||||
|
||||
/* Set the OC-Supported-Features AVP */
|
||||
{
|
||||
CHECK_FCT_DO( fd_msg_avp_new ( g_udr_cmd.udr_oc_supported_features, 0, &grpavp ), goto out);
|
||||
|
||||
EN_GRPAVP_U64("OC-Feature-Vector", SH_VND_ID, g_udr_cmd.udr_oc_feature_vector, 1)
|
||||
|
||||
CHECK_FCT_DO( fd_msg_avp_add( udr_msg, MSG_BRW_LAST_CHILD, grpavp ), goto out );
|
||||
|
||||
LOG_D("OC-Feature-Vector Ok\n");
|
||||
#if SH_TEST_ON
|
||||
fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, udr_msg, fd_g_config->cnf_dict, 0, 1));
|
||||
#endif
|
||||
}
|
||||
|
||||
CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &mi->ts), goto out );
|
||||
LOG_D("CLOCK_REALTIME Ok\n");
|
||||
|
||||
/* Keep a pointer to the session data for debug purpose, in real life we would not need it */
|
||||
svg = mi;
|
||||
|
||||
/* Store this value in the session */
|
||||
CHECK_FCT_DO( fd_sess_state_store ( sh_cli_reg, sess, &mi ), goto out );
|
||||
LOG_D("sess Ok\n");
|
||||
|
||||
/* Log sending the message */
|
||||
fprintf(stderr, "SEND %x to '%s' (%s)\n", svg->randval, ta_conf->dest_realm, ta_conf->dest_host?:"-" );
|
||||
fflush(stderr);
|
||||
|
||||
/* Send the request */
|
||||
CHECK_FCT_DO( fd_msg_send( &udr_msg, NULL, svg ), goto out );
|
||||
LOG_D("fd_msg_send Ok\n");
|
||||
|
||||
/* Increment the counter */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), );
|
||||
ta_conf->stats.nb_sent++;
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), );
|
||||
|
||||
out:
|
||||
printf("end\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
static int sh_parse_pua( struct msg ** msg)
|
||||
{
|
||||
struct msg* pua_msg = *msg;
|
||||
struct avp *avp, *grpavp=NULL;
|
||||
struct avp_hdr *avphdr;
|
||||
|
||||
LOG_D("fj sh_parse_pua");
|
||||
|
||||
SEARCH_AVP_("Session-Id", 0, &g_pua_cmd.pua_session_id);
|
||||
SEARCH_AVP_("DRMP", SH_VND_ID, &g_pua_cmd.pua_drmp);
|
||||
|
||||
SEARCH_AVP_("Vendor-Specific-Application-Id", 0, &g_pua_cmd.pua_vendor_specific_application_id);
|
||||
SEARCH_AVP_("Vendor-Id", 0, &g_pua_cmd.pua_vendor_id);
|
||||
SEARCH_AVP_("Auth-Application-Id", 0, &g_pua_cmd.pua_auth_application_d);
|
||||
SEARCH_AVP_("Acct-Application-Id", 0, &g_pua_cmd.pua_acct_application_id);
|
||||
|
||||
|
||||
SEARCH_AVP_("Result-Code", 0, &g_pua_cmd.pua_result_code);
|
||||
|
||||
SEARCH_AVP_("Experimental-Result", 0, &g_pua_cmd.pua_experimental_result);
|
||||
SEARCH_AVP_("Experimental-Result-Code", 0, &g_pua_cmd.pua_experimental_result_code);
|
||||
|
||||
SEARCH_AVP_("Auth-Session-State", 0, &g_pua_cmd.pua_auth_session_state);
|
||||
SEARCH_AVP_("Origin-Host", 0, &g_pua_cmd.pua_origin_host);
|
||||
SEARCH_AVP_("Origin-Realm", 0, &g_pua_cmd.pua_origin_realm);
|
||||
|
||||
|
||||
SEARCH_AVP_("Wildcarded-Public-Identity", SH_VND_ID, &g_pua_cmd.pua_wildcarded_public_identity );
|
||||
SEARCH_AVP_("Wildcarded-IMPU", SH_VND_ID, &g_pua_cmd.pua_wildcarded_impu );
|
||||
|
||||
SEARCH_AVP_("Repository-Data-ID", SH_VND_ID, &g_pua_cmd.pua_repository_data_id );
|
||||
SEARCH_AVP_("Service-Indication", SH_VND_ID, &g_pua_cmd.pua_service_indication);
|
||||
SEARCH_AVP_("Sequence-Number", SH_VND_ID, &g_pua_cmd.pua_sequence_number);
|
||||
|
||||
SEARCH_AVP_("Data-Reference", SH_VND_ID, &g_pua_cmd.pua_data_reference);
|
||||
|
||||
SEARCH_AVP_("Supported-Features", SH_VND_ID, &g_pua_cmd.pua_supported_features );
|
||||
SEARCH_AVP_("Feature-List-ID", SH_VND_ID, &g_pua_cmd.pua_feature_list_id);
|
||||
SEARCH_AVP_("Feature-List", SH_VND_ID, &g_pua_cmd.pua_feature_list);
|
||||
|
||||
SEARCH_AVP_("OC-Supported-Features", SH_VND_ID, &g_pua_cmd.pua_oc_supported_features );
|
||||
SEARCH_AVP_("OC-Feature-Vector", SH_VND_ID, &g_pua_cmd.pua_oc_feature_vector);
|
||||
|
||||
SEARCH_AVP_("OC-OLR", SH_VND_ID, &g_pua_cmd.pua_oc_olr );
|
||||
SEARCH_AVP_("OC-Sequence-Number", SH_VND_ID, &g_pua_cmd.pua_oc_sequence_number);
|
||||
SEARCH_AVP_("OC-Report-Type", SH_VND_ID, &g_pua_cmd.pua_oc_report_type);
|
||||
SEARCH_AVP_("OC-Reduction-Percentage", SH_VND_ID, &g_pua_cmd.pua_oc_reduction_percentage);
|
||||
SEARCH_AVP_("OC-Validity-Duration", SH_VND_ID, &g_pua_cmd.pua_oc_validity_duration);
|
||||
|
||||
/* Session-Id */
|
||||
PARSE_AVP_STR(pua_msg, g_pua_cmd.pua_session_id, avp, avphdr, "ession-Id", avphdr->avp_value->os.data)
|
||||
|
||||
/* DRMP */
|
||||
PARSE_AVP_U32(pua_msg, g_pua_cmd.pua_drmp, avp, avphdr, "DRMP", avphdr->avp_value->u32)
|
||||
|
||||
/* Vendor-Specific-Application-Id */
|
||||
CHECK_FCT( fd_msg_search_avp ( pua_msg, g_pua_cmd.pua_vendor_specific_application_id, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj Vendor-Specific-Application-Id");
|
||||
|
||||
/* Vendor-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pua_cmd.pua_vendor_id, avp, avphdr, "Vendor-Id", avphdr->avp_value->u32)
|
||||
|
||||
/* Auth-Application-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pua_cmd.pua_auth_application_d, avp, avphdr, "Auth-Application-Id", avphdr->avp_value->u32)
|
||||
|
||||
/* Acct-Application-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pua_cmd.pua_acct_application_id, avp, avphdr, "Acct-Application-Id", avphdr->avp_value->u32)
|
||||
}
|
||||
|
||||
/* Result-Code */
|
||||
PARSE_AVP_U32(pua_msg, g_pua_cmd.pua_result_code, avp, avphdr, "Result-Code", avphdr->avp_value->u32)
|
||||
|
||||
/* Experimental-Result */
|
||||
CHECK_FCT( fd_msg_search_avp ( pua_msg, g_pua_cmd.pua_experimental_result, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj Experimental-Result");
|
||||
|
||||
/* Vendor-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pua_cmd.pua_vendor_id, avp, avphdr, "Vendor-Id", avphdr->avp_value->u32)
|
||||
|
||||
/* Experimental-Result-Code */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pua_cmd.pua_experimental_result_code, avp, avphdr, "Experimental-Result-Code", avphdr->avp_value->u32)
|
||||
}
|
||||
|
||||
/* Auth-Session-State */
|
||||
PARSE_AVP_U32(pua_msg, g_pua_cmd.pua_auth_session_state, avp, avphdr, "Auth-Session-State", avphdr->avp_value->u32)
|
||||
|
||||
|
||||
/* Origin-Host */
|
||||
PARSE_AVP_STR(pua_msg, g_pua_cmd.pua_origin_host, avp, avphdr, "Origin-Host", avphdr->avp_value->os.data)
|
||||
|
||||
/* Origin-Realm */
|
||||
PARSE_AVP_STR(pua_msg, g_pua_cmd.pua_origin_realm, avp, avphdr, "Origin-Realm", avphdr->avp_value->os.data)
|
||||
|
||||
|
||||
/* Wildcarded-Public-Identity */
|
||||
PARSE_AVP_STR(pua_msg, g_pua_cmd.pua_wildcarded_public_identity, avp, avphdr, "Wildcarded-Public-Identity", avphdr->avp_value->os.data)
|
||||
|
||||
/* Wildcarded-IMPU */
|
||||
PARSE_AVP_STR(pua_msg, g_pua_cmd.pua_wildcarded_impu, avp, avphdr, "Wildcarded-IMPU", avphdr->avp_value->os.data)
|
||||
|
||||
/* Repository-Data-ID */
|
||||
CHECK_FCT( fd_msg_search_avp ( pua_msg, g_pua_cmd.pua_repository_data_id, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj Repository-Data-ID");
|
||||
|
||||
/* Service-Indication */
|
||||
PARSE_GRPAVP_STR(grpavp, g_pua_cmd.pua_service_indication, avp, avphdr, "Service-Indication", avphdr->avp_value->os.data)
|
||||
|
||||
/* Sequence-Number */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pua_cmd.pua_sequence_number, avp, avphdr, "Sequence-Number", avphdr->avp_value->u32)
|
||||
}
|
||||
|
||||
/* Data-Reference */
|
||||
PARSE_AVP_U32(pua_msg, g_pua_cmd.pua_data_reference, avp, avphdr, "Data-Reference", avphdr->avp_value->u32)
|
||||
|
||||
/* Supported-Features */
|
||||
CHECK_FCT( fd_msg_search_avp ( pua_msg, g_pua_cmd.pua_supported_features, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj Supported-Features");
|
||||
|
||||
/* Vendor-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pua_cmd.pua_vendor_id, avp, avphdr, "Vendor-Id", avphdr->avp_value->u32)
|
||||
|
||||
/* Feature-List-ID */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pua_cmd.pua_feature_list_id, avp, avphdr, "Feature-List-ID", avphdr->avp_value->u32)
|
||||
|
||||
/* Feature-List */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pua_cmd.pua_feature_list, avp, avphdr, "Feature-List", avphdr->avp_value->u32)
|
||||
}
|
||||
|
||||
/* OC-Supported-Features */
|
||||
CHECK_FCT( fd_msg_search_avp ( pua_msg, g_pua_cmd.pua_oc_supported_features, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj OC-Supported-Features");
|
||||
|
||||
/* OC-Feature-Vector */
|
||||
PARSE_GRPAVP_U64(grpavp, g_pua_cmd.pua_oc_feature_vector, avp, avphdr, "OC-Feature-Vector", avphdr->avp_value->u64)
|
||||
}
|
||||
|
||||
/* OC-OLR */
|
||||
CHECK_FCT( fd_msg_search_avp ( pua_msg, g_pua_cmd.pua_oc_olr, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj OC-OLR");
|
||||
|
||||
/* OC-Sequence-Number */
|
||||
PARSE_GRPAVP_U64(grpavp, g_pua_cmd.pua_oc_feature_vector, avp, avphdr, "OC-Sequence-Number", avphdr->avp_value->u64)
|
||||
|
||||
/* OC-Report-Type */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pua_cmd.pua_oc_report_type, avp, avphdr, "OC-Report-Type", avphdr->avp_value->u32)
|
||||
|
||||
/* OC-Reduction-Percentage */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pua_cmd.pua_oc_reduction_percentage, avp, avphdr, "OC-Reduction-Percentage", avphdr->avp_value->u32)
|
||||
|
||||
/* OC-Validity-Duration */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pua_cmd.pua_oc_validity_duration, avp, avphdr, "OC-Validity-Duration", avphdr->avp_value->u32)
|
||||
|
||||
}
|
||||
|
||||
out:
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static int sh_parse_uda(struct msg** msg)
|
||||
{
|
||||
struct msg* udr_msg = *msg;
|
||||
struct avp *avp, *grpavp=NULL;
|
||||
struct avp_hdr *avphdr;
|
||||
|
||||
LOG_D("fj sh_parse_uda");
|
||||
|
||||
SEARCH_AVP_("Origin-Host", 0, &g_uda_cmd.uda_origin_host);
|
||||
SEARCH_AVP_("Session-Id", 0, &g_uda_cmd.uda_session_id);
|
||||
SEARCH_AVP_("DRMP", SH_VND_ID, &g_uda_cmd.uda_drmp);
|
||||
SEARCH_AVP_("Vendor-Specific-Application-Id", 0, &g_uda_cmd.uda_vendor_specific_application_id);
|
||||
SEARCH_AVP_("Vendor-Id", 0, &g_uda_cmd.uda_vendor_id);
|
||||
SEARCH_AVP_("Auth-Application-Id", 0, &g_uda_cmd.uda_auth_application_d);
|
||||
SEARCH_AVP_("Acct-Application-Id", 0, &g_uda_cmd.uda_acct_application_id);
|
||||
|
||||
|
||||
SEARCH_AVP_("Result-Code", 0, &g_uda_cmd.uda_result_code);
|
||||
|
||||
SEARCH_AVP_("Experimental-Result", 0, &g_uda_cmd.uda_experimental_result);
|
||||
SEARCH_AVP_("Experimental-Result-Code", 0, &g_uda_cmd.uda_experimental_result_code);
|
||||
|
||||
SEARCH_AVP_("Auth-Session-State", 0, &g_uda_cmd.uda_auth_session_state);
|
||||
|
||||
SEARCH_AVP_("Origin-Realm", 0, &g_uda_cmd.uda_origin_realm);
|
||||
|
||||
SEARCH_AVP_("Supported-Features", SH_VND_ID, &g_uda_cmd.uda_supported_features );
|
||||
SEARCH_AVP_("Feature-List-ID", SH_VND_ID, &g_uda_cmd.uda_feature_list_id);
|
||||
SEARCH_AVP_("Feature-List", SH_VND_ID, &g_uda_cmd.uda_feature_list);
|
||||
|
||||
|
||||
SEARCH_AVP_("Wildcarded-Public-Identity", SH_VND_ID, &g_uda_cmd.uda_wildcarded_public_identity );
|
||||
SEARCH_AVP_("Wildcarded-IMPU", SH_VND_ID, &g_uda_cmd.uda_wildcarded_impu );
|
||||
SEARCH_AVP_("User-Data", SH_VND_ID, &g_uda_cmd.uda_user_data );
|
||||
|
||||
SEARCH_AVP_("OC-Supported-Features", SH_VND_ID, &g_uda_cmd.uda_oc_supported_features );
|
||||
// SEARCH_AVP_("OC-Feature-Vector", SH_VND_ID, &g_uda_cmd.uda_oc_feature_vector);
|
||||
|
||||
SEARCH_AVP_("OC-OLR", SH_VND_ID, &g_uda_cmd.uda_oc_olr );
|
||||
SEARCH_AVP_("OC-Sequence-Number", SH_VND_ID, &g_uda_cmd.uda_oc_sequence_number);
|
||||
SEARCH_AVP_("OC-Report-Type", SH_VND_ID, &g_uda_cmd.uda_oc_report_type);
|
||||
SEARCH_AVP_("OC-Reduction-Percentage", SH_VND_ID, &g_uda_cmd.uda_oc_reduction_percentage);
|
||||
SEARCH_AVP_("OC-Validity-Duration", SH_VND_ID, &g_uda_cmd.uda_oc_validity_duration);
|
||||
|
||||
/* Session-Id */
|
||||
PARSE_AVP_STR(udr_msg, g_uda_cmd.uda_session_id, avp, avphdr, "Session-Id", avphdr->avp_value->os.data)
|
||||
|
||||
/* DRMP */
|
||||
PARSE_AVP_U32(udr_msg, g_uda_cmd.uda_drmp, avp, avphdr, "DRMP", avphdr->avp_value->u32)
|
||||
|
||||
/* Vendor-Specific-Application-Id */
|
||||
CHECK_FCT( fd_msg_search_avp ( udr_msg, g_uda_cmd.uda_vendor_specific_application_id, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj Vendor-Specific-Application-Id");
|
||||
|
||||
/* Vendor-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_uda_cmd.uda_vendor_id, avp, avphdr, "Vendor-Id", avphdr->avp_value->u32)
|
||||
|
||||
/* Auth-Application-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_uda_cmd.uda_auth_application_d, avp, avphdr, "Auth-Application-Id", avphdr->avp_value->u32)
|
||||
|
||||
/* Acct-Application-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_uda_cmd.uda_acct_application_id, avp, avphdr, "Acct-Application-Id", avphdr->avp_value->u32)
|
||||
}
|
||||
|
||||
/* Result-Code */
|
||||
PARSE_AVP_U32(udr_msg, g_uda_cmd.uda_result_code, avp, avphdr, "Result-Code", avphdr->avp_value->u32)
|
||||
|
||||
/* Experimental-Result */
|
||||
CHECK_FCT( fd_msg_search_avp ( udr_msg, g_uda_cmd.uda_experimental_result, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj Experimental-Result");
|
||||
|
||||
/* Vendor-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_uda_cmd.uda_vendor_id, avp, avphdr, "Vendor-Id", avphdr->avp_value->u32)
|
||||
|
||||
/* Experimental-Result-Code */
|
||||
PARSE_GRPAVP_U32(grpavp, g_uda_cmd.uda_experimental_result_code, avp, avphdr, "Experimental-Result-Code", avphdr->avp_value->u32)
|
||||
}
|
||||
|
||||
/* Auth-Session-State */
|
||||
PARSE_AVP_U32(udr_msg, g_uda_cmd.uda_auth_session_state, avp, avphdr, "Auth-Session-State", avphdr->avp_value->u32)
|
||||
|
||||
|
||||
/* Origin-Host */
|
||||
PARSE_AVP_STR(udr_msg, g_uda_cmd.uda_origin_host, avp, avphdr, "Origin-Host", avphdr->avp_value->os.data)
|
||||
|
||||
/* Origin-Realm */
|
||||
PARSE_AVP_STR(udr_msg, g_uda_cmd.uda_origin_realm, avp, avphdr, "Origin-Realm", avphdr->avp_value->os.data)
|
||||
|
||||
/* Supported-Features */
|
||||
CHECK_FCT( fd_msg_search_avp ( udr_msg, g_uda_cmd.uda_supported_features, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj Supported-Features");
|
||||
|
||||
/* Vendor-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_uda_cmd.uda_vendor_id, avp, avphdr, "Vendor-Id", avphdr->avp_value->u32)
|
||||
|
||||
/* Feature-List-ID */
|
||||
PARSE_GRPAVP_U32(grpavp, g_uda_cmd.uda_feature_list_id, avp, avphdr, "Feature-List-ID", avphdr->avp_value->u32)
|
||||
|
||||
/* Feature-List */
|
||||
PARSE_GRPAVP_U32(grpavp, g_uda_cmd.uda_feature_list, avp, avphdr, "Feature-List", avphdr->avp_value->u32)
|
||||
}
|
||||
|
||||
/* Wildcarded-Public-Identity */
|
||||
PARSE_AVP_STR(udr_msg, g_uda_cmd.uda_wildcarded_public_identity, avp, avphdr, "Wildcarded-Public-Identity", avphdr->avp_value->os.data)
|
||||
|
||||
/* Wildcarded-IMPU */
|
||||
PARSE_AVP_STR(udr_msg, g_uda_cmd.uda_wildcarded_impu, avp, avphdr, "Wildcarded-IMPU", avphdr->avp_value->os.data)
|
||||
|
||||
/* User-Data */
|
||||
PARSE_AVP_STR(udr_msg, g_uda_cmd.uda_user_data, avp, avphdr, "User-Data", avphdr->avp_value->os.data)
|
||||
|
||||
|
||||
/* OC-Supported-Features */
|
||||
CHECK_FCT( fd_msg_search_avp ( udr_msg, g_uda_cmd.uda_oc_supported_features, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj OC-Supported-Features");
|
||||
|
||||
/* OC-Feature-Vector */
|
||||
// PARSE_GRPAVP_U32(grpavp, g_uda_cmd.uda_oc_feature_vector, avp, avphdr, "OC-Feature-Vector", avphdr->avp_value->u64)
|
||||
}
|
||||
|
||||
/* OC-OLR */
|
||||
CHECK_FCT( fd_msg_search_avp ( udr_msg, g_uda_cmd.uda_oc_olr, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj OC-OLR");
|
||||
|
||||
/* OC-Sequence-Number */
|
||||
PARSE_GRPAVP_U64(grpavp, g_uda_cmd.uda_oc_sequence_number, avp, avphdr, "OC-Sequence-Number", avphdr->avp_value->u64)
|
||||
|
||||
/* OC-Report-Type */
|
||||
PARSE_GRPAVP_U32(grpavp, g_uda_cmd.uda_oc_report_type, avp, avphdr, "OC-Report-Type", avphdr->avp_value->u32)
|
||||
|
||||
/* OC-Reduction-Percentage */
|
||||
PARSE_GRPAVP_U32(grpavp, g_uda_cmd.uda_oc_reduction_percentage, avp, avphdr, "OC-Reduction-Percentage", avphdr->avp_value->u32)
|
||||
|
||||
/* OC-Validity-Duration */
|
||||
PARSE_GRPAVP_U32(grpavp, g_uda_cmd.uda_oc_validity_duration, avp, avphdr, "OC-Validity-Duration", avphdr->avp_value->u32)
|
||||
}
|
||||
out:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Cb called when an answer is received */
|
||||
static int sh_rec_pua( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act)
|
||||
{
|
||||
LOG_D("fj sh_rec_pua in");
|
||||
|
||||
fprintf(stderr, "ECHO PUA received from 'server.domain', done...\n");
|
||||
|
||||
sh_parse_pua(msg);
|
||||
|
||||
/* Free the message */
|
||||
CHECK_FCT_DO(fd_msg_free(*msg), return 0);
|
||||
*msg = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sh_rec_uda( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act)
|
||||
{
|
||||
LOG_D("fj sh_rec_uda in\n");
|
||||
|
||||
fprintf(stderr, "ECHO UDA received from 'server.domain', replying...\n");
|
||||
|
||||
sh_parse_uda(msg);
|
||||
|
||||
// sh_send_pur();
|
||||
|
||||
/* Free the message */
|
||||
CHECK_FCT_DO(fd_msg_free(*msg), return 0);
|
||||
*msg = NULL;
|
||||
|
||||
return 0;
|
||||
#if 0
|
||||
struct sess_state * mi = NULL;
|
||||
struct timespec ts;
|
||||
struct session * sess;
|
||||
struct avp * avp;
|
||||
struct avp_hdr * hdr;
|
||||
unsigned long dur;
|
||||
int error = 0;
|
||||
|
||||
CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &ts), return );
|
||||
|
||||
/* Search the session, retrieve its data */
|
||||
{
|
||||
int new;
|
||||
CHECK_FCT_DO( fd_msg_sess_get(fd_g_config->cnf_dict, *msg, &sess, &new), return );
|
||||
ASSERT( new == 0 );
|
||||
|
||||
CHECK_FCT_DO( fd_sess_state_retrieve( sh_cli_reg, sess, &mi ), return );
|
||||
ASSERT( (void *)mi == data );
|
||||
}
|
||||
|
||||
/* Now log content of the answer */
|
||||
fprintf(stderr, "RECV ");
|
||||
|
||||
/* Value of Test-AVP */
|
||||
CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_avp, &avp), return );
|
||||
if (avp) {
|
||||
CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return );
|
||||
if (hdr->avp_value->i32 == mi->randval) {
|
||||
fprintf(stderr, "%x (%s) ", hdr->avp_value->i32, "Ok");
|
||||
} else {
|
||||
fprintf(stderr, "%x (%s) ", hdr->avp_value->i32, "PROBLEM");
|
||||
error++;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "no_Test-AVP ");
|
||||
error++;
|
||||
}
|
||||
|
||||
/* Value of Result Code */
|
||||
CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_res_code, &avp), return );
|
||||
if (avp) {
|
||||
CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return );
|
||||
fprintf(stderr, "Status: %d ", hdr->avp_value->i32);
|
||||
if (hdr->avp_value->i32 != 2001)
|
||||
error++;
|
||||
} else {
|
||||
fprintf(stderr, "no_Result-Code ");
|
||||
error++;
|
||||
}
|
||||
|
||||
/* Value of Origin-Host */
|
||||
CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_origin_host, &avp), return );
|
||||
if (avp) {
|
||||
CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return );
|
||||
fprintf(stderr, "From '%.*s' ", (int)hdr->avp_value->os.len, hdr->avp_value->os.data);
|
||||
} else {
|
||||
fprintf(stderr, "no_Origin-Host ");
|
||||
error++;
|
||||
}
|
||||
|
||||
/* Value of Origin-Realm */
|
||||
CHECK_FCT_DO( fd_msg_search_avp ( *msg, ta_origin_realm, &avp), return );
|
||||
if (avp) {
|
||||
CHECK_FCT_DO( fd_msg_avp_hdr( avp, &hdr ), return );
|
||||
fprintf(stderr, "('%.*s') ", (int)hdr->avp_value->os.len, hdr->avp_value->os.data);
|
||||
} else {
|
||||
fprintf(stderr, "no_Origin-Realm ");
|
||||
error++;
|
||||
}
|
||||
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), );
|
||||
dur = ((ts.tv_sec - mi->ts.tv_sec) * 1000000) + ((ts.tv_nsec - mi->ts.tv_nsec) / 1000);
|
||||
if (ta_conf->stats.nb_recv) {
|
||||
/* Ponderate in the avg */
|
||||
ta_conf->stats.avg = (ta_conf->stats.avg * ta_conf->stats.nb_recv + dur) / (ta_conf->stats.nb_recv + 1);
|
||||
/* Min, max */
|
||||
if (dur < ta_conf->stats.shortest)
|
||||
ta_conf->stats.shortest = dur;
|
||||
if (dur > ta_conf->stats.longest)
|
||||
ta_conf->stats.longest = dur;
|
||||
} else {
|
||||
ta_conf->stats.shortest = dur;
|
||||
ta_conf->stats.longest = dur;
|
||||
ta_conf->stats.avg = dur;
|
||||
}
|
||||
|
||||
if (error)
|
||||
ta_conf->stats.nb_errs++;
|
||||
else
|
||||
ta_conf->stats.nb_recv++;
|
||||
|
||||
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), );
|
||||
|
||||
/* Display how long it took */
|
||||
if (ts.tv_nsec > mi->ts.tv_nsec) {
|
||||
fprintf(stderr, "in %d.%06ld sec",
|
||||
(int)(ts.tv_sec - mi->ts.tv_sec),
|
||||
(long)(ts.tv_nsec - mi->ts.tv_nsec) / 1000);
|
||||
} else {
|
||||
fprintf(stderr, "in %d.%06ld sec",
|
||||
(int)(ts.tv_sec + 1 - mi->ts.tv_sec),
|
||||
(long)(1000000000 + ts.tv_nsec - mi->ts.tv_nsec) / 1000);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
|
||||
/* Free the message */
|
||||
CHECK_FCT_DO(fd_msg_free(*msg), return);
|
||||
*msg = NULL;
|
||||
|
||||
free(mi);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static void sh_send_entry()
|
||||
{
|
||||
static int i = 0;
|
||||
|
||||
if((++i)%2)
|
||||
sh_send_udr();
|
||||
else
|
||||
sh_send_pur();
|
||||
}
|
||||
#endif
|
||||
/* Default callback for the application. */
|
||||
#if 0
|
||||
static int ta_fb_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act)
|
||||
{
|
||||
/* This CB should never be called */
|
||||
TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act);
|
||||
|
||||
fd_log_debug("Unexpected message received!");
|
||||
|
||||
return ENOTSUP;
|
||||
}
|
||||
#endif
|
||||
|
||||
int sh_cli_init(void)
|
||||
{
|
||||
CHECK_FCT( fd_sess_handler_create(&sh_cli_reg, (void *)free, NULL, NULL) );
|
||||
|
||||
/* fj added */
|
||||
{
|
||||
struct disp_when data;
|
||||
|
||||
LOG_D("Initializing dispatch callbacks for test");
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.app = sh_appli;
|
||||
data.command = uda_cmd;
|
||||
|
||||
/* Now specific handler for UDR */
|
||||
CHECK_FCT( fd_disp_register( sh_rec_uda, DISP_HOW_CC, &data, NULL, &sh_hdl_uda ) );
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.app = sh_appli;
|
||||
data.command = pua_cmd;
|
||||
/* Now specific handler for PUR */
|
||||
CHECK_FCT( fd_disp_register( sh_rec_pua, DISP_HOW_CC, &data, NULL, &sh_hdl_pua ) );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sh_cli_finit(void)
|
||||
{
|
||||
CHECK_FCT_DO( fd_sess_handler_destroy(&sh_cli_reg, NULL), /* continue */ );
|
||||
|
||||
/* fj added */
|
||||
if (sh_hdl_uda) {
|
||||
(void) fd_disp_unregister(&sh_hdl_uda, NULL);
|
||||
}
|
||||
|
||||
if (sh_hdl_pua) {
|
||||
(void) fd_disp_unregister(&sh_hdl_pua, NULL);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
371
plat/diameter/extensions/sh_app/sh_conf.c
Normal file
371
plat/diameter/extensions/sh_app/sh_conf.c
Normal file
@@ -0,0 +1,371 @@
|
||||
#include "sh_conf.h"
|
||||
|
||||
Ro_LinkSet rolkset={0,0};
|
||||
|
||||
int GetRoDiamIdPeer(DiamId_t **realm, DiamId_t **host, int bSms)
|
||||
{
|
||||
struct peer_hdr*peer = NULL;
|
||||
SH_CONF_S *pcfg = NULL;
|
||||
int i;
|
||||
int ret = -1;
|
||||
int peer_state = -1;
|
||||
if (bSms)
|
||||
{
|
||||
int curlk = rolkset.cursmslk;
|
||||
for (i=0; i<rolkset.smslknum; i++)
|
||||
{
|
||||
curlk = (curlk + i +1) % rolkset.smslknum;
|
||||
pcfg = &rolkset.smslk[curlk].cfg;
|
||||
if (pcfg->pi_diamid_peer != NULL)
|
||||
{
|
||||
ret = fd_peer_getbyid(pcfg->pi_diamid_peer, strlen(pcfg->pi_diamid_peer), 0, &peer);
|
||||
if( !ret && peer )
|
||||
{
|
||||
peer_state = fd_peer_get_state(peer);
|
||||
if( STATE_OPEN == peer_state )
|
||||
{
|
||||
if (rolkset.smslk[curlk].bconn == 0)
|
||||
{
|
||||
printf("diam peer disconn to conn, host[%s]\r\n", pcfg->pi_diamid_peer);
|
||||
rolkset.smslk[curlk].bconn = 1;
|
||||
}
|
||||
*realm = pcfg->pi_diamid_realm_peer;
|
||||
*host = pcfg->pi_diamid_peer;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rolkset.smslk[curlk].bconn == 1)
|
||||
{
|
||||
printf("diam peer conn to discon, host[%s]\r\n", pcfg->pi_diamid_peer);
|
||||
rolkset.smslk[curlk].bconn = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("diam peer NA, host[%s], ret[%d], peer[%p]\r\n", pcfg->pi_diamid_peer, ret, peer);
|
||||
rolkset.smslk[curlk].bconn = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int curlk = rolkset.curvoicelk;
|
||||
for (i=0; i<rolkset.voicelknum; i++)
|
||||
{
|
||||
curlk = (curlk + i +1) % rolkset.voicelknum;
|
||||
pcfg = &rolkset.voicelk[curlk].cfg;
|
||||
if (pcfg->pi_diamid_peer != NULL)
|
||||
{
|
||||
ret = fd_peer_getbyid(pcfg->pi_diamid_peer, strlen(pcfg->pi_diamid_peer), 0, &peer);
|
||||
if( !ret && peer )
|
||||
{
|
||||
peer_state = fd_peer_get_state(peer);
|
||||
if( STATE_OPEN == peer_state )
|
||||
{
|
||||
if (rolkset.voicelk[curlk].bconn == 0)
|
||||
{
|
||||
printf("diam peer disconn to conn, host[%s]\r\n", pcfg->pi_diamid_peer);
|
||||
rolkset.voicelk[curlk].bconn = 1;
|
||||
}
|
||||
*realm = pcfg->pi_diamid_realm_peer;
|
||||
*host = pcfg->pi_diamid_peer;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rolkset.voicelk[curlk].bconn == 1)
|
||||
{
|
||||
printf("diam peer conn to discon, host[%s]\r\n", pcfg->pi_diamid_peer);
|
||||
rolkset.voicelk[curlk].bconn = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("diam peer NA, host[%s], ret[%d], peer[%p]\r\n", pcfg->pi_diamid_peer, ret, peer);
|
||||
rolkset.voicelk[curlk].bconn = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AddRoLink(SH_CONF_S *cfg, uint16_t port, int bSms)
|
||||
{
|
||||
if (bSms)
|
||||
{
|
||||
if(rolkset.smslknum >= MaxRoLinkNum)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
rolkset.smslk[rolkset.smslknum].cfg.pi_diamid_peer = strdup(cfg->pi_diamid_peer);
|
||||
rolkset.smslk[rolkset.smslknum].cfg.pi_diamid_realm_peer = strdup(cfg->pi_diamid_realm_peer);
|
||||
rolkset.smslk[rolkset.smslknum].cfg.peer_port = port;
|
||||
rolkset.smslknum++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(rolkset.voicelknum >= MaxRoLinkNum)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
rolkset.voicelk[rolkset.voicelknum].cfg.pi_diamid_peer = strdup(cfg->pi_diamid_peer);
|
||||
rolkset.voicelk[rolkset.voicelknum].cfg.pi_diamid_realm_peer = strdup(cfg->pi_diamid_realm_peer);
|
||||
rolkset.voicelk[rolkset.voicelknum].cfg.peer_port = port;
|
||||
rolkset.voicelknum++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
SH_CONF_S g_sh_conf_ext;
|
||||
//SH_CONF_S g_rovoice_conf_ext;
|
||||
//SH_CONF_S g_rosms_conf_ext;
|
||||
|
||||
#define SH_PARSE_BUFFER_LEN 1024
|
||||
|
||||
static char* shParseStr_(char* buffer, char* _key, char *ret_str, int flag_from_begin)
|
||||
{
|
||||
char *pos = strstr(buffer, _key);
|
||||
char *pos_1 = NULL;
|
||||
char *pos_2 = NULL;
|
||||
if(NULL != pos && (flag_from_begin ? (buffer == pos) : 1) )
|
||||
{
|
||||
pos_1 = strstr(pos, "\"");
|
||||
if(NULL != pos_1)
|
||||
{
|
||||
pos_2 = strstr(pos_1 + 1, "\"");
|
||||
if(NULL != pos_2)
|
||||
{
|
||||
memcpy(ret_str, pos_1 + 1, pos_2 - pos_1 - 1);
|
||||
ret_str[pos_2 - pos_1] = '\0';
|
||||
// fprintf(stderr, "%s=%s\n", _key, ret_str);
|
||||
return ret_str;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char* shParseStr(char* buffer, char* _key, char *ret_str)
|
||||
{
|
||||
return shParseStr_(buffer, _key, ret_str, 1);
|
||||
}
|
||||
static char* shParseStrSub(char* buffer, char* _key, char *ret_str)
|
||||
{
|
||||
return shParseStr_(buffer, _key, ret_str, 0);
|
||||
}
|
||||
|
||||
uint16_t shParseInt(char* buffer, char* _key, uint16_t* ret_int)
|
||||
{
|
||||
char buff_num[16] = {0};
|
||||
|
||||
char *pos = strstr(buffer, _key);
|
||||
char *pos_1 = NULL;
|
||||
char *pos_2 = NULL;
|
||||
/* first address is start of the line */
|
||||
if(NULL != pos && buffer == pos)
|
||||
{
|
||||
pos_1 = strstr(pos, "=");
|
||||
if(NULL != pos_1)
|
||||
{
|
||||
pos_2 = strstr(pos_1 + 1, ";");
|
||||
if(NULL != pos_2)
|
||||
{
|
||||
memcpy(buff_num, pos_1 + 1, pos_2 - pos_1 - 1);
|
||||
*ret_int = atol( buff_num );
|
||||
// fprintf(stderr, "%s=%d\n", _key, *ret_int);
|
||||
return *ret_int;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int shParseFlags(char* buffer, char* _key, char* no_flag_key)
|
||||
{
|
||||
char *pos = strstr(buffer, _key);
|
||||
char *pos_1 = NULL;
|
||||
char *pos_2 = NULL;
|
||||
/* first address is start of the line */
|
||||
if(NULL != pos && buffer == pos)
|
||||
{
|
||||
pos_1 = strstr(pos, "{");
|
||||
if(NULL != pos_1)
|
||||
{
|
||||
pos_2 = strstr(pos_1 + 1, "}");
|
||||
if(NULL != pos_2)
|
||||
{
|
||||
if(strstr( pos_1 + 1, no_flag_key) )
|
||||
{
|
||||
// fprintf(stderr, "%s\n", no_flag_key);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int shParse_(struct fd_config * conf)
|
||||
{
|
||||
FILE* fd;
|
||||
char buffer[SH_PARSE_BUFFER_LEN] = {0};
|
||||
char ret_str[512] = {0};
|
||||
|
||||
/* Create input file descriptor */
|
||||
fd = fopen (conf->cnf_file, "r");
|
||||
if (fd == NULL)
|
||||
{
|
||||
perror ("open");
|
||||
return 2;
|
||||
}
|
||||
|
||||
conf->ro_voiceport = 29100;
|
||||
conf->ro_smsport = 19500;
|
||||
strcpy(conf->service_context_voice, "agrandtech_ro@3gpp.org");
|
||||
strcpy(conf->service_context_sms, "agrandtech_sms@3gpp.org");
|
||||
/* Copy process */
|
||||
while((fgets(buffer, SH_PARSE_BUFFER_LEN, fd)) != NULL)
|
||||
{
|
||||
if( shParseStr(buffer, "Identity", ret_str) )
|
||||
{
|
||||
conf->cnf_diamid = strdup(ret_str);
|
||||
conf->cnf_diamid_len = strlen(ret_str);
|
||||
|
||||
memset( ret_str, 0, strlen(ret_str) );
|
||||
}
|
||||
if( shParseStr(buffer, "Realm", ret_str) )
|
||||
{
|
||||
conf->cnf_diamrlm = strdup(ret_str);
|
||||
conf->cnf_diamrlm_len = strlen(ret_str);
|
||||
|
||||
memset( ret_str, 0, strlen(ret_str) );
|
||||
}
|
||||
if( shParseStr(buffer, "ServiceCxtRoVoice", ret_str) )
|
||||
{
|
||||
strcpy(conf->service_context_voice, ret_str);
|
||||
memset( ret_str, 0, strlen(ret_str) );
|
||||
}
|
||||
if( shParseStr(buffer, "ServiceCxtRoSms", ret_str) )
|
||||
{
|
||||
strcpy(conf->service_context_sms, ret_str);
|
||||
memset( ret_str, 0, strlen(ret_str) );
|
||||
}
|
||||
shParseInt(buffer, "RoVoicePort", &conf->ro_voiceport);
|
||||
shParseInt(buffer, "RoSmsPort", &conf->ro_smsport);
|
||||
shParseInt(buffer, "Port", &conf->cnf_port);
|
||||
shParseInt(buffer, "SecPort", &conf->cnf_port_tls);
|
||||
shParseInt(buffer, "SCTPStr", &conf->cnf_sctp_str);
|
||||
|
||||
if( shParseFlags(buffer, "ConnectPeer", "No_TLS") )
|
||||
{
|
||||
conf->cnf_sec_data.tls_disabled = 1;
|
||||
}
|
||||
if( shParseFlags(buffer, "ConnectPeer", "No_FWD") )
|
||||
{
|
||||
conf->cnf_flags.no_fwd = 1;
|
||||
}
|
||||
if( shParseFlags(buffer, "ConnectPeer", "No_IP4") )
|
||||
{
|
||||
conf->cnf_flags.no_ip4 = 1;
|
||||
}
|
||||
if( shParseFlags(buffer, "ConnectPeer", "No_IP6") )
|
||||
{
|
||||
conf->cnf_flags.no_ip6 = 1;
|
||||
}
|
||||
if( shParseFlags(buffer, "ConnectPeer", "No_TCP") )
|
||||
{
|
||||
conf->cnf_flags.no_tcp = 1;
|
||||
}
|
||||
if( shParseFlags(buffer, "ConnectPeer", "No_SCTP") )
|
||||
{
|
||||
conf->cnf_flags.no_sctp = 1;
|
||||
}
|
||||
if( shParseFlags(buffer, "ConnectPeer", "Prefer_TCP") )
|
||||
{
|
||||
conf->cnf_flags.pr_tcp = 1;
|
||||
}
|
||||
|
||||
memset(buffer, 0, SH_PARSE_BUFFER_LEN);
|
||||
}
|
||||
|
||||
fclose (fd);
|
||||
|
||||
conf->cnf_flags.tls_alg = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int shParseExt(struct fd_config * conf)
|
||||
{
|
||||
FILE* fd;
|
||||
char buffer[SH_PARSE_BUFFER_LEN] = {0};
|
||||
char ret_str[512] = {0};
|
||||
|
||||
fd = fopen (conf->cnf_file, "r");
|
||||
if(NULL == fd)
|
||||
{
|
||||
perror ("open");
|
||||
return 2;
|
||||
}
|
||||
|
||||
while((fgets(buffer, SH_PARSE_BUFFER_LEN, fd)) != NULL)
|
||||
{
|
||||
shParseInt( buffer, "ServiceMod", (uint16_t*)(&g_sh_conf_ext.mode) );
|
||||
|
||||
if( shParseStr(buffer, "ConnectPeer", ret_str) )
|
||||
{
|
||||
g_sh_conf_ext.pi_diamid_peer = strdup(ret_str);
|
||||
memset( ret_str, 0, strlen(ret_str) );
|
||||
|
||||
if( shParseStrSub(buffer, "Realm", ret_str) )
|
||||
{
|
||||
g_sh_conf_ext.pi_diamid_realm_peer = strdup(ret_str);
|
||||
memset( ret_str, 0, strlen(ret_str) );
|
||||
}
|
||||
g_sh_conf_ext.peer_port = fd_g_config->cnf_port;
|
||||
if( shParseFlags(buffer, "ConnectPeer", "Ro_SMS") )
|
||||
{
|
||||
//g_rosms_conf_ext.pi_diamid_peer = strdup(g_sh_conf_ext.pi_diamid_peer);
|
||||
//g_rosms_conf_ext.pi_diamid_realm_peer = strdup(g_sh_conf_ext.pi_diamid_realm_peer);
|
||||
//g_rosms_conf_ext.peer_port = fd_g_config->ro_smsport;
|
||||
AddRoLink(&g_sh_conf_ext, fd_g_config->ro_smsport, 1);
|
||||
free(g_sh_conf_ext.pi_diamid_peer);
|
||||
g_sh_conf_ext.pi_diamid_peer = NULL;
|
||||
free(g_sh_conf_ext.pi_diamid_realm_peer);
|
||||
g_sh_conf_ext.pi_diamid_realm_peer = NULL;
|
||||
}
|
||||
if( shParseFlags(buffer, "ConnectPeer", "Ro_VOICE") )
|
||||
{
|
||||
//g_rovoice_conf_ext.pi_diamid_peer = strdup(g_sh_conf_ext.pi_diamid_peer);
|
||||
//g_rovoice_conf_ext.pi_diamid_realm_peer = strdup(g_sh_conf_ext.pi_diamid_realm_peer);
|
||||
//g_rovoice_conf_ext.peer_port = fd_g_config->ro_voiceport;
|
||||
AddRoLink(&g_sh_conf_ext, fd_g_config->ro_voiceport, 0);
|
||||
free(g_sh_conf_ext.pi_diamid_peer);
|
||||
g_sh_conf_ext.pi_diamid_peer = NULL;
|
||||
free(g_sh_conf_ext.pi_diamid_realm_peer);
|
||||
g_sh_conf_ext.pi_diamid_realm_peer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
shParseInt( buffer, "LogLevel", (uint16_t*)(&fd_g_debug_lvl) );
|
||||
|
||||
memset(buffer, 0, SH_PARSE_BUFFER_LEN);
|
||||
}
|
||||
|
||||
fclose (fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int shParse(struct fd_config * conf)
|
||||
{
|
||||
return shParse_(conf) || shParseExt(conf);
|
||||
}
|
||||
48
plat/diameter/extensions/sh_app/sh_conf.h
Normal file
48
plat/diameter/extensions/sh_app/sh_conf.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef __SH_CONF_H__
|
||||
#define __SH_CONF_H__
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include "sh_app.h"
|
||||
|
||||
typedef struct _SH_CONF_S
|
||||
{
|
||||
int mode;
|
||||
DiamId_t pi_diamid_peer;
|
||||
DiamId_t pi_diamid_realm_peer;
|
||||
uint16_t peer_port;
|
||||
}SH_CONF_S;
|
||||
|
||||
extern SH_CONF_S g_sh_conf_ext;
|
||||
|
||||
// Ro link from scp to ocs===============================
|
||||
typedef struct _Ro_Link_S
|
||||
{
|
||||
int bconn;
|
||||
SH_CONF_S cfg;
|
||||
}Ro_Link_S;
|
||||
|
||||
#define MaxRoLinkNum 4
|
||||
typedef struct _Ro_LinkSet
|
||||
{
|
||||
int smslknum;
|
||||
int voicelknum;
|
||||
int cursmslk;
|
||||
int curvoicelk;
|
||||
|
||||
Ro_Link_S smslk[MaxRoLinkNum];
|
||||
Ro_Link_S voicelk[MaxRoLinkNum];
|
||||
}Ro_LinkSet;
|
||||
extern Ro_LinkSet rolkset;
|
||||
//
|
||||
|
||||
//extern SH_CONF_S g_rosms_conf_ext;
|
||||
//extern SH_CONF_S g_rovoice_conf_ext;
|
||||
|
||||
int shParse(struct fd_config * conf);
|
||||
|
||||
|
||||
#endif /* __SH_CONF_H__ */
|
||||
4723
plat/diameter/extensions/sh_app/sh_dict.c
Normal file
4723
plat/diameter/extensions/sh_app/sh_dict.c
Normal file
File diff suppressed because it is too large
Load Diff
753
plat/diameter/extensions/sh_app/sh_serv.c
Normal file
753
plat/diameter/extensions/sh_app/sh_serv.c
Normal file
@@ -0,0 +1,753 @@
|
||||
/*********************************************************************************************************
|
||||
* Software License Agreement (BSD License) *
|
||||
* Author: Sebastien Decugis <sdecugis@freediameter.net> *
|
||||
* *
|
||||
* Copyright (c) 2013, WIDE Project and NICT *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Redistribution and use of this software in source and binary forms, with or without modification, are *
|
||||
* permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* * Redistributions of source code must retain the above *
|
||||
* copyright notice, this list of conditions and the *
|
||||
* following disclaimer. *
|
||||
* *
|
||||
* * Redistributions in binary form must reproduce the above *
|
||||
* copyright notice, this list of conditions and the *
|
||||
* following disclaimer in the documentation and/or other *
|
||||
* materials provided with the distribution. *
|
||||
* *
|
||||
* * Neither the name of the WIDE Project or NICT nor the *
|
||||
* names of its contributors may be used to endorse or *
|
||||
* promote products derived from this software without *
|
||||
* specific prior written permission of WIDE Project and *
|
||||
* NICT. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
|
||||
*********************************************************************************************************/
|
||||
|
||||
/* Install the dispatch callbacks */
|
||||
|
||||
#include "sh_app.h"
|
||||
|
||||
static struct disp_hdl * sh_hdl_fb = NULL; /* handler for fallback cb */
|
||||
static struct disp_hdl * sh_hdl_udr = NULL; /* handler for PUR req cb */
|
||||
static struct disp_hdl * sh_hdl_pur = NULL; /* handler for PUR req cb */
|
||||
|
||||
static struct sh_udr_msg g_udr_cmd;
|
||||
static struct sh_pur_msg g_pur_cmd;
|
||||
|
||||
|
||||
static struct sh_uda_msg g_uda_cmd;
|
||||
static struct sh_pua_msg g_pua_cmd;
|
||||
//static struct dict_avp_request __avp;
|
||||
|
||||
|
||||
|
||||
/* Default callback for the application. */
|
||||
#if 0
|
||||
static int ta_fb_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act)
|
||||
{
|
||||
/* This CB should never be called */
|
||||
TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act);
|
||||
|
||||
fd_log_debug("Unexpected message received!");
|
||||
|
||||
return ENOTSUP;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int sh_parse_pur(struct msg** msg)
|
||||
{
|
||||
struct msg* udr_msg = *msg;
|
||||
struct avp *avp, *grpavp=NULL;
|
||||
struct avp_hdr *avphdr;
|
||||
|
||||
LOG_D("fj sh_parse_pur");
|
||||
|
||||
SEARCH_AVP_("Session-Id", 0, &g_pur_cmd.pur_session_id);
|
||||
SEARCH_AVP_("DRMP", SH_VND_ID, &g_pur_cmd.pur_drmp);
|
||||
|
||||
SEARCH_AVP_("Vendor-Specific-Application-Id", 0, &g_pur_cmd.pur_vendor_specific_application_id);
|
||||
SEARCH_AVP_("Vendor-Id", 0, &g_pur_cmd.pur_vendor_id);
|
||||
SEARCH_AVP_("Auth-Application-Id", 0, &g_pur_cmd.pur_auth_application_d);
|
||||
SEARCH_AVP_("Acct-Application-Id", 0, &g_pur_cmd.pur_acct_application_id);
|
||||
|
||||
SEARCH_AVP_("Auth-Session-State", 0, &g_pur_cmd.pur_auth_session_state);
|
||||
SEARCH_AVP_("Origin-Host", 0, &g_pur_cmd.pur_origin_host);
|
||||
SEARCH_AVP_("Origin-Realm", 0, &g_pur_cmd.pur_origin_realm);
|
||||
SEARCH_AVP_("Destination-Host", 0, &g_pur_cmd.pur_destination_host);
|
||||
SEARCH_AVP_("Destination-Realm", 0, &g_pur_cmd.pur_destination_realm);
|
||||
|
||||
SEARCH_AVP_("Supported-Features", SH_VND_ID, &g_pur_cmd.pur_supported_features);
|
||||
SEARCH_AVP_("Feature-List-ID", SH_VND_ID, &g_pur_cmd.pur_feature_list_id);
|
||||
SEARCH_AVP_("Feature-List", SH_VND_ID, &g_pur_cmd.pur_feature_list);
|
||||
|
||||
|
||||
SEARCH_AVP_("User-Identity", SH_VND_ID, &g_pur_cmd.pur_user_identity);
|
||||
SEARCH_AVP_("Public-Identity", SH_VND_ID, &g_pur_cmd.pur_public_identity);
|
||||
SEARCH_AVP_("MSISDN", SH_VND_ID, &g_pur_cmd.pur_msisdn);
|
||||
|
||||
|
||||
SEARCH_AVP_("Wildcarded-Public-Identity", SH_VND_ID, &g_pur_cmd.pur_wildcarded_public_identity);
|
||||
SEARCH_AVP_("Wildcarded-IMPU", SH_VND_ID, &g_pur_cmd.pur_wildcarded_impu);
|
||||
SEARCH_AVP_("User-Name", 0, &g_pur_cmd.pur_user_name);
|
||||
SEARCH_AVP_("Data-Reference", SH_VND_ID, &g_pur_cmd.pur_data_reference);
|
||||
|
||||
SEARCH_AVP_("User-Data", SH_VND_ID, &g_pur_cmd.pur_user_date);
|
||||
|
||||
SEARCH_AVP_("OC-Supported-Features", SH_VND_ID, &g_pur_cmd.pur_oc_supported_features);
|
||||
SEARCH_AVP_("OC-Feature-Vector", SH_VND_ID, &g_pur_cmd.pur_oc_feature_vector);
|
||||
|
||||
/* Session-Id */
|
||||
PARSE_AVP_STR(udr_msg, g_pur_cmd.pur_session_id, avp, avphdr, "Session-Id", avphdr->avp_value->os.data)
|
||||
|
||||
/* DRMP */
|
||||
PARSE_AVP_U32(udr_msg, g_pur_cmd.pur_drmp, avp, avphdr, "DRMP", avphdr->avp_value->u32)
|
||||
|
||||
/* Vendor-Specific-Application-Id */
|
||||
CHECK_FCT( fd_msg_search_avp ( udr_msg, g_pur_cmd.pur_vendor_specific_application_id, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj Vendor-Specific-Application-Id");
|
||||
|
||||
/* Vendor-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pur_cmd.pur_vendor_id, avp, avphdr, "Vendor-Id", avphdr->avp_value->u32)
|
||||
|
||||
/* Auth-Application-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pur_cmd.pur_auth_application_d, avp, avphdr, "Auth-Application-Id", avphdr->avp_value->u32)
|
||||
|
||||
/* Acct-Application-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pur_cmd.pur_acct_application_id, avp, avphdr, "Acct-Application-Id", avphdr->avp_value->u32)
|
||||
}
|
||||
|
||||
/* Auth-Session-State */
|
||||
PARSE_AVP_U32(udr_msg, g_pur_cmd.pur_auth_session_state, avp, avphdr, "Auth-Session-State", avphdr->avp_value->i32)
|
||||
|
||||
/* Origin-Host */
|
||||
PARSE_AVP_STR(udr_msg, g_pur_cmd.pur_origin_host, avp, avphdr, "Origin-Host", avphdr->avp_value->os.data)
|
||||
|
||||
/* Origin-Realm */
|
||||
PARSE_AVP_STR(udr_msg, g_pur_cmd.pur_origin_realm, avp, avphdr, "Origin-Realm", avphdr->avp_value->os.data)
|
||||
|
||||
/* Destination-Host */
|
||||
PARSE_AVP_STR(udr_msg, g_pur_cmd.pur_destination_host, avp, avphdr, "Dest-Host", avphdr->avp_value->os.data)
|
||||
|
||||
/* Destination-Realm */
|
||||
PARSE_AVP_STR(udr_msg, g_pur_cmd.pur_destination_realm, avp, avphdr, "Dest-Realm", avphdr->avp_value->os.data)
|
||||
|
||||
/* Supported-Features */
|
||||
CHECK_FCT( fd_msg_search_avp ( udr_msg, g_pur_cmd.pur_supported_features, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj Supported-Features ");
|
||||
|
||||
/* Vendor-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pur_cmd.pur_vendor_id, avp, avphdr, "Vendor-Id", avphdr->avp_value->u32)
|
||||
|
||||
/* Feature-List-ID */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pur_cmd.pur_feature_list_id, avp, avphdr, "Feature-List-ID", avphdr->avp_value->u32)
|
||||
|
||||
/* Feature-List */
|
||||
PARSE_GRPAVP_U32(grpavp, g_pur_cmd.pur_feature_list, avp, avphdr, "Feature-List", avphdr->avp_value->u32)
|
||||
}
|
||||
|
||||
/* User-Identity */
|
||||
CHECK_FCT( fd_msg_search_avp ( udr_msg, g_pur_cmd.pur_user_identity, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj User-Identity");
|
||||
|
||||
/* Public-Identity */
|
||||
PARSE_GRPAVP_STR(grpavp, g_pur_cmd.pur_public_identity, avp, avphdr, "Public-Identity", avphdr->avp_value->os.data)
|
||||
|
||||
/* MSISDN */
|
||||
PARSE_GRPAVP_STR(grpavp, g_pur_cmd.pur_msisdn, avp, avphdr, "MSISDN", avphdr->avp_value->os.data)
|
||||
}
|
||||
|
||||
/* wildcarded_public_id */
|
||||
PARSE_AVP_STR(udr_msg, g_pur_cmd.pur_wildcarded_public_identity, avp, avphdr, "Wild-Pub-ID", avphdr->avp_value->os.data)
|
||||
|
||||
/* wildcarded_impu */
|
||||
PARSE_AVP_STR(udr_msg, g_pur_cmd.pur_wildcarded_impu, avp, avphdr, "Wild-Pub-IMPU", avphdr->avp_value->os.data)
|
||||
|
||||
/* User-Name */
|
||||
PARSE_AVP_STR(udr_msg, g_pur_cmd.pur_user_name, avp, avphdr, "User-Name", avphdr->avp_value->os.data)
|
||||
|
||||
/* User-Data */
|
||||
PARSE_AVP_STR(udr_msg, g_pur_cmd.pur_user_date, avp, avphdr, "User-Data", avphdr->avp_value->os.data)
|
||||
|
||||
|
||||
/* OC-Supported-Features */
|
||||
CHECK_FCT( fd_msg_search_avp ( udr_msg, g_pur_cmd.pur_oc_supported_features, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj OC-Supported-Features");
|
||||
|
||||
/* OC-Feature-Vector */
|
||||
PARSE_GRPAVP_U64(grpavp, g_pur_cmd.pur_oc_feature_vector, avp, avphdr, "OC-Feature-Vector", avphdr->avp_value->u64)
|
||||
}
|
||||
|
||||
out:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sh_parse_udr(struct msg** msg)
|
||||
{
|
||||
struct msg* udr_msg = *msg;
|
||||
struct avp *avp, *grpavp=NULL;
|
||||
struct avp_hdr *avphdr;
|
||||
|
||||
LOG_D("fj sh_parse_udr");
|
||||
|
||||
|
||||
SEARCH_AVP_("Session-Id", 0, &g_udr_cmd.udr_session_id);
|
||||
SEARCH_AVP_("DRMP", SH_VND_ID, &g_udr_cmd.udr_drmp);
|
||||
SEARCH_AVP_("Vendor-Specific-Application-Id", 0, &g_udr_cmd.udr_vendor_specific_application_id);
|
||||
SEARCH_AVP_("Vendor-Id", 0, &g_udr_cmd.udr_vendor_id);
|
||||
SEARCH_AVP_("Auth-Application-Id", 0, &g_udr_cmd.udr_auth_application_d);
|
||||
SEARCH_AVP_("Acct-Application-Id", 0, &g_udr_cmd.udr_acct_application_id);
|
||||
|
||||
SEARCH_AVP_("Auth-Session-State", 0, &g_udr_cmd.udr_auth_session_state);
|
||||
SEARCH_AVP_("Origin-Host", 0, &g_udr_cmd.udr_origin_host);
|
||||
SEARCH_AVP_("Origin-Realm", 0, &g_udr_cmd.udr_origin_realm);
|
||||
SEARCH_AVP_("Destination-Host", 0, &g_udr_cmd.udr_destination_host);
|
||||
SEARCH_AVP_("Destination-Realm", 0, &g_udr_cmd.udr_destination_realm);
|
||||
|
||||
SEARCH_AVP_("Supported-Features", SH_VND_ID, &g_udr_cmd.udr_supported_features);
|
||||
SEARCH_AVP_("Feature-List-ID", SH_VND_ID, &g_udr_cmd.udr_feature_list_id);
|
||||
SEARCH_AVP_("Feature-List", SH_VND_ID, &g_udr_cmd.udr_feature_list);
|
||||
|
||||
SEARCH_AVP_("User-Identity", SH_VND_ID, &g_udr_cmd.udr_user_identity);
|
||||
SEARCH_AVP_("Public-Identity", SH_VND_ID, &g_udr_cmd.udr_public_identity);
|
||||
SEARCH_AVP_("MSISDN", SH_VND_ID, &g_udr_cmd.udr_msisdn);
|
||||
|
||||
|
||||
SEARCH_AVP_("Wildcarded-Public-Identity", SH_VND_ID, &g_udr_cmd.udr_wildcarded_public_identity);
|
||||
SEARCH_AVP_("Wildcarded-IMPU", SH_VND_ID, &g_udr_cmd.udr_wildcarded_impu);
|
||||
SEARCH_AVP_("Server-Name", SH_VND_ID, &g_udr_cmd.udr_server_name);
|
||||
SEARCH_AVP_("Service-Indication", SH_VND_ID, &g_udr_cmd.udr_service_indication);
|
||||
SEARCH_AVP_("Data-Reference", SH_VND_ID, &g_udr_cmd.udr_data_reference);
|
||||
SEARCH_AVP_("Identity-Set", SH_VND_ID, &g_udr_cmd.udr_identity_set);
|
||||
SEARCH_AVP_("Requested-Domain", SH_VND_ID, &g_udr_cmd.udr_requested_domain);
|
||||
SEARCH_AVP_("Current-Location", SH_VND_ID, &g_udr_cmd.udr_current_location);
|
||||
SEARCH_AVP_("DSAI-Tag", SH_VND_ID, &g_udr_cmd.udr_dsai_tag);
|
||||
SEARCH_AVP_("Session-Priority", SH_VND_ID, &g_udr_cmd.udr_session_priority);
|
||||
SEARCH_AVP_("User-Name", 0, &g_udr_cmd.udr_user_name);
|
||||
SEARCH_AVP_("Requested-Nodes", SH_VND_ID, &g_udr_cmd.udr_requested_nodes);
|
||||
SEARCH_AVP_("Serving-Node-Indication", SH_VND_ID, &g_udr_cmd.udr_serving_node_indication);
|
||||
SEARCH_AVP_("Pre-paging-Supported", SH_VND_ID, &g_udr_cmd.udr_pre_paging_supported);
|
||||
SEARCH_AVP_("Local-Time-Zone-Indication", SH_VND_ID, &g_udr_cmd.udr_local_time_zone_indication);
|
||||
SEARCH_AVP_("UDR-Flags", SH_VND_ID, &g_udr_cmd.udr_udr_flags);
|
||||
|
||||
SEARCH_AVP_("Call-Reference-Info", SH_VND_ID, &g_udr_cmd.udr_call_reference_info);
|
||||
SEARCH_AVP_("Call-Reference-Number", SH_VND_ID, &g_udr_cmd.udr_call_reference_number);
|
||||
SEARCH_AVP_("AS-Number", SH_VND_ID, &g_udr_cmd.udr_as_number);
|
||||
|
||||
|
||||
SEARCH_AVP_("OC-Supported-Features", SH_VND_ID, &g_udr_cmd.udr_oc_supported_features);
|
||||
SEARCH_AVP_("OC-Feature-Vector", SH_VND_ID, &g_udr_cmd.udr_oc_feature_vector);
|
||||
|
||||
|
||||
/* Session-Id */
|
||||
PARSE_AVP_STR(udr_msg, g_udr_cmd.udr_session_id, avp, avphdr, "fj Session-Id", avphdr->avp_value->os.data)
|
||||
|
||||
/* DRMP */
|
||||
PARSE_AVP_U32(udr_msg, g_udr_cmd.udr_drmp, avp, avphdr, "fj DRMP", avphdr->avp_value->u32)
|
||||
|
||||
/* Vendor-Specific-Application-Id */
|
||||
CHECK_FCT( fd_msg_search_avp ( udr_msg, g_udr_cmd.udr_vendor_specific_application_id, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj Vendor-Specific-Application-Id");
|
||||
|
||||
/* Vendor-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_udr_cmd.udr_vendor_id, avp, avphdr, "Vendor-Id", avphdr->avp_value->u32)
|
||||
|
||||
/* Auth-Application-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_udr_cmd.udr_auth_application_d, avp, avphdr, "Auth-Application-Id", avphdr->avp_value->u32)
|
||||
|
||||
/* Acct-Application-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_udr_cmd.udr_acct_application_id, avp, avphdr, "Acct-Application-Id", avphdr->avp_value->u32)
|
||||
}
|
||||
|
||||
/* Auth-Session-State */
|
||||
PARSE_AVP_U32(udr_msg, g_udr_cmd.udr_auth_session_state, avp, avphdr, "Auth-Session-State", avphdr->avp_value->i32)
|
||||
|
||||
/* Origin-Host */
|
||||
PARSE_AVP_STR(udr_msg, g_udr_cmd.udr_origin_host, avp, avphdr, "Origin-Host", avphdr->avp_value->os.data)
|
||||
|
||||
/* Origin-Realm */
|
||||
PARSE_AVP_STR(udr_msg, g_udr_cmd.udr_origin_realm, avp, avphdr, "Origin-Realm", avphdr->avp_value->os.data)
|
||||
|
||||
/* Destination-Host */
|
||||
PARSE_AVP_STR(udr_msg, g_udr_cmd.udr_destination_host, avp, avphdr, "Dest-Host", avphdr->avp_value->os.data)
|
||||
|
||||
/* Destination-Realm */
|
||||
PARSE_AVP_STR(udr_msg, g_udr_cmd.udr_destination_realm, avp, avphdr, "Dest-Realm", avphdr->avp_value->os.data)
|
||||
|
||||
/* Supported-Features */
|
||||
CHECK_FCT( fd_msg_search_avp ( udr_msg, g_udr_cmd.udr_supported_features, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj Supported-Features ");
|
||||
|
||||
/* Vendor-Id */
|
||||
PARSE_GRPAVP_U32(grpavp, g_udr_cmd.udr_vendor_id, avp, avphdr, "Vendor-Id", avphdr->avp_value->u32)
|
||||
|
||||
/* Feature-List-ID */
|
||||
PARSE_GRPAVP_U32(grpavp, g_udr_cmd.udr_feature_list_id, avp, avphdr, "Feature-List-ID", avphdr->avp_value->u32)
|
||||
|
||||
/* Feature-List */
|
||||
PARSE_GRPAVP_U32(grpavp, g_udr_cmd.udr_feature_list, avp, avphdr, "Feature-List", avphdr->avp_value->u32)
|
||||
}
|
||||
|
||||
/* User-Identity */
|
||||
CHECK_FCT( fd_msg_search_avp ( udr_msg, g_udr_cmd.udr_user_identity, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj User-Identity");
|
||||
|
||||
/* Public-Identity */
|
||||
PARSE_GRPAVP_STR(grpavp, g_udr_cmd.udr_public_identity, avp, avphdr, "Public-Identity", avphdr->avp_value->os.data)
|
||||
|
||||
/* MSISDN */
|
||||
PARSE_GRPAVP_STR(grpavp, g_udr_cmd.udr_msisdn, avp, avphdr, "MSISDN", avphdr->avp_value->os.data)
|
||||
}
|
||||
|
||||
/* wildcarded_public_id */
|
||||
PARSE_AVP_STR(udr_msg, g_udr_cmd.udr_wildcarded_public_identity, avp, avphdr, "Wild-Pub-ID", avphdr->avp_value->os.data)
|
||||
|
||||
/* wildcarded_impu */
|
||||
PARSE_AVP_STR(udr_msg, g_udr_cmd.udr_wildcarded_impu, avp, avphdr, "Wild-Pub-IMPU", avphdr->avp_value->os.data)
|
||||
|
||||
/* server_name */
|
||||
PARSE_AVP_STR(udr_msg, g_udr_cmd.udr_server_name, avp, avphdr, "Server-Name", avphdr->avp_value->os.data)
|
||||
|
||||
/* Service-Indication */
|
||||
PARSE_AVP_STR(udr_msg, g_udr_cmd.udr_service_indication, avp, avphdr, "Service-ID", avphdr->avp_value->os.data)
|
||||
|
||||
/* Data-Reference */
|
||||
PARSE_AVP_U32(udr_msg, g_udr_cmd.udr_data_reference, avp, avphdr, "Data-Reference", avphdr->avp_value->u32)
|
||||
|
||||
/* Identity-Set */
|
||||
PARSE_AVP_U32(udr_msg, g_udr_cmd.udr_identity_set, avp, avphdr, "Identity-Set", avphdr->avp_value->u32)
|
||||
|
||||
/* Req-Domain*/
|
||||
PARSE_AVP_U32(udr_msg, g_udr_cmd.udr_requested_domain, avp, avphdr, "Req-Domain", avphdr->avp_value->u32)
|
||||
|
||||
/* Cur-Location*/
|
||||
PARSE_AVP_U32(udr_msg, g_udr_cmd.udr_current_location, avp, avphdr, "Cur-Location", avphdr->avp_value->u32)
|
||||
|
||||
/* DSAI-Tag */
|
||||
PARSE_AVP_STR(udr_msg, g_udr_cmd.udr_dsai_tag, avp, avphdr, "DSAI-Tag", avphdr->avp_value->os.data)
|
||||
|
||||
/* Session-Priority */
|
||||
PARSE_AVP_U32(udr_msg, g_udr_cmd.udr_session_priority, avp, avphdr, "Session-Priority", avphdr->avp_value->u32)
|
||||
|
||||
/* User-Name*/
|
||||
PARSE_AVP_STR(udr_msg, g_udr_cmd.udr_user_name, avp, avphdr, "User-Name", avphdr->avp_value->os.data)
|
||||
|
||||
PARSE_AVP_U32(udr_msg, g_udr_cmd.udr_requested_nodes, avp, avphdr, "Requested-Nodes", avphdr->avp_value->u32)
|
||||
PARSE_AVP_U32(udr_msg, g_udr_cmd.udr_serving_node_indication, avp, avphdr, "Serving-Node-Indication", avphdr->avp_value->u32)
|
||||
PARSE_AVP_U32(udr_msg, g_udr_cmd.udr_pre_paging_supported, avp, avphdr, "Pre-paging-Supported", avphdr->avp_value->u32)
|
||||
PARSE_AVP_U32(udr_msg, g_udr_cmd.udr_local_time_zone_indication, avp, avphdr, "Local-Time-Zone-Indication", avphdr->avp_value->u32)
|
||||
PARSE_AVP_U32(udr_msg, g_udr_cmd.udr_udr_flags, avp, avphdr, "UDR-Flags", avphdr->avp_value->u32)
|
||||
|
||||
/* Call-Reference-Info */
|
||||
CHECK_FCT( fd_msg_search_avp ( udr_msg, g_udr_cmd.udr_call_reference_info, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj Call-Reference-Info");
|
||||
|
||||
/* Call-Reference-Number */
|
||||
PARSE_GRPAVP_STR(grpavp, g_udr_cmd.udr_call_reference_number, avp, avphdr, "Call-Reference-Number", avphdr->avp_value->os.data)
|
||||
|
||||
/* AS-Number */
|
||||
PARSE_GRPAVP_STR(grpavp, g_udr_cmd.udr_as_number, avp, avphdr, "AS-Number", avphdr->avp_value->os.data)
|
||||
}
|
||||
|
||||
/* OC-Supported-Features */
|
||||
CHECK_FCT( fd_msg_search_avp ( udr_msg, g_udr_cmd.udr_oc_supported_features, &grpavp) );
|
||||
if(grpavp != NULL)
|
||||
{
|
||||
LOG_D("fj Call-Reference-Info");
|
||||
|
||||
/* OC-Feature-Vector */
|
||||
PARSE_GRPAVP_U64(grpavp, g_udr_cmd.udr_oc_feature_vector, avp, avphdr, "OC-Feature-Vector", avphdr->avp_value->u64)
|
||||
}
|
||||
out:
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sh_rec_pur( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act)
|
||||
{
|
||||
struct dict_object * pur_origin_host = NULL;
|
||||
|
||||
struct msg *ans/*, *qry*/;
|
||||
struct avp * a, *grpavp;
|
||||
union avp_value val;
|
||||
|
||||
TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act);
|
||||
LOG_D("fj sh_rec_pur in\n");
|
||||
|
||||
if (msg == NULL)
|
||||
return EINVAL;
|
||||
|
||||
sh_parse_pur(msg);
|
||||
|
||||
SEARCH_AVP_("Origin-Host", 0, &pur_origin_host);
|
||||
|
||||
/* Value of Origin-Host */
|
||||
if (! (ta_conf->mode & MODE_BENCH)) {
|
||||
fprintf(stderr, "ECHO PUR received from ");
|
||||
CHECK_FCT( fd_msg_search_avp ( *msg, pur_origin_host, &a) );
|
||||
if (a) {
|
||||
struct avp_hdr * hdr;
|
||||
CHECK_FCT( fd_msg_avp_hdr( a, &hdr ) );
|
||||
fprintf(stderr, "'%.*s'", (int)hdr->avp_value->os.len, hdr->avp_value->os.data);
|
||||
} else {
|
||||
fprintf(stderr, "no_Origin-Host");
|
||||
}
|
||||
fprintf(stderr, ", replying...\n");
|
||||
}
|
||||
|
||||
/* Create answer header */
|
||||
// qry = *msg;
|
||||
CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, msg, 0 ) );
|
||||
ans = *msg;
|
||||
|
||||
|
||||
/* set application id */
|
||||
{
|
||||
struct msg_hdr * msg_hdr = NULL;
|
||||
ASSERT( 0 == fd_msg_hdr ( ans, &msg_hdr ) );
|
||||
msg_hdr->msg_appl = SH_APP_ID;
|
||||
msg_hdr->msg_flags = msg_hdr->msg_flags & (~CMD_FLAG_PROXIABLE);
|
||||
}
|
||||
|
||||
|
||||
/* resolve uda avps */
|
||||
// SEARCH_AVP_("Session-Id", 0, &uda_session_id);
|
||||
SEARCH_AVP_("DRMP", SH_VND_ID, &g_pua_cmd.pua_drmp);
|
||||
SEARCH_AVP_("Vendor-Specific-Application-Id", 0, &g_pua_cmd.pua_vendor_specific_application_id);
|
||||
SEARCH_AVP_("Result-Code", 0, &g_pua_cmd.pua_result_code);
|
||||
SEARCH_AVP_("Experimental-Result", 0, &g_pua_cmd.pua_experimental_result);
|
||||
SEARCH_AVP_("Auth-Session-State", 0, &g_pua_cmd.pua_auth_session_state);
|
||||
SEARCH_AVP_("Origin-Host", 0, &g_pua_cmd.pua_origin_host);
|
||||
SEARCH_AVP_("Origin-Realm", 0, &g_pua_cmd.pua_origin_realm);
|
||||
|
||||
|
||||
SEARCH_AVP_("Wildcarded-Public-Identity", SH_VND_ID, &g_pua_cmd.pua_wildcarded_public_identity );
|
||||
SEARCH_AVP_("Wildcarded-IMPU", SH_VND_ID, &g_pua_cmd.pua_wildcarded_impu );
|
||||
SEARCH_AVP_("Repository-Data-ID", SH_VND_ID, &g_pua_cmd.pua_repository_data_id );
|
||||
|
||||
SEARCH_AVP_("Data-Reference", SH_VND_ID, &g_pua_cmd.pua_data_reference);
|
||||
|
||||
SEARCH_AVP_("Supported-Features", SH_VND_ID, &g_pua_cmd.pua_supported_features );
|
||||
SEARCH_AVP_("OC-Supported-Features", SH_VND_ID, &g_pua_cmd.pua_oc_supported_features );
|
||||
SEARCH_AVP_("OC-OLR", SH_VND_ID, &g_pua_cmd.pua_oc_olr );
|
||||
|
||||
|
||||
EN_AVP_U32(g_pua_cmd.pua_drmp, 0, ans, "DRMP Ok")
|
||||
|
||||
/* Set Vendor-Specific-Application-Id AVP if needed*/
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_new ( g_pua_cmd.pua_vendor_specific_application_id, 0, &grpavp ) );
|
||||
|
||||
EN_GRPAVP_U32("Vendor-Id", 0, g_pua_cmd.pua_vendor_id, SH_VND_ID)
|
||||
EN_GRPAVP_U32("Auth-Application-Id", 0, g_pua_cmd.pua_auth_application_d, SH_APP_ID)
|
||||
EN_GRPAVP_U32("Acct-Application-Id", 0,g_pua_cmd.pua_acct_application_id, SH_APP_ID)
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, grpavp ) );
|
||||
|
||||
LOG_D("Vendor-Specific-Application-Id Ok\n");
|
||||
}
|
||||
|
||||
// EN_AVP_U32(g_uda_cmd.uda_result_code, 2001, ans, "Result-Code Ok\n")
|
||||
|
||||
/* Set the Experimental-Result group AVP if needed*/
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_new ( g_pua_cmd.pua_experimental_result, 0, &grpavp ) );
|
||||
|
||||
EN_GRPAVP_U32("Vendor-Id", 0, g_pua_cmd.pua_vendor_id, SH_VND_ID)
|
||||
EN_GRPAVP_U32("Experimental-Result-Code", 0, g_pua_cmd.pua_experimental_result_code, 3)
|
||||
CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, grpavp ) );
|
||||
|
||||
LOG_D("Experimental-Result Ok\n");
|
||||
}
|
||||
|
||||
EN_AVP_U32(g_pua_cmd.pua_auth_session_state, 0, ans, "Auth-Session-State Ok\n")
|
||||
|
||||
|
||||
EN_AVP_STR(g_pua_cmd.pua_wildcarded_public_identity, "wildcarded_public_id", ans, "wildcarded_public_id Ok")
|
||||
EN_AVP_STR( g_pua_cmd.pua_wildcarded_impu, "wildcarded_impu", ans, "wildcarded_impu Ok")
|
||||
/* Set the Repository-Data-ID AVP */
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_new ( g_pua_cmd.pua_repository_data_id, 0, &grpavp ) );
|
||||
|
||||
EN_GRPAVP_STR("Service-Indication", SH_VND_ID, g_pua_cmd.pua_service_indication, "Service-Indicatioin", grpavp)
|
||||
EN_GRPAVP_U32_("Sequence-Number", SH_VND_ID, g_pua_cmd.pua_sequence_number, 1234, grpavp)
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, grpavp ) );
|
||||
|
||||
LOG_D("Repository-Data-ID Ok\n");
|
||||
}
|
||||
|
||||
EN_AVP_U32(g_pua_cmd.pua_data_reference, 0, ans, "Data-Reference Ok\n")
|
||||
|
||||
/* Set the Supported-Features group AVP if needed*/
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_new ( g_pua_cmd.pua_supported_features, 0, &grpavp ) );
|
||||
|
||||
EN_GRPAVP_U32_("Vendor-Id", 0, g_pua_cmd.pua_vendor_id, SH_VND_ID, grpavp)
|
||||
EN_GRPAVP_U32_("Feature-List-ID", SH_VND_ID, g_pua_cmd.pua_feature_list_id, 2, grpavp)
|
||||
EN_GRPAVP_U32_("Feature-List", SH_VND_ID, g_pua_cmd.pua_feature_list, 3, grpavp)
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, grpavp ) );
|
||||
|
||||
LOG_D("Supported-Features Ok\n");
|
||||
}
|
||||
|
||||
/* Set the OC-Supported-Features AVP */
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_new ( g_pua_cmd.pua_oc_supported_features, 0, &grpavp ) );
|
||||
|
||||
EN_GRPAVP_U64("OC-Feature-Vector", SH_VND_ID, g_pua_cmd.pua_oc_feature_vector, 1)
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, grpavp ) );
|
||||
|
||||
LOG_D("OC-Feature-Vector Ok\n");
|
||||
}
|
||||
|
||||
/* Set the OC-OLR group AVP if needed*/
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_new ( g_pua_cmd.pua_oc_olr, 0, &grpavp ) );
|
||||
|
||||
EN_GRPAVP_U64("OC-Sequence-Number", SH_VND_ID, g_pua_cmd.pua_oc_sequence_number, 1)
|
||||
EN_GRPAVP_U32("OC-Report-Type", SH_VND_ID,g_pua_cmd.pua_oc_report_type, 2)
|
||||
EN_GRPAVP_U32("OC-Reduction-Percentage", SH_VND_ID, g_pua_cmd.pua_oc_reduction_percentage, 3)
|
||||
EN_GRPAVP_U32("OC-Validity-Duration", SH_VND_ID, g_pua_cmd.pua_oc_validity_duration, 4)
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, grpavp ) );
|
||||
|
||||
LOG_D("OC-OLR Ok\n");
|
||||
}
|
||||
|
||||
/* Set the Origin-Host, Origin-Realm, Result-Code AVPs */
|
||||
CHECK_FCT( fd_msg_rescode_set( ans, "DIAMETER_SUCCESS", NULL, NULL, 1 ) );
|
||||
|
||||
/* Send the answer */
|
||||
CHECK_FCT( fd_msg_send( msg, NULL, NULL ) );
|
||||
|
||||
/* Add this value to the stats */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), );
|
||||
ta_conf->stats.nb_echoed++;
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), );
|
||||
|
||||
out:
|
||||
printf("sh_rec_pur end.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sh_rec_udr( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act)
|
||||
{
|
||||
struct msg *ans/*, *qry*/;
|
||||
struct avp * a, *grpavp;
|
||||
union avp_value val;
|
||||
|
||||
TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act);
|
||||
LOG_D("fj sh_rec_udr in\n");
|
||||
|
||||
if (msg == NULL)
|
||||
return EINVAL;
|
||||
|
||||
sh_parse_udr(msg);
|
||||
|
||||
SEARCH_AVP_("Origin-Host", 0, &g_uda_cmd.uda_origin_host);
|
||||
SEARCH_AVP_("Session-Id", 0, &g_uda_cmd.uda_session_id);
|
||||
|
||||
/* Value of Origin-Host */
|
||||
if (! (ta_conf->mode & MODE_BENCH)) {
|
||||
fprintf(stderr, "ECHO UDR received from ");
|
||||
CHECK_FCT( fd_msg_search_avp ( *msg, g_uda_cmd.uda_origin_host, &a) );
|
||||
if (a) {
|
||||
struct avp_hdr * hdr;
|
||||
CHECK_FCT( fd_msg_avp_hdr( a, &hdr ) );
|
||||
fprintf(stderr, "'%.*s'", (int)hdr->avp_value->os.len, hdr->avp_value->os.data);
|
||||
} else {
|
||||
fprintf(stderr, "no_Origin-Host");
|
||||
}
|
||||
fprintf(stderr, ", replying...\n");
|
||||
}
|
||||
|
||||
/* Create answer header */
|
||||
// qry = *msg;
|
||||
CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, msg, 0 ) );
|
||||
ans = *msg;
|
||||
|
||||
/* set application id */
|
||||
{
|
||||
struct msg_hdr * msg_hdr = NULL;
|
||||
ASSERT( 0 == fd_msg_hdr ( ans, &msg_hdr ) );
|
||||
msg_hdr->msg_appl = SH_APP_ID;
|
||||
msg_hdr->msg_flags = msg_hdr->msg_flags & (~CMD_FLAG_PROXIABLE);
|
||||
}
|
||||
|
||||
/* resolve uda avps */
|
||||
// SEARCH_AVP_("Session-Id", 0, &uda_session_id);
|
||||
SEARCH_AVP_("DRMP", SH_VND_ID, &g_uda_cmd.uda_drmp);
|
||||
SEARCH_AVP_("Vendor-Specific-Application-Id", 0, &g_uda_cmd.uda_vendor_specific_application_id);
|
||||
SEARCH_AVP_("Result-Code", 0, &g_uda_cmd.uda_result_code);
|
||||
SEARCH_AVP_("Experimental-Result", 0, &g_uda_cmd.uda_experimental_result);
|
||||
SEARCH_AVP_("Auth-Session-State", 0, &g_uda_cmd.uda_auth_session_state);
|
||||
|
||||
SEARCH_AVP_("Origin-Realm", 0, &g_uda_cmd.uda_origin_realm);
|
||||
|
||||
SEARCH_AVP_("Supported-Features", SH_VND_ID, &g_uda_cmd.uda_supported_features );
|
||||
SEARCH_AVP_("Wildcarded-Public-Identity", SH_VND_ID, &g_uda_cmd.uda_wildcarded_public_identity );
|
||||
SEARCH_AVP_("Wildcarded-IMPU", SH_VND_ID, &g_uda_cmd.uda_wildcarded_impu );
|
||||
SEARCH_AVP_("User-Data", SH_VND_ID, &g_uda_cmd.uda_user_data );
|
||||
SEARCH_AVP_("OC-Supported-Features", SH_VND_ID, &g_uda_cmd.uda_oc_supported_features );
|
||||
SEARCH_AVP_("OC-OLR", SH_VND_ID, &g_uda_cmd.uda_oc_olr );
|
||||
|
||||
|
||||
EN_AVP_U32(g_uda_cmd.uda_drmp, 0, ans, "DRMP Ok")
|
||||
|
||||
/* Set Vendor-Specific-Application-Id AVP if needed*/
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_new ( g_uda_cmd.uda_vendor_specific_application_id, 0, &grpavp ) );
|
||||
|
||||
EN_GRPAVP_U32("Vendor-Id", 0, g_uda_cmd.uda_vendor_id, SH_VND_ID)
|
||||
EN_GRPAVP_U32("Auth-Application-Id", 0, g_uda_cmd.uda_auth_application_d, SH_APP_ID)
|
||||
EN_GRPAVP_U32("Acct-Application-Id", 0,g_uda_cmd.uda_acct_application_id, SH_APP_ID)
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, grpavp ) );
|
||||
|
||||
LOG_D("Vendor-Specific-Application-Id Ok\n");
|
||||
}
|
||||
|
||||
// EN_AVP_U32(g_uda_cmd.uda_result_code, 2001, ans, "Result-Code Ok\n")
|
||||
|
||||
/* Set the Experimental-Result group AVP if needed*/
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_new ( g_uda_cmd.uda_experimental_result, 0, &grpavp ) );
|
||||
|
||||
EN_GRPAVP_U32("Vendor-Id", 0, g_uda_cmd.uda_vendor_id, 3)
|
||||
EN_GRPAVP_U32("Experimental-Result-Code", 0, g_uda_cmd.uda_experimental_result_code, 3)
|
||||
CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, grpavp ) );
|
||||
|
||||
LOG_D("Experimental-Result Ok\n");
|
||||
}
|
||||
|
||||
EN_AVP_U32(g_uda_cmd.uda_auth_session_state, 0, ans, "Auth-Session-State Ok\n")
|
||||
|
||||
/* Set the Supported-Features group AVP if needed*/
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_new ( g_uda_cmd.uda_supported_features, 0, &grpavp ) );
|
||||
|
||||
EN_GRPAVP_U32("Vendor-Id", 0, g_uda_cmd.uda_vendor_id, 1)
|
||||
EN_GRPAVP_U32("Feature-List-ID", SH_VND_ID, g_uda_cmd.uda_feature_list_id, 2)
|
||||
EN_GRPAVP_U32("Feature-List", SH_VND_ID, g_uda_cmd.uda_feature_list, 3)
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, grpavp ) );
|
||||
|
||||
LOG_D("Supported-Features Ok\n");
|
||||
}
|
||||
EN_AVP_STR(g_uda_cmd.uda_wildcarded_public_identity, "wildcarded_public_id", ans, "wildcarded_public_id Ok")
|
||||
EN_AVP_STR( g_uda_cmd.uda_wildcarded_impu, "wildcarded_impu", ans, "wildcarded_impu Ok")
|
||||
EN_AVP_STR( g_uda_cmd.uda_user_data, "User-Data", ans, "User-Data Ok")
|
||||
/* Set the OC-Supported-Features AVP */
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_new ( g_uda_cmd.uda_oc_supported_features, 0, &grpavp ) );
|
||||
|
||||
EN_GRPAVP_U64("OC-Feature-Vector", SH_VND_ID, g_uda_cmd.uda_oc_feature_vector, 1)
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, grpavp ) );
|
||||
|
||||
LOG_D("OC-Feature-Vector Ok\n");
|
||||
}
|
||||
/* Set the OC-OLR group AVP if needed*/
|
||||
{
|
||||
CHECK_FCT( fd_msg_avp_new ( g_uda_cmd.uda_oc_olr, 0, &grpavp ) );
|
||||
|
||||
EN_GRPAVP_U64("OC-Sequence-Number", SH_VND_ID, g_uda_cmd.uda_oc_sequence_number, 1)
|
||||
EN_GRPAVP_U32("OC-Report-Type", SH_VND_ID,g_uda_cmd.uda_oc_report_type, 2)
|
||||
EN_GRPAVP_U32("OC-Reduction-Percentage", SH_VND_ID, g_uda_cmd.uda_oc_reduction_percentage, 3)
|
||||
EN_GRPAVP_U32("OC-Validity-Duration", SH_VND_ID, g_uda_cmd.uda_oc_validity_duration, 4)
|
||||
|
||||
CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, grpavp ) );
|
||||
|
||||
LOG_D("Supported-Features Ok\n");
|
||||
#if SH_TEST_ON
|
||||
fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, ans, fd_g_config->cnf_dict, 0, 1));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Set the Origin-Host, Origin-Realm, Result-Code AVPs */
|
||||
CHECK_FCT( fd_msg_rescode_set( ans, "DIAMETER_SUCCESS", NULL, NULL, 1 ) );
|
||||
|
||||
/* Send the answer */
|
||||
CHECK_FCT( fd_msg_send( msg, NULL, NULL ) );
|
||||
|
||||
/* Add this value to the stats */
|
||||
CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), );
|
||||
ta_conf->stats.nb_echoed++;
|
||||
CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), );
|
||||
|
||||
out:
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern struct dict_object * sh_appli;
|
||||
extern struct dict_object * sh_vendor;
|
||||
extern struct dict_object * udr_cmd;
|
||||
extern struct dict_object * pur_cmd;
|
||||
|
||||
int sh_serv_init(void)
|
||||
{
|
||||
struct disp_when data;
|
||||
|
||||
TRACE_DEBUG(FULL, "Initializing dispatch callbacks for test");
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.app = sh_appli;
|
||||
data.command = udr_cmd; // udr_cmd; // ta_cmd_r;
|
||||
|
||||
/* fallback CB if command != Test-Request received */
|
||||
// CHECK_FCT( fd_disp_register( ta_fb_cb, DISP_HOW_APPID, &data, NULL, &sh_hdl_fb ) );
|
||||
|
||||
/* Now specific handler for UDR */
|
||||
CHECK_FCT( fd_disp_register( sh_rec_udr, DISP_HOW_CC, &data, NULL, &sh_hdl_udr ) );
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
data.app = sh_appli;
|
||||
data.command = pur_cmd; // udr_cmd; // ta_cmd_r;
|
||||
/* Now specific handler for PUR */
|
||||
CHECK_FCT( fd_disp_register( sh_rec_pur, DISP_HOW_CC, &data, NULL, &sh_hdl_pur ) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sh_serv_fini(void)
|
||||
{
|
||||
if (sh_hdl_fb) {
|
||||
(void) fd_disp_unregister(&sh_hdl_fb, NULL);
|
||||
}
|
||||
if (sh_hdl_udr) {
|
||||
(void) fd_disp_unregister(&sh_hdl_udr, NULL);
|
||||
}
|
||||
if (sh_hdl_pur) {
|
||||
(void) fd_disp_unregister(&sh_hdl_pur, NULL);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
177
plat/diameter/extensions/sh_app/ta_conf.l
Normal file
177
plat/diameter/extensions/sh_app/ta_conf.l
Normal file
@@ -0,0 +1,177 @@
|
||||
/*********************************************************************************************************
|
||||
* Software License Agreement (BSD License) *
|
||||
* Author: Sebastien Decugis <sdecugis@freediameter.net> *
|
||||
* *
|
||||
* Copyright (c) 2013, WIDE Project and NICT *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Redistribution and use of this software in source and binary forms, with or without modification, are *
|
||||
* permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* * Redistributions of source code must retain the above *
|
||||
* copyright notice, this list of conditions and the *
|
||||
* following disclaimer. *
|
||||
* *
|
||||
* * Redistributions in binary form must reproduce the above *
|
||||
* copyright notice, this list of conditions and the *
|
||||
* following disclaimer in the documentation and/or other *
|
||||
* materials provided with the distribution. *
|
||||
* *
|
||||
* * Neither the name of the WIDE Project or NICT nor the *
|
||||
* names of its contributors may be used to endorse or *
|
||||
* promote products derived from this software without *
|
||||
* specific prior written permission of WIDE Project and *
|
||||
* NICT. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
|
||||
*********************************************************************************************************/
|
||||
|
||||
/* Lex extension's configuration parser.
|
||||
*
|
||||
* The configuration file contains a default priority, and a list of peers with optional overwite priority.
|
||||
* -- see the app_test.conf.sample file for more detail.
|
||||
*/
|
||||
|
||||
%{
|
||||
#include "test_app.h"
|
||||
/* Include yacc tokens definitions */
|
||||
#include "ta_conf.tab.h"
|
||||
|
||||
/* Update the column information */
|
||||
#define YY_USER_ACTION { \
|
||||
yylloc->first_column = yylloc->last_column + 1; \
|
||||
yylloc->last_column = yylloc->first_column + yyleng - 1; \
|
||||
}
|
||||
|
||||
/* Avoid warning with newer flex */
|
||||
#define YY_NO_INPUT
|
||||
|
||||
%}
|
||||
|
||||
%option bison-bridge bison-locations
|
||||
%option noyywrap
|
||||
%option nounput
|
||||
|
||||
%%
|
||||
|
||||
/* Update the line count */
|
||||
\n {
|
||||
yylloc->first_line++;
|
||||
yylloc->last_line++;
|
||||
yylloc->last_column=0;
|
||||
}
|
||||
|
||||
/* Eat all spaces but not new lines */
|
||||
([[:space:]]{-}[\n])+ ;
|
||||
/* Eat all comments */
|
||||
#.*$ ;
|
||||
|
||||
/* Recognize any integer */
|
||||
[-]?[[:digit:]]+ {
|
||||
/* Convert this to an integer value */
|
||||
int ret=0;
|
||||
ret = sscanf(yytext, "%i", &yylval->integer);
|
||||
if (ret != 1) {
|
||||
/* No matching: an error occurred */
|
||||
fd_log_debug("Unable to convert the value '%s' to a valid number: %s", yytext, strerror(errno));
|
||||
return LEX_ERROR; /* trig an error in yacc parser */
|
||||
/* Maybe we could REJECT instead of failing here? */
|
||||
}
|
||||
return INTEGER;
|
||||
}
|
||||
|
||||
/* Recognize quoted strings -- we do not support escaped \" in the string currently. */
|
||||
\"[^\"]+\" {
|
||||
/* Match a quoted string. Let's be very permissive. */
|
||||
yylval->string = strdup(yytext+1);
|
||||
if (!yylval->string) {
|
||||
fd_log_debug("Unable to copy the string '%s': %s", yytext, strerror(errno));
|
||||
TRACE_DEBUG(INFO, "strdup failed");
|
||||
return LEX_ERROR; /* trig an error in yacc parser */
|
||||
}
|
||||
yylval->string[strlen(yytext) - 2] = '\0';
|
||||
return QSTRING;
|
||||
}
|
||||
|
||||
/* Recognize the tokens */
|
||||
(?i:"vendor-id") {
|
||||
return VENDOR_ID;
|
||||
}
|
||||
|
||||
(?i:"appli-id") {
|
||||
return APPLI_ID;
|
||||
}
|
||||
|
||||
(?i:"cmd-id") {
|
||||
return CMD_ID;
|
||||
}
|
||||
|
||||
(?i:"avp-id") {
|
||||
return AVP_ID;
|
||||
}
|
||||
|
||||
(?i:"long-avp-id") {
|
||||
return LONG_AVP_ID;
|
||||
}
|
||||
|
||||
(?i:"long-avp-len") {
|
||||
return LONG_AVP_LEN;
|
||||
}
|
||||
|
||||
(?i:"mode") {
|
||||
return MODE;
|
||||
}
|
||||
|
||||
(?i:"server") {
|
||||
yylval->integer = MODE_SERV;
|
||||
return INTEGER;
|
||||
}
|
||||
|
||||
(?i:"client") {
|
||||
yylval->integer = MODE_CLI;
|
||||
return INTEGER;
|
||||
}
|
||||
|
||||
(?i:"both") {
|
||||
yylval->integer = MODE_SERV | MODE_CLI;
|
||||
return INTEGER;
|
||||
}
|
||||
|
||||
(?i:"dest-realm") {
|
||||
return DEST_REALM;
|
||||
}
|
||||
|
||||
(?i:"dest-host") {
|
||||
return DEST_HOST;
|
||||
}
|
||||
|
||||
(?i:"user-name") {
|
||||
return USER_NAME;
|
||||
}
|
||||
|
||||
(?i:"Signal") {
|
||||
return SIGNAL;
|
||||
}
|
||||
|
||||
(?i:"Benchmark") {
|
||||
return BENCH;
|
||||
}
|
||||
|
||||
|
||||
/* Valid single characters for yyparse */
|
||||
[=;] { return yytext[0]; }
|
||||
|
||||
/* Unrecognized sequence, if it did not match any previous pattern */
|
||||
[^[:space:]"*=>;\n]+ {
|
||||
fd_log_debug("Unrecognized text on line %d col %d: '%s'.", yylloc->first_line, yylloc->first_column, yytext);
|
||||
return LEX_ERROR;
|
||||
}
|
||||
|
||||
%%
|
||||
239
plat/diameter/extensions/sh_app/ta_conf.y
Normal file
239
plat/diameter/extensions/sh_app/ta_conf.y
Normal file
@@ -0,0 +1,239 @@
|
||||
/*********************************************************************************************************
|
||||
* Software License Agreement (BSD License) *
|
||||
* Author: Sebastien Decugis <sdecugis@freediameter.net> *
|
||||
* *
|
||||
* Copyright (c) 2013, WIDE Project and NICT *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* Redistribution and use of this software in source and binary forms, with or without modification, are *
|
||||
* permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* * Redistributions of source code must retain the above *
|
||||
* copyright notice, this list of conditions and the *
|
||||
* following disclaimer. *
|
||||
* *
|
||||
* * Redistributions in binary form must reproduce the above *
|
||||
* copyright notice, this list of conditions and the *
|
||||
* following disclaimer in the documentation and/or other *
|
||||
* materials provided with the distribution. *
|
||||
* *
|
||||
* * Neither the name of the WIDE Project or NICT nor the *
|
||||
* names of its contributors may be used to endorse or *
|
||||
* promote products derived from this software without *
|
||||
* specific prior written permission of WIDE Project and *
|
||||
* NICT. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
|
||||
*********************************************************************************************************/
|
||||
|
||||
/* Yacc extension's configuration parser.
|
||||
* See doc/app_test.conf.sample for configuration file format
|
||||
*/
|
||||
|
||||
/* For development only : */
|
||||
%debug
|
||||
%error-verbose
|
||||
|
||||
/* The parser receives the configuration file filename as parameter */
|
||||
%parse-param {char * conffile}
|
||||
|
||||
/* Keep track of location */
|
||||
%locations
|
||||
%pure-parser
|
||||
|
||||
%{
|
||||
#include "test_app.h"
|
||||
#include "ta_conf.tab.h" /* bison is not smart enough to define the YYLTYPE before including this code, so... */
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Forward declaration */
|
||||
int yyparse(char * conffile);
|
||||
|
||||
/* Parse the configuration file */
|
||||
int ta_conf_handle(char * conffile)
|
||||
{
|
||||
extern FILE * ta_confin;
|
||||
int ret;
|
||||
|
||||
TRACE_ENTRY("%p", conffile);
|
||||
|
||||
TRACE_DEBUG (FULL, "Parsing configuration file: %s...", conffile);
|
||||
|
||||
ta_confin = fopen(conffile, "r");
|
||||
if (ta_confin == NULL) {
|
||||
ret = errno;
|
||||
fd_log_debug("Unable to open extension configuration file %s for reading: %s", conffile, strerror(ret));
|
||||
TRACE_DEBUG (INFO, "Error occurred, message logged -- configuration file.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = yyparse(conffile);
|
||||
|
||||
fclose(ta_confin);
|
||||
|
||||
if (ret != 0) {
|
||||
TRACE_DEBUG (INFO, "Unable to parse the configuration file.");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The Lex parser prototype */
|
||||
int ta_conflex(YYSTYPE *lvalp, YYLTYPE *llocp);
|
||||
|
||||
/* Function to report the errors */
|
||||
void yyerror (YYLTYPE *ploc, char * conffile, char const *s)
|
||||
{
|
||||
TRACE_DEBUG(INFO, "Error in configuration parsing");
|
||||
|
||||
if (ploc->first_line != ploc->last_line)
|
||||
fd_log_debug("%s:%d.%d-%d.%d : %s", conffile, ploc->first_line, ploc->first_column, ploc->last_line, ploc->last_column, s);
|
||||
else if (ploc->first_column != ploc->last_column)
|
||||
fd_log_debug("%s:%d.%d-%d : %s", conffile, ploc->first_line, ploc->first_column, ploc->last_column, s);
|
||||
else
|
||||
fd_log_debug("%s:%d.%d : %s", conffile, ploc->first_line, ploc->first_column, s);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
/* Values returned by lex for token */
|
||||
%union {
|
||||
char *string; /* The string is allocated by strdup in lex.*/
|
||||
int integer; /* Store integer values */
|
||||
}
|
||||
|
||||
/* In case of error in the lexical analysis */
|
||||
%token LEX_ERROR
|
||||
|
||||
/* Key words */
|
||||
%token VENDOR_ID
|
||||
%token APPLI_ID
|
||||
%token CMD_ID
|
||||
%token AVP_ID
|
||||
%token LONG_AVP_ID
|
||||
%token LONG_AVP_LEN
|
||||
%token MODE
|
||||
%token DEST_REALM
|
||||
%token DEST_HOST
|
||||
%token USER_NAME
|
||||
%token SIGNAL
|
||||
%token BENCH
|
||||
|
||||
/* Tokens and types for routing table definition */
|
||||
/* A (de)quoted string (malloc'd in lex parser; it must be freed after use) */
|
||||
%token <string> QSTRING
|
||||
|
||||
/* An integer value */
|
||||
%token <integer> INTEGER
|
||||
|
||||
|
||||
|
||||
/* -------------------------------------- */
|
||||
%%
|
||||
|
||||
/* The grammar definition */
|
||||
conffile: /* empty grammar is OK */
|
||||
| conffile vendor
|
||||
| conffile appli
|
||||
| conffile cmd
|
||||
| conffile avp
|
||||
| conffile long_avp_id
|
||||
| conffile long_avp_len
|
||||
| conffile mode
|
||||
| conffile dstrealm
|
||||
| conffile dsthost
|
||||
| conffile usrname
|
||||
| conffile signal
|
||||
| conffile bench
|
||||
;
|
||||
|
||||
vendor: VENDOR_ID '=' INTEGER ';'
|
||||
{
|
||||
ta_conf->vendor_id = $3;
|
||||
}
|
||||
;
|
||||
|
||||
appli: APPLI_ID '=' INTEGER ';'
|
||||
{
|
||||
ta_conf->appli_id = $3;
|
||||
}
|
||||
;
|
||||
|
||||
cmd: CMD_ID '=' INTEGER ';'
|
||||
{
|
||||
ta_conf->cmd_id = $3;
|
||||
}
|
||||
;
|
||||
|
||||
avp: AVP_ID '=' INTEGER ';'
|
||||
{
|
||||
ta_conf->avp_id = $3;
|
||||
}
|
||||
;
|
||||
|
||||
long_avp_id: LONG_AVP_ID '=' INTEGER ';'
|
||||
{
|
||||
ta_conf->long_avp_id = $3;
|
||||
}
|
||||
;
|
||||
|
||||
long_avp_len: LONG_AVP_LEN '=' INTEGER ';'
|
||||
{
|
||||
ta_conf->long_avp_len = $3;
|
||||
}
|
||||
;
|
||||
|
||||
mode: MODE '=' INTEGER ';'
|
||||
{
|
||||
ta_conf->mode = $3 | (ta_conf->mode & ~3); /* overwrite the 2 lsb */
|
||||
}
|
||||
;
|
||||
|
||||
bench: BENCH ';'
|
||||
{
|
||||
ta_conf->mode |= MODE_BENCH;
|
||||
}
|
||||
| BENCH INTEGER INTEGER ';'
|
||||
{
|
||||
ta_conf->mode |= MODE_BENCH;
|
||||
ta_conf->bench_duration = $2;
|
||||
ta_conf->bench_concur = $3;
|
||||
}
|
||||
;
|
||||
|
||||
dstrealm: DEST_REALM '=' QSTRING ';'
|
||||
{
|
||||
free(ta_conf->dest_realm);
|
||||
ta_conf->dest_realm = $3;
|
||||
}
|
||||
;
|
||||
|
||||
dsthost: DEST_HOST '=' QSTRING ';'
|
||||
{
|
||||
free(ta_conf->dest_host);
|
||||
ta_conf->dest_host = $3;
|
||||
}
|
||||
;
|
||||
|
||||
usrname: USER_NAME '=' QSTRING ';'
|
||||
{
|
||||
free(ta_conf->user_name);
|
||||
ta_conf->user_name = $3;
|
||||
}
|
||||
;
|
||||
|
||||
signal: SIGNAL '=' INTEGER ';'
|
||||
{
|
||||
ta_conf->signal = $3;
|
||||
}
|
||||
;
|
||||
Reference in New Issue
Block a user