Skip to content
Snippets Groups Projects
Commit 12ae0cfc authored by Elemer Lelik's avatar Elemer Lelik
Browse files

Initial contribution

parent 1b0ad123
No related branches found
Tags R.12.A
No related merge requests found
Showing
with 4339 additions and 0 deletions
# titan.ProtocolModules.RADIUS_ProtocolModule_Generator
Main project page:
https://projects.eclipse.org/projects/tools.titan
The source code of the TTCN-3 compiler and executor:
https://github.com/eclipse/titan.core
<!DOCTYPE TITAN_GUI_project_file>
<Project TITAN_version="1.8.pl2" >
<General>
<Project_Name>RADIUS_Demo_new</Project_Name>
<Executable_Path>myTest</Executable_Path>
<Working_Dir>.</Working_Dir>
<Build_Host>alpha</Build_Host>
<Execution_Mode>Parallel</Execution_Mode>
<Code_Splitting_Mode>None</Code_Splitting_Mode>
<ScriptFile_AfterMake>gui_make_RPMG_new.sh</ScriptFile_AfterMake>
<Log_Format>yes</Log_Format>
<Update_Symlinks>yes</Update_Symlinks>
<Create_Absolute_Symlinks>no</Create_Absolute_Symlinks>
<Update_Makefile>yes</Update_Makefile>
<Localhost_Execute>yes</Localhost_Execute>
<Execute_Command>rsh %host &quot;cd %project_working_dir ; &quot;%executable&quot; %localhost %mctr_port&quot;</Execute_Command>
<Execute_Hosts>alfa, beta, gamma</Execute_Hosts>
<UnUsed_List></UnUsed_List>
</General>
<Modules>
<Module>../../../TestPorts/UDPasp_CNL113346/src/UDPasp_PortType.ttcn</Module>
<Module>../../../TestPorts/UDPasp_CNL113346/src/UDPasp_Types.ttcn</Module>
<Module>RADIUS_Mapping_new.ttcn</Module>
<Module>Radius_Test_new.ttcn</Module>
</Modules>
<TestPorts>
<TestPort>../../../TestPorts/UDPasp_CNL113346/src/UDPasp_PT.cc</TestPort>
<TestPort>../../../TestPorts/UDPasp_CNL113346/src/UDPasp_PT.hh</TestPort>
</TestPorts>
<Other_Sources>
<Other_Source>../src/RADIUS_EncDec.cc</Other_Source>
</Other_Sources>
<Configs>
<Config>radius.cfg</Config>
</Configs>
<Test_Cases>
<Test_Case>Radius_Test_new.tc_RADIUS_server_receiveAccessRequest_sendAccessAccept_with_correct_auth</Test_Case>
<Test_Case>Radius_Test_new.tc_RADIUS_server_receiveAccessRequest_sendAccessAccept_with_incorrect_auth</Test_Case>
<Test_Case>Radius_Test_new.tc_RADIUS_client_sendAccessRequest</Test_Case>
<Test_Case>Radius_Test_new.tc_RADIUS_client_sendAccessRequest_receiveAccessAccept</Test_Case>
<Test_Case>Radius_Test_new.tc_RADIUS_client_sendAccessAccept</Test_Case>
<Test_Case>Radius_Test_new.tc_RADIUS_client_sendAccountingRequest_receiveAccountingResponse</Test_Case>
<Test_Case>Radius_Test_new.tc_RADIUS_server_receiveAccessRequest_sendAccessAccept</Test_Case>
<Test_Case>Radius_Test_new.tc_RADIUS_server_receiveAccessRequest_sendAccessChallenge</Test_Case>
<Test_Case>Radius_Test_new.tc_RADIUS_server_receiveAccountingRequest_sendAccountingResponse</Test_Case>
</Test_Cases>
<Others>
<Other>gui_make_RPMG_new.sh</Other>
<Other>../src/ATTR.awk</Other>
<Other>../src/IPv6_IETF_RFC3162.rdf</Other>
<Other>../src/Base_IETF_RFC2865.rdf</Other>
<Other>../src/BaseTypes_IETF_RFC2865.rdf</Other>
<Other>../src/Extensions_IETF_RFC2869.rdf</Other>
<Other>../src/TunnelAuthentication_IETF_RFC2868.rdf</Other>
<Other>../src/Extensions_IETF_RFC2869.rdf</Other>
<Other>../src/GGSN_FS_46_15517_CSA113_35_4RevB.rdf</Other>
<Other>../src/Accounting_IETF_RFC2866_RFC2867.rdf</Other>
</Others>
<File_Group name="MainFileGroup" />
</Project>
<!DOCTYPE TITAN_GUI_project_file>
<Project TITAN_version="1.8.pl2" >
<General>
<Project_Name>RADIUS_Demo_orig</Project_Name>
<Executable_Path>myTest</Executable_Path>
<Working_Dir>.</Working_Dir>
<Build_Host>alpha</Build_Host>
<Execution_Mode>Parallel</Execution_Mode>
<Code_Splitting_Mode>None</Code_Splitting_Mode>
<ScriptFile_AfterMake>gui_make_RPMG_orig.sh</ScriptFile_AfterMake>
<Log_Format>yes</Log_Format>
<Update_Symlinks>yes</Update_Symlinks>
<Create_Absolute_Symlinks>no</Create_Absolute_Symlinks>
<Update_Makefile>yes</Update_Makefile>
<Localhost_Execute>yes</Localhost_Execute>
<Execute_Command>rsh %host &quot;cd %project_working_dir ; &quot;%executable&quot; %localhost %mctr_port&quot;</Execute_Command>
<Execute_Hosts>alfa, beta, gamma</Execute_Hosts>
<UnUsed_List></UnUsed_List>
</General>
<Modules>
<Module>../../../TestPorts/UDPasp_CNL113346/src/UDPasp_PortType.ttcn</Module>
<Module>../../../TestPorts/UDPasp_CNL113346/src/UDPasp_Types.ttcn</Module>
<Module>RADIUS_Mapping_orig.ttcn</Module>
<Module>Radius_Test_orig.ttcn</Module>
</Modules>
<TestPorts>
<TestPort>../../../TestPorts/UDPasp_CNL113346/src/UDPasp_PT.cc</TestPort>
<TestPort>../../../TestPorts/UDPasp_CNL113346/src/UDPasp_PT.hh</TestPort>
</TestPorts>
<Other_Sources>
<Other_Source>../src/RADIUS_EncDec.cc</Other_Source>
</Other_Sources>
<Configs>
<Config>radius.cfg</Config>
</Configs>
<Test_Cases>
<Test_Case>Radius_Test_orig.tc_RADIUS_server_receiveAccessRequest_sendAccessAccept_with_correct_auth</Test_Case>
<Test_Case>Radius_Test_orig.tc_RADIUS_server_receiveAccessRequest_sendAccessAccept_with_incorrect_auth</Test_Case>
<Test_Case>Radius_Test_orig.tc_RADIUS_client_sendAccessRequest</Test_Case>
<Test_Case>Radius_Test_orig.tc_RADIUS_client_sendAccessRequest_receiveAccessAccept</Test_Case>
<Test_Case>Radius_Test_orig.tc_RADIUS_client_sendAccessAccept</Test_Case>
<Test_Case>Radius_Test_orig.tc_RADIUS_client_sendAccountingRequest_receiveAccountingResponse</Test_Case>
<Test_Case>Radius_Test_orig.tc_RADIUS_server_receiveAccessRequest_sendAccessAccept</Test_Case>
<Test_Case>Radius_Test_orig.tc_RADIUS_server_receiveAccessRequest_sendAccessChallenge</Test_Case>
<Test_Case>Radius_Test_orig.tc_RADIUS_server_receiveAccountingRequest_sendAccountingResponse</Test_Case>
</Test_Cases>
<Others>
<Other>gui_make_RPMG_orig.sh</Other>
<Other>../src/ATTR.awk</Other>
<Other>../src/IPv6_IETF_RFC3162.rdf</Other>
<Other>../src/Base_IETF_RFC2865.rdf</Other>
<Other>../src/BaseTypes_IETF_RFC2865.rdf</Other>
<Other>../src/Extensions_IETF_RFC2869.rdf</Other>
<Other>../src/TunnelAuthentication_IETF_RFC2868.rdf</Other>
<Other>../src/Extensions_IETF_RFC2869.rdf</Other>
<Other>../src/GGSN_FS_46_15517_CSA113_35_4RevB.rdf</Other>
<Other>../src/Accounting_IETF_RFC2866_RFC2867.rdf</Other>
</Others>
<File_Group name="MainFileGroup" />
</Project>
/******************************************************************************
* Copyright (c) 2008, 2015 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Timea Moder
* Endre Kulcsar
* Gabor Szalai
* Janos Kovesdi
* Kulcsr Endre
* Zoltan Medve
* Tamas Korosi
******************************************************************************/
//
// File: RADIUS_Mapping_new.ttcn
// Description: Example module providing UDP Mapping for RPMG
// Rev: R12A
// Prodnr: CNL 113 600
// Remark: This file is not a part of the product.
//
//
//
module RADIUS_Mapping_new
{
import from RADIUS_Types all;
import from UDPasp_Types all;
import from UDPasp_PortType all;
modulepar{
charstring tsp_SharedSecret := "sharedSecret"
}
type record ASP_UDP_RADIUS {
PDU_RADIUS data,
AddressType addressf,
PortType portf
}
type port UDPasp_RADIUS_PT message {
inout ASP_UDP_RADIUS
} with {extension "internal"}
type component RADIUS_mapping_CT {
var RADIUS_port_descriptor v_RADIUS_port_descriptor;
port UDPasp_RADIUS_PT UDP_RADIUS_PCO; // upper port
port UDPasp_PT UDP_PCO; // lower port
}
template ASP_UDP t_ASP_UDP := ?;
template ASP_UDP_RADIUS t_ASP_UDP_RADIUS := ?;
type record of vsa_descriptor vsa_descriptor_list;
type record vsa_descriptor {
integer vendor_id,
integer_list subattr_types
}
//================================================================
// Types from RADIUS test port, info needed for external functions
//================================================================
type record RADIUS_port_descriptor {
boolean global_keying, // if this is set to true, 256 will be used instead of EAP Identifier
charstring secret,
integer mode,
octetstring req_auth[256],
octetstring req_acct[256],
boolean debugging
}
type record of integer integer_list;
type enumerated generic_attrib_value_union_selection {
unbound,
text_val,
string_val,
address_val,
integer_val,
time_val
}
type enumerated RADIUS_Mode {client, server};
//================================================================
//================================================================
//================================================================
// Sending in Server mode
// -- Access_Accept or
// -- Access_Reject or
// -- Access_Challenge or
// -- Accounting_Response
// == Disconnect_Request == NOT HANDLED
function f_handle_outgoing_server_message(in ASP_UDP_RADIUS pl_ASP_UDP_RADIUS) runs on RADIUS_mapping_CT {
if (pl_ASP_UDP_RADIUS.data.code == Access_Accept)
{
if (pl_ASP_UDP_RADIUS.data.authenticator == '00000000000000000000000000000000'O)
{
if (isvalue(v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier]))
{
var octetstring v_RADIUS_encoded := f_RADIUS_Enc(pl_ASP_UDP_RADIUS.data);
pl_ASP_UDP_RADIUS.data.authenticator :=
f_calc_MD5(
substr(v_RADIUS_encoded,0,4)
& v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(v_RADIUS_encoded,20,(lengthof(v_RADIUS_encoded)-20))
& char2oct(tsp_SharedSecret));
}
}
f_encode_send(pl_ASP_UDP_RADIUS)
}
else if (pl_ASP_UDP_RADIUS.data.code == Access_Reject)
{
if (pl_ASP_UDP_RADIUS.data.authenticator == '00000000000000000000000000000000'O)
{
if (isvalue(v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier]))
{
var octetstring v_RADIUS_encoded := f_RADIUS_Enc(pl_ASP_UDP_RADIUS.data);
pl_ASP_UDP_RADIUS.data.authenticator :=
f_calc_MD5(
substr(v_RADIUS_encoded,0,4)
& v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(v_RADIUS_encoded,20,(lengthof(v_RADIUS_encoded)-20))
& char2oct(tsp_SharedSecret));
}
}
f_encode_send(pl_ASP_UDP_RADIUS)
}
else if (pl_ASP_UDP_RADIUS.data.code == Access_Challenge)
{
if (pl_ASP_UDP_RADIUS.data.authenticator == '00000000000000000000000000000000'O)
{
if (isvalue(v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier]))
{
var octetstring v_RADIUS_encoded := f_RADIUS_Enc(pl_ASP_UDP_RADIUS.data);
pl_ASP_UDP_RADIUS.data.authenticator :=
f_calc_MD5(
substr(v_RADIUS_encoded,0,4)
& v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(v_RADIUS_encoded,20,(lengthof(v_RADIUS_encoded)-20))
& char2oct(tsp_SharedSecret));
}
}
f_encode_send(pl_ASP_UDP_RADIUS)
}
else if (pl_ASP_UDP_RADIUS.data.code == Accounting_Response)
{
if (pl_ASP_UDP_RADIUS.data.authenticator == '00000000000000000000000000000000'O)
{
if (isvalue(v_RADIUS_port_descriptor.req_acct[pl_ASP_UDP_RADIUS.data.identifier]))
{
var octetstring v_RADIUS_encoded := f_RADIUS_Enc(pl_ASP_UDP_RADIUS.data);
pl_ASP_UDP_RADIUS.data.authenticator :=
f_calc_MD5(
substr(v_RADIUS_encoded,0,4)
& v_RADIUS_port_descriptor.req_acct[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(v_RADIUS_encoded,20,(lengthof(v_RADIUS_encoded)-20))
& char2oct(tsp_SharedSecret));
}
}
f_encode_send(pl_ASP_UDP_RADIUS)
}
else {log("Warning : Will not send out Radius message with code ", pl_ASP_UDP_RADIUS.data.code, " in Server mode!") }
}
// Sending in Client mode
// -- Access_Request or
// -- Accounting_Request
// == Access_Challenge == NOT HANDLED
// == Disconnect_Ack == NOT HANDLED
// == Disconnect_Nak == NOT HANDLED
function f_handle_outgoing_client_message(in ASP_UDP_RADIUS pl_ASP_UDP_RADIUS) runs on RADIUS_mapping_CT {
if (pl_ASP_UDP_RADIUS.data.code == Access_Request)
{
// fill out authenticator with random number if template has 0s
if (pl_ASP_UDP_RADIUS.data.authenticator == '00000000000000000000000000000000'O)
{
var integer i;
for ( i := 0; i < 16; i := i+1)
{
pl_ASP_UDP_RADIUS.data.authenticator[i] := int2oct(float2int(int2float(256)*rnd()),1)
}
}
v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] := pl_ASP_UDP_RADIUS.data.authenticator;
// Calulate hidden password
var integer j := 0;
while (j < sizeof(pl_ASP_UDP_RADIUS.data.attributes))
{
if (pl_ASP_UDP_RADIUS.data.attributes[j].genericAttrib.attrib_type==Base_User_Password)
{
var integer v_pw_len :=lengthof(pl_ASP_UDP_RADIUS.data.attributes[j].genericAttrib.attrib_data.base_user_password);
var integer v_padding_length := 16 - (v_pw_len mod 16);
var octetstring v_padded_password :=
pl_ASP_UDP_RADIUS.data.attributes[j].genericAttrib.attrib_data.base_user_password & int2oct(0,v_padding_length)
var octetstring v_hidden_password := f_calculate_password(
v_padded_password,
pl_ASP_UDP_RADIUS.data.authenticator,
false
);
pl_ASP_UDP_RADIUS.data.attributes[j].genericAttrib.attrib_data.base_user_password := v_hidden_password;
j := sizeof(pl_ASP_UDP_RADIUS.data.attributes) // stop while loop
}
j := j + 1;
}
f_encode_send(pl_ASP_UDP_RADIUS);
}
else if (pl_ASP_UDP_RADIUS.data.code == Accounting_Request)
{
if (pl_ASP_UDP_RADIUS.data.authenticator == '00000000000000000000000000000000'O)
{
pl_ASP_UDP_RADIUS.data.authenticator := f_calc_MD5(f_RADIUS_Enc(pl_ASP_UDP_RADIUS.data) & char2oct(tsp_SharedSecret));
}
v_RADIUS_port_descriptor.req_acct[pl_ASP_UDP_RADIUS.data.identifier] := pl_ASP_UDP_RADIUS.data.authenticator;
f_encode_send(pl_ASP_UDP_RADIUS);
}
else {log("Warning : Will not send out Radius message with code ", pl_ASP_UDP_RADIUS.data.code, " in Client mode!") }
}
// -- Access_Accept or
// -- Access_Reject or
// -- Access_Challenge or
// -- Accounting_Response
// == Disconnect_Request == NOT HANDLED
function f_handle_incoming_server_message(in ASP_UDP_RADIUS pl_ASP_UDP_RADIUS, octetstring pl_asp_udp_data) runs on RADIUS_mapping_CT {
if (pl_ASP_UDP_RADIUS.data.code == Access_Accept)
{
UDP_RADIUS_PCO.send(pl_ASP_UDP_RADIUS);
var octetstring v_calc_auth := f_calc_MD5(
substr(pl_asp_udp_data,0,4)
& v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(pl_asp_udp_data,20, lengthof(pl_asp_udp_data)-20)
& char2oct(tsp_SharedSecret))
if (v_calc_auth != pl_ASP_UDP_RADIUS.data.authenticator)
{ log("Warning : Unexpected authentication value received in message with code ", pl_ASP_UDP_RADIUS.data.code) }
}
else if (pl_ASP_UDP_RADIUS.data.code == Access_Reject)
{
UDP_RADIUS_PCO.send(pl_ASP_UDP_RADIUS);
var octetstring v_calc_auth := f_calc_MD5(
substr(pl_asp_udp_data,0,4)
& v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(pl_asp_udp_data,20, lengthof(pl_asp_udp_data)-20)
& char2oct(tsp_SharedSecret))
if (v_calc_auth != pl_ASP_UDP_RADIUS.data.authenticator)
{ log("Warning : Unexpected authentication value received in message with code ", pl_ASP_UDP_RADIUS.data.code) }
}
else if (pl_ASP_UDP_RADIUS.data.code == Access_Challenge)
{
UDP_RADIUS_PCO.send(pl_ASP_UDP_RADIUS);
var octetstring v_calc_auth := f_calc_MD5(
substr(pl_asp_udp_data,0,4)
& v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(pl_asp_udp_data,20, lengthof(pl_asp_udp_data)-20)
& char2oct(tsp_SharedSecret))
if (v_calc_auth != pl_ASP_UDP_RADIUS.data.authenticator)
{ log("Warning : Unexpected authentication value received in message with code ", pl_ASP_UDP_RADIUS.data.code) }
}
else if (pl_ASP_UDP_RADIUS.data.code == Accounting_Response)
{
UDP_RADIUS_PCO.send(pl_ASP_UDP_RADIUS);
var octetstring v_calc_auth := f_calc_MD5(
substr(pl_asp_udp_data,0,4)
& v_RADIUS_port_descriptor.req_acct[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(pl_asp_udp_data,20, lengthof(pl_asp_udp_data)-20)
& char2oct(tsp_SharedSecret))
if (v_calc_auth != pl_ASP_UDP_RADIUS.data.authenticator)
{ log("Warning : Unexpected authentication value received in message with code ", pl_ASP_UDP_RADIUS.data.code) }
}
else {log("Warning : Unexpected message with code ", pl_ASP_UDP_RADIUS.data.code, " received in Client mode") }
}
// Access_Request or
// Accounting_Request
// == Access_Challenge == NOT HANDLED
// == Disconnect_Ack == NOT HANDLED
// == Disconnect_Nak == NOT HANDLED
function f_handle_incoming_client_message(in ASP_UDP_RADIUS pl_ASP_UDP_RADIUS,octetstring pl_asp_udp_data) runs on RADIUS_mapping_CT {
if (pl_ASP_UDP_RADIUS.data.code == Access_Request)
{
// Calulate password from hidden password
var integer j := 0;
while (j < sizeof(pl_ASP_UDP_RADIUS.data.attributes))
{
if (pl_ASP_UDP_RADIUS.data.attributes[j].genericAttrib.attrib_type==Base_User_Password)
{
var octetstring v_padded_password := f_calculate_password(
pl_ASP_UDP_RADIUS.data.attributes[j].genericAttrib.attrib_data.base_user_password,
pl_ASP_UDP_RADIUS.data.authenticator,
true
);
var integer v_padding_length := 0;
while (v_padded_password[lengthof(v_padded_password) - v_padding_length - 1] == '00'O)
{
v_padding_length := v_padding_length + 1;
}
var octetstring v_password:= substr (v_padded_password,0,lengthof(v_padded_password) - v_padding_length);
pl_ASP_UDP_RADIUS.data.attributes[j].genericAttrib.attrib_data.base_user_password := v_password;
j := sizeof(pl_ASP_UDP_RADIUS.data.attributes) // stop while loop
}
j := j + 1;
}
UDP_RADIUS_PCO.send(pl_ASP_UDP_RADIUS);
v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] := pl_ASP_UDP_RADIUS.data.authenticator // store value
}
else if (pl_ASP_UDP_RADIUS.data.code == Accounting_Request)
{
UDP_RADIUS_PCO.send(pl_ASP_UDP_RADIUS);
v_RADIUS_port_descriptor.req_acct[pl_ASP_UDP_RADIUS.data.identifier] := pl_ASP_UDP_RADIUS.data.authenticator // store value
var octetstring v_calc_auth := f_calc_MD5(
substr(pl_asp_udp_data,0,4)
& '00000000000000000000000000000000'O
& substr(pl_asp_udp_data,20, lengthof(pl_asp_udp_data)-20)
& char2oct(tsp_SharedSecret)
)
if (v_calc_auth != pl_ASP_UDP_RADIUS.data.authenticator)
{ log("Warning : Unexpected authentication value received in message with code ", pl_ASP_UDP_RADIUS.data.code) }
}
else {log("Warning : Unexpected message with code ", pl_ASP_UDP_RADIUS.data.code, " received in Server mode")}
}
// Encrypts Password field in Access Request using Request Authentication
// field and shared secret (modulepar)
function f_calculate_password( octetstring pl_password,octetstring pl_authenticatior, boolean pl_decrypt) runs on RADIUS_mapping_CT return octetstring{
return f_crypt_password (pl_password,pl_authenticatior,''O,pl_decrypt,tsp_SharedSecret) // false = encode, true = decode
}
function f_encode_send(in ASP_UDP_RADIUS pl_ASP_UDP_RADIUS) runs on RADIUS_mapping_CT {
var ASP_UDP v_asp_udp;
v_asp_udp.data := f_RADIUS_Enc(pl_ASP_UDP_RADIUS.data);
v_asp_udp.addressf := pl_ASP_UDP_RADIUS.addressf;
v_asp_udp.portf := pl_ASP_UDP_RADIUS.portf;
UDP_PCO.send(v_asp_udp);
}
//function f_store_RequestAuth_Field
//function f_store_last
function f_RADIUS_EncDec_Start(RADIUS_Mode pl_RADIUS_Mode) runs on RADIUS_mapping_CT {
var ASP_UDP_RADIUS v_asp_udp_radius;
var ASP_UDP v_asp_udp;
while (true) {
alt {
/////////////////////////////////
// incoming messages on upper port
/////////////////////////////////
[] UDP_RADIUS_PCO.receive(t_ASP_UDP_RADIUS) -> value v_asp_udp_radius {
if (pl_RADIUS_Mode == server) {
f_handle_outgoing_server_message(v_asp_udp_radius)
}
else { // client mode
f_handle_outgoing_client_message(v_asp_udp_radius)
}
}
/////////////////////////////////
// incoming messages on lower port
/////////////////////////////////
[] UDP_PCO.receive(t_ASP_UDP) -> value v_asp_udp {
v_asp_udp_radius.data := f_RADIUS_Dec(v_asp_udp.data);
v_asp_udp_radius.addressf := v_asp_udp.addressf;
v_asp_udp_radius.portf := v_asp_udp.portf;
if (pl_RADIUS_Mode == server) {
f_handle_incoming_client_message(v_asp_udp_radius,v_asp_udp.data)
}
else { // client mode
f_handle_incoming_server_message(v_asp_udp_radius,v_asp_udp.data)
}
}
}
}
}
} // end of module
/******************************************************************************
* Copyright (c) 2008, 2015 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Timea Moder
* Endre Kulcsar
* Gabor Szalai
* Janos Kovesdi
* Kulcsr Endre
* Zoltan Medve
* Tamas Korosi
******************************************************************************/
//
// File: RADIUS_Mapping_orig.ttcn
// Description: Example module providing UDP Mapping for RPMG
// Rev: R12A
// Prodnr: CNL 113 600
// Remark: This file is not a part of the product.
//
//
//
module RADIUS_Mapping_orig
{
import from RADIUS_Types all;
import from UDPasp_Types all;
import from UDPasp_PortType all;
modulepar{
charstring tsp_SharedSecret := "sharedSecret"
}
type record ASP_UDP_RADIUS {
PDU_RADIUS data,
AddressType addressf,
PortType portf
}
type port UDPasp_RADIUS_PT message {
inout ASP_UDP_RADIUS
} with {extension "internal"}
type component RADIUS_mapping_CT {
var RADIUS_port_descriptor v_RADIUS_port_descriptor;
port UDPasp_RADIUS_PT UDP_RADIUS_PCO; // upper port
port UDPasp_PT UDP_PCO; // lower port
}
template ASP_UDP t_ASP_UDP := ?;
template ASP_UDP_RADIUS t_ASP_UDP_RADIUS := ?;
type record of vsa_descriptor vsa_descriptor_list;
type record vsa_descriptor {
integer vendor_id,
integer_list subattr_types
}
//================================================================
// Types from RADIUS test port, info needed for external functions
//================================================================
type record RADIUS_port_descriptor {
boolean global_keying, // if this is set to true, 256 will be used instead of EAP Identifier
charstring secret,
integer mode,
octetstring req_auth[256],
octetstring req_acct[256],
boolean debugging
}
type record of integer integer_list;
type enumerated generic_attrib_value_union_selection {
unbound,
text_val,
string_val,
address_val,
integer_val,
time_val
}
type enumerated RADIUS_Mode {client, server};
//================================================================
//================================================================
//================================================================
// Sending in Server mode
// -- Access_Accept or
// -- Access_Reject or
// -- Access_Challenge or
// -- Accounting_Response
// == Disconnect_Request == NOT HANDLED
function f_handle_outgoing_server_message(in ASP_UDP_RADIUS pl_ASP_UDP_RADIUS) runs on RADIUS_mapping_CT {
if (pl_ASP_UDP_RADIUS.data.code == Access_Accept)
{
if (pl_ASP_UDP_RADIUS.data.authenticator == '00000000000000000000000000000000'O)
{
if (isvalue(v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier]))
{
var octetstring v_RADIUS_encoded := f_RADIUS_Enc(pl_ASP_UDP_RADIUS.data);
pl_ASP_UDP_RADIUS.data.authenticator :=
f_calc_MD5(
substr(v_RADIUS_encoded,0,4)
& v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(v_RADIUS_encoded,20,(lengthof(v_RADIUS_encoded)-20))
& char2oct(tsp_SharedSecret));
}
}
f_encode_send(pl_ASP_UDP_RADIUS)
}
else if (pl_ASP_UDP_RADIUS.data.code == Access_Reject)
{
if (pl_ASP_UDP_RADIUS.data.authenticator == '00000000000000000000000000000000'O)
{
if (isvalue(v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier]))
{
var octetstring v_RADIUS_encoded := f_RADIUS_Enc(pl_ASP_UDP_RADIUS.data);
pl_ASP_UDP_RADIUS.data.authenticator :=
f_calc_MD5(
substr(v_RADIUS_encoded,0,4)
& v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(v_RADIUS_encoded,20,(lengthof(v_RADIUS_encoded)-20))
& char2oct(tsp_SharedSecret));
}
}
f_encode_send(pl_ASP_UDP_RADIUS)
}
else if (pl_ASP_UDP_RADIUS.data.code == Access_Challenge)
{
if (pl_ASP_UDP_RADIUS.data.authenticator == '00000000000000000000000000000000'O)
{
if (isvalue(v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier]))
{
var octetstring v_RADIUS_encoded := f_RADIUS_Enc(pl_ASP_UDP_RADIUS.data);
pl_ASP_UDP_RADIUS.data.authenticator :=
f_calc_MD5(
substr(v_RADIUS_encoded,0,4)
& v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(v_RADIUS_encoded,20,(lengthof(v_RADIUS_encoded)-20))
& char2oct(tsp_SharedSecret));
}
}
f_encode_send(pl_ASP_UDP_RADIUS)
}
else if (pl_ASP_UDP_RADIUS.data.code == Accounting_Response)
{
if (pl_ASP_UDP_RADIUS.data.authenticator == '00000000000000000000000000000000'O)
{
if (isvalue(v_RADIUS_port_descriptor.req_acct[pl_ASP_UDP_RADIUS.data.identifier]))
{
var octetstring v_RADIUS_encoded := f_RADIUS_Enc(pl_ASP_UDP_RADIUS.data);
pl_ASP_UDP_RADIUS.data.authenticator :=
f_calc_MD5(
substr(v_RADIUS_encoded,0,4)
& v_RADIUS_port_descriptor.req_acct[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(v_RADIUS_encoded,20,(lengthof(v_RADIUS_encoded)-20))
& char2oct(tsp_SharedSecret));
}
}
f_encode_send(pl_ASP_UDP_RADIUS)
}
else {log("Warning : Will not send out Radius message with code ", pl_ASP_UDP_RADIUS.data.code, " in Server mode!") }
}
// Sending in Client mode
// -- Access_Request or
// -- Accounting_Request
// == Access_Challenge == NOT HANDLED
// == Disconnect_Ack == NOT HANDLED
// == Disconnect_Nak == NOT HANDLED
function f_handle_outgoing_client_message(in ASP_UDP_RADIUS pl_ASP_UDP_RADIUS) runs on RADIUS_mapping_CT {
if (pl_ASP_UDP_RADIUS.data.code == Access_Request)
{
// fill out authenticator with random number if template has 0s
if (pl_ASP_UDP_RADIUS.data.authenticator == '00000000000000000000000000000000'O)
{
var integer i;
for ( i := 0; i < 16; i := i+1)
{
pl_ASP_UDP_RADIUS.data.authenticator[i] := int2oct(float2int(int2float(256)*rnd()),1)
}
}
v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] := pl_ASP_UDP_RADIUS.data.authenticator;
// Calulate hidden password
var integer j := 0;
while (j < sizeof(pl_ASP_UDP_RADIUS.data.attributes))
{
if (ischosen(pl_ASP_UDP_RADIUS.data.attributes[j].attrib_Base_User_Password))
{
var integer v_pw_len :=lengthof(pl_ASP_UDP_RADIUS.data.attributes[j].attrib_Base_User_Password.base_user_password);
var integer v_padding_length := 16 - (v_pw_len mod 16);
var octetstring v_padded_password :=
pl_ASP_UDP_RADIUS.data.attributes[j].attrib_Base_User_Password.base_user_password & int2oct(0,v_padding_length)
var octetstring v_hidden_password := f_calculate_password(
v_padded_password,
pl_ASP_UDP_RADIUS.data.authenticator,
false
);
pl_ASP_UDP_RADIUS.data.attributes[j].attrib_Base_User_Password.base_user_password := v_hidden_password;
j := sizeof(pl_ASP_UDP_RADIUS.data.attributes) // stop while loop
}
j := j + 1;
}
f_encode_send(pl_ASP_UDP_RADIUS);
}
else if (pl_ASP_UDP_RADIUS.data.code == Accounting_Request)
{
if (pl_ASP_UDP_RADIUS.data.authenticator == '00000000000000000000000000000000'O)
{
pl_ASP_UDP_RADIUS.data.authenticator := f_calc_MD5(f_RADIUS_Enc(pl_ASP_UDP_RADIUS.data) & char2oct(tsp_SharedSecret));
}
v_RADIUS_port_descriptor.req_acct[pl_ASP_UDP_RADIUS.data.identifier] := pl_ASP_UDP_RADIUS.data.authenticator;
f_encode_send(pl_ASP_UDP_RADIUS);
}
else {log("Warning : Will not send out Radius message with code ", pl_ASP_UDP_RADIUS.data.code, " in Client mode!") }
}
// -- Access_Accept or
// -- Access_Reject or
// -- Access_Challenge or
// -- Accounting_Response
// == Disconnect_Request == NOT HANDLED
function f_handle_incoming_server_message(in ASP_UDP_RADIUS pl_ASP_UDP_RADIUS, octetstring pl_asp_udp_data) runs on RADIUS_mapping_CT {
if (pl_ASP_UDP_RADIUS.data.code == Access_Accept)
{
UDP_RADIUS_PCO.send(pl_ASP_UDP_RADIUS);
var octetstring v_calc_auth := f_calc_MD5(
substr(pl_asp_udp_data,0,4)
& v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(pl_asp_udp_data,20, lengthof(pl_asp_udp_data)-20)
& char2oct(tsp_SharedSecret))
if (v_calc_auth != pl_ASP_UDP_RADIUS.data.authenticator)
{ log("Warning : Unexpected authentication value received in message with code ", pl_ASP_UDP_RADIUS.data.code) }
}
else if (pl_ASP_UDP_RADIUS.data.code == Access_Reject)
{
UDP_RADIUS_PCO.send(pl_ASP_UDP_RADIUS);
var octetstring v_calc_auth := f_calc_MD5(
substr(pl_asp_udp_data,0,4)
& v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(pl_asp_udp_data,20, lengthof(pl_asp_udp_data)-20)
& char2oct(tsp_SharedSecret))
if (v_calc_auth != pl_ASP_UDP_RADIUS.data.authenticator)
{ log("Warning : Unexpected authentication value received in message with code ", pl_ASP_UDP_RADIUS.data.code) }
}
else if (pl_ASP_UDP_RADIUS.data.code == Access_Challenge)
{
UDP_RADIUS_PCO.send(pl_ASP_UDP_RADIUS);
var octetstring v_calc_auth := f_calc_MD5(
substr(pl_asp_udp_data,0,4)
& v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(pl_asp_udp_data,20, lengthof(pl_asp_udp_data)-20)
& char2oct(tsp_SharedSecret))
if (v_calc_auth != pl_ASP_UDP_RADIUS.data.authenticator)
{ log("Warning : Unexpected authentication value received in message with code ", pl_ASP_UDP_RADIUS.data.code) }
}
else if (pl_ASP_UDP_RADIUS.data.code == Accounting_Response)
{
UDP_RADIUS_PCO.send(pl_ASP_UDP_RADIUS);
var octetstring v_calc_auth := f_calc_MD5(
substr(pl_asp_udp_data,0,4)
& v_RADIUS_port_descriptor.req_acct[pl_ASP_UDP_RADIUS.data.identifier] // stored value
& substr(pl_asp_udp_data,20, lengthof(pl_asp_udp_data)-20)
& char2oct(tsp_SharedSecret))
if (v_calc_auth != pl_ASP_UDP_RADIUS.data.authenticator)
{ log("Warning : Unexpected authentication value received in message with code ", pl_ASP_UDP_RADIUS.data.code) }
}
else {log("Warning : Unexpected message with code ", pl_ASP_UDP_RADIUS.data.code, " received in Client mode") }
}
// Access_Request or
// Accounting_Request
// == Access_Challenge == NOT HANDLED
// == Disconnect_Ack == NOT HANDLED
// == Disconnect_Nak == NOT HANDLED
function f_handle_incoming_client_message(in ASP_UDP_RADIUS pl_ASP_UDP_RADIUS,octetstring pl_asp_udp_data) runs on RADIUS_mapping_CT {
if (pl_ASP_UDP_RADIUS.data.code == Access_Request)
{
// Calulate password from hidden password
var integer j := 0;
while (j < sizeof(pl_ASP_UDP_RADIUS.data.attributes))
{
if (ischosen(pl_ASP_UDP_RADIUS.data.attributes[j].attrib_Base_User_Password))
{
var octetstring v_padded_password := f_calculate_password(
pl_ASP_UDP_RADIUS.data.attributes[j].attrib_Base_User_Password.base_user_password,
pl_ASP_UDP_RADIUS.data.authenticator,
true
);
var integer v_padding_length := 0;
while (v_padded_password[lengthof(v_padded_password) - v_padding_length - 1] == '00'O)
{
v_padding_length := v_padding_length + 1;
}
var octetstring v_password:= substr (v_padded_password,0,lengthof(v_padded_password) - v_padding_length);
pl_ASP_UDP_RADIUS.data.attributes[j].attrib_Base_User_Password.base_user_password := v_password;
j := sizeof(pl_ASP_UDP_RADIUS.data.attributes) // stop while loop
}
j := j + 1;
}
UDP_RADIUS_PCO.send(pl_ASP_UDP_RADIUS);
v_RADIUS_port_descriptor.req_auth[pl_ASP_UDP_RADIUS.data.identifier] := pl_ASP_UDP_RADIUS.data.authenticator // store value
}
else if (pl_ASP_UDP_RADIUS.data.code == Accounting_Request)
{
UDP_RADIUS_PCO.send(pl_ASP_UDP_RADIUS);
v_RADIUS_port_descriptor.req_acct[pl_ASP_UDP_RADIUS.data.identifier] := pl_ASP_UDP_RADIUS.data.authenticator // store value
var octetstring v_calc_auth := f_calc_MD5(
substr(pl_asp_udp_data,0,4)
& '00000000000000000000000000000000'O
& substr(pl_asp_udp_data,20, lengthof(pl_asp_udp_data)-20)
& char2oct(tsp_SharedSecret)
)
if (v_calc_auth != pl_ASP_UDP_RADIUS.data.authenticator)
{ log("Warning : Unexpected authentication value received in message with code ", pl_ASP_UDP_RADIUS.data.code) }
}
else {log("Warning : Unexpected message with code ", pl_ASP_UDP_RADIUS.data.code, " received in Server mode")}
}
// Encrypts Password field in Access Request using Request Authentication
// field and shared secret (modulepar)
function f_calculate_password( octetstring pl_password,octetstring pl_authenticatior, boolean pl_decrypt) runs on RADIUS_mapping_CT return octetstring{
return f_crypt_password (pl_password,pl_authenticatior,''O,pl_decrypt,tsp_SharedSecret) // false = encode, true = decode
}
function f_encode_send(in ASP_UDP_RADIUS pl_ASP_UDP_RADIUS) runs on RADIUS_mapping_CT {
var ASP_UDP v_asp_udp;
v_asp_udp.data := f_RADIUS_Enc(pl_ASP_UDP_RADIUS.data);
v_asp_udp.addressf := pl_ASP_UDP_RADIUS.addressf;
v_asp_udp.portf := pl_ASP_UDP_RADIUS.portf;
UDP_PCO.send(v_asp_udp);
}
//function f_store_RequestAuth_Field
//function f_store_last
function f_RADIUS_EncDec_Start(RADIUS_Mode pl_RADIUS_Mode) runs on RADIUS_mapping_CT {
var ASP_UDP_RADIUS v_asp_udp_radius;
var ASP_UDP v_asp_udp;
while (true) {
alt {
/////////////////////////////////
// incoming messages on upper port
/////////////////////////////////
[] UDP_RADIUS_PCO.receive(t_ASP_UDP_RADIUS) -> value v_asp_udp_radius {
if (pl_RADIUS_Mode == server) {
f_handle_outgoing_server_message(v_asp_udp_radius)
}
else { // client mode
f_handle_outgoing_client_message(v_asp_udp_radius)
}
}
/////////////////////////////////
// incoming messages on lower port
/////////////////////////////////
[] UDP_PCO.receive(t_ASP_UDP) -> value v_asp_udp {
v_asp_udp_radius.data := f_RADIUS_Dec(v_asp_udp.data);
v_asp_udp_radius.addressf := v_asp_udp.addressf;
v_asp_udp_radius.portf := v_asp_udp.portf;
if (pl_RADIUS_Mode == server) {
f_handle_incoming_client_message(v_asp_udp_radius,v_asp_udp.data)
}
else { // client mode
f_handle_incoming_server_message(v_asp_udp_radius,v_asp_udp.data)
}
}
}
}
}
} // end of module
[MODULE_PARAMETERS]
tsp_addressf := "159.107.193.33"
tsp_portf := 1100
tsp_portf2 := 1101
#tsp_skip_auth_encr := true
[TESTPORT_PARAMETERS]
system.RADIUS_Port.localPort := "50000"
#system.RADIUS_Port.localPort := "10002"
system.RADIUS_ClientPort.localPort := "1101"
system.RADIUS_ServerPort.localPort := "1100"
[LOGGING]
FileMask := LOG_ALL | TTCN_DEBUG | TTCN_MATCHING
ConsoleMask := TTCN_ERROR | TTCN_WARNING | TTCN_TESTCASE | TTCN_STATISTICS | TTCN_PORTEVENT
SourceInfoFormat := Yes
[EXECUTE]
RadiusAndEAP_Demo.tc_RADIUS_EAP_AKA_full_authentication
RadiusAndEAP_Demo.tc_RADIUS_EAP_SIM_full_authentication
<!DOCTYPE TITAN_GUI_project_file>
<Project TITAN_version="1.8.pl2" >
<General>
<Project_Name>RADIUSandEAP_Demo</Project_Name>
<Executable_Path>myTest</Executable_Path>
<Working_Dir>.</Working_Dir>
<Build_Host>alpha</Build_Host>
<Execution_Mode>Parallel</Execution_Mode>
<Code_Splitting_Mode>None</Code_Splitting_Mode>
<ScriptFile_AfterMake>gui_make_RPMGandEAP.sh</ScriptFile_AfterMake>
<Log_Format>yes</Log_Format>
<Update_Symlinks>yes</Update_Symlinks>
<Create_Absolute_Symlinks>no</Create_Absolute_Symlinks>
<Update_Makefile>yes</Update_Makefile>
<Localhost_Execute>yes</Localhost_Execute>
<Execute_Command>rsh %host &quot;cd %project_working_dir ; &quot;%executable&quot; %localhost %mctr_port&quot;</Execute_Command>
<Execute_Hosts>alfa, beta, gamma</Execute_Hosts>
<UnUsed_List></UnUsed_List>
</General>
<Modules>
<Module>../../../TestPorts/UDPasp_CNL113346/src/UDPasp_PortType.ttcn</Module>
<Module>../../../TestPorts/UDPasp_CNL113346/src/UDPasp_Types.ttcn</Module>
<Module>RADIUSandEAP_Mapping.ttcn</Module>
<Module>RadiusAndEAP_Demo.ttcn</Module>
<Module>../../PPP_CNL113599/src/EAP_Types.ttcn</Module>
<Module>../../COMMON/src/General_Types.ttcn</Module>
</Modules>
<TestPorts>
<TestPort>../../../TestPorts/UDPasp_CNL113346/src/UDPasp_PT.cc</TestPort>
<TestPort>../../../TestPorts/UDPasp_CNL113346/src/UDPasp_PT.hh</TestPort>
</TestPorts>
<Other_Sources>
<Other_Source>../../PPP_CNL113599/src/EAP_EncDec.cc</Other_Source>
<Other_Source>../src/RADIUS_EncDec.cc</Other_Source>
</Other_Sources>
<Configs>
<Config>RADIUSandEAP.cfg</Config>
</Configs>
<Test_Cases>
<Test_Case>RadiusAndEAP_Demo.control</Test_Case>
<Test_Case>RadiusAndEAP_Demo.tc_RADIUS_EAP_AKA_full_authentication</Test_Case>
<Test_Case>RadiusAndEAP_Demo.tc_RADIUS_EAP_SIM_full_authentication</Test_Case>
<Test_Case>RadiusAndEAP_Demo.tc_RADIUS_EAP_SIM_reauthentication</Test_Case>
</Test_Cases>
<Others>
<Other>gui_make_RPMGandEAP.sh</Other>
<Other>../src/ATTR.awk</Other>
<Other>../src/IPv6_IETF_RFC3162.rdf</Other>
<Other>../src/Base_IETF_RFC2865.rdf</Other>
<Other>../src/BaseTypes_IETF_RFC2865.rdf</Other>
<Other>../src/Extensions_IETF_RFC2869.rdf</Other>
<Other>../src/TunnelAuthentication_IETF_RFC2868.rdf</Other>
<Other>../src/Extensions_IETF_RFC2869.rdf</Other>
<Other>../src/GGSN_FS_46_15517_CSA113_35_4RevB.rdf</Other>
<Other>../src/Accounting_IETF_RFC2866_RFC2867.rdf</Other>
<Other>../src/DynamicAuthorizationExtensions_IETF_RFC5176.rdf</Other>
</Others>
<File_Group name="MainFileGroup" />
</Project>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#!/bin/sh
sed -e '
s/OPENSSL_DIR = $(TTCN3_DIR)/\OPENSSL_DIR = \/mnt\/TTCN\/Tools\/openssl-0.9.8e/g
s/CPPFLAGS = -D$(PLATFORM) -I$(TTCN3_DIR)\/include/CPPFLAGS = -D$(PLATFORM) -I$(OPENSSL_DIR)\/include -I$(TTCN3_DIR)\/include/g
' \
-e 's/^TTCN3_MODULES =/TTCN3_MODULES = RADIUS_Types.ttcn/g
s/^GENERATED_SOURCES =/GENERATED_SOURCES = RADIUS_Types.cc/g
s/^GENERATED_HEADERS =/GENERATED_HEADERS = RADIUS_Types.hh/g
s/^OBJECTS =/OBJECTS = RADIUS_Types.o/g
/# Add your rules here if necessary./ {
a\
#
a\
a\
AWK=/usr/local/bin/gawk
a\
a\
RADIUS_Types.ttcn: BaseTypes_IETF_RFC2865.rdf Base_IETF_RFC2865.rdf Accounting_IETF_RFC2866_RFC2867.rdf IPv6_IETF_RFC3162.rdf Extensions_IETF_RFC2869.rdf TunnelAuthentication_IETF_RFC2868.rdf ATTR.awk
a\
$(AWK) -f ATTR.awk BaseTypes_IETF_RFC2865.rdf Base_IETF_RFC2865.rdf Accounting_IETF_RFC2866_RFC2867.rdf IPv6_IETF_RFC3162.rdf Extensions_IETF_RFC2869.rdf TunnelAuthentication_IETF_RFC2868.rdf > $@
a\
a\
#
a\
# End of additional rules for RPMG
}
' \
<$1 >$2
#!/bin/sh
sed -e '
s/OPENSSL_DIR = $(TTCN3_DIR)/\OPENSSL_DIR = \/mnt\/TTCN\/Tools\/openssl-0.9.8e/g
s/CPPFLAGS = -D$(PLATFORM) -I$(TTCN3_DIR)\/include/CPPFLAGS = -D$(PLATFORM) -I$(OPENSSL_DIR)\/include -I$(TTCN3_DIR)\/include/g
' \
-e 's/^TTCN3_MODULES =/TTCN3_MODULES = RADIUS_Types.ttcn/g
s/^GENERATED_SOURCES =/GENERATED_SOURCES = RADIUS_Types.cc/g
s/^GENERATED_HEADERS =/GENERATED_HEADERS = RADIUS_Types.hh/g
s/^OBJECTS =/OBJECTS = RADIUS_Types.o/g
/# Add your rules here if necessary./ {
a\
#
a\
a\
AWK=/usr/local/bin/gawk
a\
a\
RADIUS_Types.ttcn: BaseTypes_IETF_RFC2865.rdf Base_IETF_RFC2865.rdf Accounting_IETF_RFC2866_RFC2867.rdf IPv6_IETF_RFC3162.rdf Extensions_IETF_RFC2869.rdf TunnelAuthentication_IETF_RFC2868.rdf ATTR.awk
a\
$(AWK) -f ATTR.awk -v old_structured_code=1 BaseTypes_IETF_RFC2865.rdf Base_IETF_RFC2865.rdf Accounting_IETF_RFC2866_RFC2867.rdf IPv6_IETF_RFC3162.rdf Extensions_IETF_RFC2869.rdf TunnelAuthentication_IETF_RFC2868.rdf > $@
a\
a\
#
a\
# End of additional rules for RPMG
}
' \
<$1 >$2
#!/bin/sh
sed -e '
s/OPENSSL_DIR = $(TTCN3_DIR)/\OPENSSL_DIR = \/mnt\/TTCN\/Tools\/openssl-0.9.8e/g
s/CPPFLAGS = -D$(PLATFORM) -I$(TTCN3_DIR)\/include/CPPFLAGS = -D$(PLATFORM) -I$(OPENSSL_DIR)\/include -I$(TTCN3_DIR)\/include/g
' \
-e 's/^TTCN3_MODULES =/TTCN3_MODULES = RADIUS_Types.ttcn/g
s/^GENERATED_SOURCES =/GENERATED_SOURCES = RADIUS_Types.cc/g
s/^GENERATED_HEADERS =/GENERATED_HEADERS = RADIUS_Types.hh/g
s/^OBJECTS =/OBJECTS = RADIUS_Types.o/g
/# Add your rules here if necessary./ {
a\
#
a\
a\
AWK=/usr/local/bin/gawk
a\
a\
RADIUS_Types.ttcn: BaseTypes_IETF_RFC2865.rdf Base_IETF_RFC2865.rdf Accounting_IETF_RFC2866_RFC2867.rdf IPv6_IETF_RFC3162.rdf Extensions_IETF_RFC2869.rdf TunnelAuthentication_IETF_RFC2868.rdf DynamicAuthorizationExtensions_IETF_RFC5176.rdf ATTR.awk
a\
$(AWK) -f ATTR.awk BaseTypes_IETF_RFC2865.rdf Base_IETF_RFC2865.rdf Accounting_IETF_RFC2866_RFC2867.rdf IPv6_IETF_RFC3162.rdf Extensions_IETF_RFC2869.rdf TunnelAuthentication_IETF_RFC2868.rdf DynamicAuthorizationExtensions_IETF_RFC5176.rdf > $@
a\
a\
#
a\
# End of additional rules for RPMG
}
' \
<$1 >$2
[MODULE_PARAMETERS]
tsp_addressf := "159.107.193.33"
tsp_portf := 1100
[TESTPORT_PARAMETERS]
system.RADIUS_Port.localPort := "50000"
#system.RADIUS_Port.localPort := "10002"
[LOGGING]
/*LogFile := "UDPtest.log" */
FileMask := LOG_ALL | TTCN_DEBUG | TTCN_MATCHING
ConsoleMask := TTCN_ERROR | TTCN_WARNING | TTCN_TESTCASE | TTCN_STATISTICS | TTCN_PORTEVENT
LogSourceInfo := Yes
[EXECUTE]
#Radius_Test.tc_RADIUS_server_receiveAccessRequest_sendAccessAccept_with_correct_auth
#Radius_Test.tc_RADIUS_server_receiveAccessRequest_sendAccessAccept_with_incorrect_auth
#Radius_Test.tc_RADIUS_client_sendAccessRequest
#Radius_Test.tc_RADIUS_client_sendAccessRequest_receiveAccessAccept
#Radius_Test.tc_RADIUS_client_sendAccessAccept
#Radius_Test.tc_RADIUS_client_sendAccountingRequest_receiveAccountingResponse
Radius_Test.tc_RADIUS_server_receiveAccessRequest_sendAccessAccept
#Radius_Test.tc_RADIUS_server_receiveAccessRequest_sendAccessChallenge
#Radius_Test.tc_RADIUS_server_receiveAccountingRequest_sendAccountingResponse
File added
File added
#/******************************************************************************
#* Copyright (c) 2008, 2015 Ericsson AB
#* All rights reserved. This program and the accompanying materials
#* are made available under the terms of the Eclipse Public License v1.0
#* which accompanies this distribution, and is available at
#* http://www.eclipse.org/legal/epl-v10.html
#*
#* Contributors:
#* Timea Moder
#* Endre Kulcsar
#* Gabor Szalai
#* Janos Kovesdi
#* Kulcsr Endre
#* Zoltan Medve
#* Tamas Korosi
#******************************************************************************/
# #
# File: ATTR.awk #
# Description: RPMG AWK script for weaving RDF files #
# Rev: R12A
# Prodnr: CNL 113 600 #
#############################################################################
BEGIN {
FS = "[ \t\n;]+"
HT = " "
# Number of attribute descriptors found in input RDF file
attrib_descriptors = 0
packet_descriptors = 0
# Number of attribute type definitions matching preceeding attribute descriptor
matching_attrib_types = 0
matching_packet_types = 0
# Identifier of generated TTCN-3 module
if(!module_id) module_id = "RADIUS_Types"
# Use APPLICATION-REVISION prefix in Attrib type identifiers when true
if(!use_application_revision) use_application_revision = 0
# Replace all enumeration type Attribs with type Unsigned32 when true
if(!enum_2_UnsignedInt) enum_2_UnsignedInt = 0
# Generate original structured TTCN-3 code when true
if(!old_structured_code) old_structured_code = 0
print "module " module_id " {"
}
{
# Remove excess WS from beginning and end of EACH record
sub(/^[ \t]+/, "")
sub(/[ \t]+$/, "")
}
/\/\/ APPLICATION-NAME:/ {
# Will be used to prefix generated Attribute type definitions
application_id = $3
}
/\/\/ APPLICATION-REVISION:/ {
# Could be used as additional prefix for generated ATTR type definitions
application_revision = $3
if(use_application_revision && application_revision) {
application_id = application_id "_" application_revision
}
}
/\/\/ Packet-Type:/ {
# Packet descriptor line e.g.:
# // Packet: Official-Packet-Type (Official-Packet-Code)
# <-------- $3 ------> <------ $4 -------->
i = 1
while ((packet_code[i] != $4) && (i <= packet_descriptors)) {
i++
}
if (i > packet_descriptors) {
new_packet_type = $3
new_packet_code = $4
gsub(/-/, "_", new_packet_type)
packet_descriptors++
++matching_packet_types
packet_code[packet_descriptors] = new_packet_code
packet_type[matching_packet_types] = new_packet_type}
}
/\/\/ Attrib:/ {
# Attrib descriptor line e.g.:
# // Attrib: Official-Attrib-Name (Official-Attrib-Code)
# <-------- $3 ------> <------ $4 -------->
attrib_descriptors++
new_attrib_name = $3
new_attrib_code = $4
gsub(/-/, "_", new_attrib_name)
attrib_desc[new_attrib_name]=new_attrib_name
}
/\<type/ {
# TTCN-3 type definition e.g.:
# <type> <kind> <identifier> MUST be in same line!
if (($3 == new_attrib_name) && (new_attrib_code in ATTR))
{
print "// WARNING: Duplicated Attrib definition removed by gawk script!"
if($2 == "enumerated") { f_ReadTotalEnum() }
++deleted_attrib_types
next
}
else if($3 == new_attrib_name) {
$3 = application_id "_" new_attrib_name
++matching_attrib_types
ATTR[new_attrib_code] = new_attrib_name
attrib_code[matching_attrib_types] = new_attrib_code
attrib_type[matching_attrib_types] = application_id "_" new_attrib_name
if($2 == "enumerated") {
f_ReadTotalEnum()
if(enum_2_UnsignedInt) {
print "// WARNING: Enumeration type Attrib replaced by UnsignedInteger!"
print "type UINT32 " application_id "_" new_attrib_name ";"
}
else{
prettyprinted_enum = total_enum
gsub(/\,/, ",\n", prettyprinted_enum)
sub(/\{/, "{\n", prettyprinted_enum)
sub(/\}/, "\n}", prettyprinted_enum)
f_AddVariant_U32(prettyprinted_enum)
}
} else if ($2 ~ /^enum_[0-9]+$/) {
split($2, a, "_")
f_ReadTotalEnum()
if(enum_2_UnsignedInt) {
print "// WARNING: Enumeration type Attrib replaced by UnsignedInteger!"
print "type UINT" a[2] " " application_id "_" new_attrib_name ";"
}
else{
prettyprinted_enum = total_enum
gsub(/\,/, ",\n", prettyprinted_enum)
sub(/\{/, "{\n", prettyprinted_enum)
sub(/\}/, "\n}", prettyprinted_enum)
gsub(/enum_[0-9]*/, "enumerated ", prettyprinted_enum)
f_AddVariant_U(prettyprinted_enum, a[2])
}
}
} else if (($2 != "enumerated") && ($2 ~ /^enum_[0-9]+$/)) {
split($2, a, "_")
f_ReadTotalEnum()
if(enum_2_UnsignedInt) {
print "// WARNING: Enumeration type Attrib replaced by UnsignedInteger!"
print "type UINT" a[2] " " application_id "_" new_attrib_name ";"
}
else{
prettyprinted_enum = total_enum
gsub(/\,/, ",\n", prettyprinted_enum)
sub(/\{/, "{\n", prettyprinted_enum)
sub(/\}/, "\n}", prettyprinted_enum)
gsub(/enum_[0-9]*/, "enumerated ", prettyprinted_enum)
f_AddVariant_U(prettyprinted_enum, a[2])
}
}
}
/\/\/ Vendor:/ {
# Vendor descriptor line e.g.:
# // Vendor: vendor_name (vendor_id)
# <-- $3 --> <-- $4 -->
vendor_name = $3
gsub(/-/, "_", vendor_name)
vendor_list[vendor_name]=$4
}
{print}
END {
print "// STATISTICS: " attrib_descriptors " Attrib descriptors found"
print "// STATISTICS: " matching_attrib_types \
" Attrib type definitions matching Attrib descriptors found"
print "// STATISTICS: " deleted_attrib_types " duplicate Attrib definitions deleted"
if(attrib_descriptors != matching_attrib_types + deleted_attrib_types) {
print "// ERROR: attrib_descriptors " attrib_descriptors \
" != matching_attrib_types " matching_attrib_types
ss=1
for(t in attrib_type){
print ss " " attrib_type[t]
ss++
}
ss=1
print "\n"
for(t in attrib_desc){
print ss " " attrib_desc[t]
ss++
}
exit(1)
}
print "\n"
print "type record Attrib_UNKNOWN"
print "{"
print HT "UINT8 attrib_type,"
print HT "UINT8 attrib_length,"
print HT "octetstring attrib_value"
print "} with {"
print HT " variant (attrib_length) \"LENGTHTO(attrib_type, attrib_length, attrib_value)\""
print HT "}"
print "\n"
print "type record vendor_specific_type"
print "{"
print HT "vendor_id_enum vendor_id,"
print HT "string_val_spec attrib_value"
print "} with {"
print HT " variant (attrib_value) \"CROSSTAG("
for(vendor in vendor_list){
printf (HT HT "f_%s_subattr_list, vendor_id=%s;\n",vendor, vendor)
}
print HT ")\""
print "}"
print "\n"
print "type enumerated vendor_id_enum"
print "{"
i=1
for(vendor in vendor_list){
if(i==1){
printf (HT "%s %s",vendor, vendor_list[vendor])
i++
} else {
printf (",\n" HT "%s %s",vendor, vendor_list[vendor])
}
}
print "\n" "} with {"
print HT "variant \"FIELDLENGTH(32)\""
print HT "variant \"BYTEORDER(last)\""
print "}"
print "\n"
print "type union string_val_spec"
print "{"
i=1
for(vendor in vendor_list){
if(i==1){
printf (HT "%s_subattr_list f_%s_subattr_list",vendor, vendor)
i++
} else {
printf (",\n" HT "%s_subattr_list f_%s_subattr_list",vendor, vendor)
}
}
print "\n}"
if(old_structured_code){
for(i = 1; i <= matching_attrib_types; i++) {
printf("type record Attrib_%s\n", attrib_type[i])
print "{"
print HT "Attrib attrib_type,"
print HT "UINT8 attrib_length,"
printf(HT "%s %s\n", attrib_type[i], tolower(attrib_type[i]))
print "} with {"
printf(HT " variant \"PRESENCE (attrib_type=%s)\"\n",attrib_type[i])
printf(HT " variant (attrib_length) \"LENGTHTO(attrib_type, attrib_length, %s)\"\n",
tolower(attrib_type[i]))
print HT "}"
print "\n"
}
print "type set of GenericAttrib Attribs;\n"
print "type union GenericAttrib"
print "{"
for(i = 1; i <= matching_attrib_types; i++) {
printf(HT "Attrib_%s attrib_%s,\n",
attrib_type[i],attrib_type[i])
}
print HT "Attrib_UNKNOWN attrib_UNKNOWN"
print "}\n"
}
else{
print "\n"
print "type union Attrib_Data"
print "{"
for(i = 1; i <= matching_attrib_types; i++) {
printf(HT "%s %s,\n", attrib_type[i], tolower(attrib_type[i]))
}
print HT "octetstring attrib_UNKNOWN"
print "}\n"
print "type set of GenAttrib Attribs;\n"
print "type union GenAttrib"
print "{"
print HT "GenericAttrib genericAttrib,"
print HT "Attrib_UNKNOWN attrib_UNKNOWN"
print "}\n"
print "type record GenericAttrib"
print "{"
print HT "Attrib attrib_type,"
print HT "UINT8 attrib_length,"
print HT "Attrib_Data attrib_data"
print "} with {"
print HT " variant (attrib_length) \"LENGTHTO(attrib_type, attrib_length, attrib_data)\""
print HT " variant (attrib_data) \"CROSSTAG("
for(i = 1; i <= matching_attrib_types; i++) {
printf(HT HT "%s,attrib_type=%s;\n", tolower(attrib_type[i]),attrib_type[i])
}
print HT HT "attrib_UNKNOWN, OTHERWISE"
print HT ")\""
print "}"
print "\n"
}
print "type enumerated Attrib"
print HT "{"
for(i = 1; i <= matching_attrib_types; i++) {
printf(HT "%s %s%s\n",
attrib_type[i], attrib_code[i],
(i < matching_attrib_types) ? "," : "")
}
print "} with {"
print HT "variant \"FIELDLENGTH(8)\""
print HT "variant \"BYTEORDER(last)\""
print HT "}\n"
print "type enumerated Code"
print HT "{"
for(i = 1; i <= packet_descriptors; i++) {
printf(HT "%s %s%s\n",
packet_type[i], packet_code[i],
(i < packet_descriptors) ? "," : "")
}
print "} with {"
print HT "variant \"FIELDLENGTH(8)\""
print HT "variant \"BYTEORDER(last)\""
print HT "}\n"
print "type record PDU_RADIUS"
print "{"
print HT "Code code,"
print HT "UINT8 identifier,"
print HT "UINT16 message_length,"
print HT "OCTET16 authenticator,"
print HT "Attribs attributes"
print "} with {"
print HT " variant (message_length) \"LENGTHTO(code, identifier, message_length, authenticator, attributes)\""
print HT"}\n"
print "} with { encode \"RAW\" } // End module"
}
function f_AddVariant_U32(prefix)
{
print prefix, "with {"
print HT "variant \"FIELDLENGTH(32)\""
print HT "variant \"BYTEORDER(last)\""
print "}"
}
function f_AddVariant_U(prefix,flength)
{
print prefix, "with {"
printf(HT "variant \"FIELDLENGTH(%s)\"\n",flength)
print HT "variant \"BYTEORDER(last)\""
print "}"
}
function f_ReadTotalEnum()
{
total_enum = $0
while(total_enum !~ /\}/) {
getline
sub(/\/\/.*/, "")
total_enum = total_enum $0
}
# Replace $0 contents with data following }
idx = index(total_enum, "}")
$0 = substr(total_enum, idx+1)
total_enum = substr(total_enum, 1, idx)
}
#!/bin/sh
#set -x
#/******************************************************************************
#* Copyright (c) 2008, 2015 Ericsson AB
#* All rights reserved. This program and the accompanying materials
#* are made available under the terms of the Eclipse Public License v1.0
#* which accompanies this distribution, and is available at
#* http://www.eclipse.org/legal/epl-v10.html
#*
#* Contributors:
#* Timea Moder
#* Endre Kulcsar
#* Gabor Szalai
#* Janos Kovesdi
#* Kulcsr Endre
#* Zoltan Medve
#* Tamas Korosi
#******************************************************************************/
# ATTR.sh [OPTION] ... RDF-FILEs
# {-v <variable-name>=<value>} {RDF-files}
ATTRSCRIPT="ATTR.awk"
TTCN3FILE="RADIUS_Types"
if [ $# -lt 1 ]; then
echo "ERROR: Too few arguments"
echo "Usage: $0 [-vNAME=VALUE] ... RDF-FILEs"
echo "Where: -v sets variable NAME to VALUE"
echo ""
echo "Supported variables:"
echo " module_id ................ Name of generated TTCN-3 module"
echo " use_application_revision . Use revision prefix in ATTR identifier"
echo " enum_2_UnsignedInt ....... Replace enumeration ATTRs with UnsignedInteger"
echo " old_structured_code....... Generate original structured TTCN-3 code"
exit 1
fi
# check gawk version
FIRSTLINE=`gawk --version|head -1`
PRODUCT=`echo ${FIRSTLINE} | gawk '{ print $1 $2 }'`
VERSION=`echo ${FIRSTLINE} | gawk '{ print $3 }'`
if [ ${PRODUCT} != "GNUAwk" ]; then
echo "ERROR: GNU Awk required"
exit 1
fi
RESULT=`echo ${VERSION} | gawk '{ print ($0 < "3.1.6") }'`
if [ ${RESULT} != 0 ]; then
echo "ERROR: GNU Awk version >3.1.6 required (${VERSION} found)"
exit 1
fi
# Process arguments
AWKARGS=$@
while [ $# -ge 1 ]; do
case $1 in
-v)
shift;
case $1 in
module_id=*)
TTCN3FILE=`echo $1 | sed 's/module_id=//'`
if [ -f "RADIUS_EncDec.cc" ]; then
cmd="s/#include \"RADIUS_Types.hh\"/#include \"${TTCN3FILE}.hh\"/
s/namespace RADIUS__Types/namespace ${TTCN3FILE}/
s/RADIUS_EncDec/${TTCN3FILE}_RADIUS_EncDec/g"
cat "RADIUS_EncDec.cc" \
| sed "${cmd}" > ${TTCN3FILE}"_RADIUS_EncDec.cc"
else
echo "ERROR: Missing RADIUS_EncDec.cc file"
exit 1
fi
;;
use_application_revision=*)
;;
enum_2_UnsignedInt=*)
;;
old_structured_code=*)
;;
*) echo "ERROR: Unknown variable $1!"; exit 1;;
esac
;;
*)
# end of options
if [ $# -lt 1 ]; then
echo "ERROR: No input RDF file"
exit 1
fi
# check gawk existence
which gawk > /dev/null 2> /dev/null
if [ ! $? ]; then
echo "ERROR: GNU awk can not be found"
exit 1
fi
# check input awk script
if [ -f ${ATTRSCRIPT} ]; then
gawk -f ${ATTRSCRIPT} ${AWKARGS} > ${TTCN3FILE}".ttcn"
else
echo "ERROR: ATTR.awk not found"
exit 1
fi
break
;;
esac
shift
done
/******************************************************************************
* Copyright (c) 2008, 2015 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Timea Moder
* Endre Kulcsar
* Gabor Szalai
* Janos Kovesdi
* Kulcsr Endre
* Zoltan Medve
* Tamas Korosi
******************************************************************************/
//
// File: Accounting_IETF_RFC2866_RFC2867.rdf
// Rev: <RnXnn>
// Prodnr: CNL 113 600
// Reference: RFC 2866(RADIUS Accounting)
// RFC 2867(RADIUS Accounting Modifications for Tunnel Protocol Support)
//
//
//
// APPLICATION-NAME: Acc
// APPLICATION-REVISION: RFC2866RFC2867
// Packet-Type: Accounting_Request (4)
// Packet-Type: Accounting_Response (5)
// RFC 2866 and RFC 2867
// Attrib: Acct-Status-Type (40)
type enumerated Acct_Status_Type
{
Start (1),
Stop (2),
Interim_Update (3),
Accounting_On (7),
Accounting_Off (8),
Tunnel_Start (9),
Tunnel_Stop (10),
Tunnel_Reject (11),
Tunnel_Link_Start (12),
Tunnel_Link_Stop (13),
Tunnel_Link_Reject (14)
}
// RFC 2866
// Attrib: Acct-Delay-Type (41)
type Attrib_Value Acct_Delay_Type;
// RFC 2866
// Attrib: Acct-Input-Octets (42)
type Attrib_Value Acct_Input_Octets;
// RFC 2866
// Attrib: Acct-Output-Octets (43)
type Attrib_Value Acct_Output_Octets;
// RFC 2866
// Attrib: Acct-Session-Id (44)
type Attrib_Text Acct_Session_Id;
// RFC 2866
// Attrib: Acct-Authentic (45)
type enumerated Acct_Authentic
{
RADIUS (1),
Local (2),
Remote (3)
}
// RFC 2866
// Attrib: Acct-Session-Time (46)
type Attrib_Value Acct_Session_Time;
// RFC 2866
// Attrib: Acct-Input-Packets (47)
type Attrib_Value Acct_Input_Packets;
// RFC 2866
// Attrib: Acct-Output-Packets (48)
type Attrib_Value Acct_Output_Packets;
// RFC 2866
// Attrib: Acct-Terminate-Cause (49)
type enumerated Acct_Terminate_Cause
{
User_Request (1),
Lost_Carrier (2),
Lost_Service (3),
Idle_Timeout (4),
Session_Timeout (5),
Admin_Reset (6),
Admin_Reboot (7),
Port_Error (8),
NAS_Error (9),
NAS_Request (10),
NAS_Reboot (11),
Port_Unneeded (12),
Port_Preempted (13),
Port_Suspended (14),
Service_Unavailable (15),
Callback (16),
User_Error (17),
Host_Request (18)
}
// RFC 2866
// Attrib: Acct-Multi-Session-Id (50)
type Attrib_String Acct_Multi_Session_Id;
// RFC 2866
// Attrib: Acct-Link-Count (51)
type Attrib_Value Acct_Link_Count;
// RFC 2867
// Attrib: Acct-Tunnel-Connection (68)
type Attrib_String Acct_Tunnel_Connection;
// RFC 2867
// Attrib: Acct-Tunnel-Packets-Lost (86)
type Attrib_Value Acct_Tunnel_Packets_Lost;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment