ocs init
This commit is contained in:
101
plat/radius/ut/Makefile
Normal file
101
plat/radius/ut/Makefile
Normal file
@@ -0,0 +1,101 @@
|
||||
|
||||
##----------------------------------------------------------##
|
||||
## ##
|
||||
## Universal Makefile for module template : V1.6.3 ##
|
||||
## ##
|
||||
## Created : Wei Liu 07/04/11 ##
|
||||
## Revision: [Last]Wei Liu 07/07/07 ##
|
||||
## ##
|
||||
##----------------------------------------------------------##
|
||||
|
||||
##---------------------------------------------------------------------##
|
||||
##--------------------------------------
|
||||
##
|
||||
## Project correlation(Customer define)
|
||||
##
|
||||
##--------------------------------------
|
||||
|
||||
## MODULE= [Module Name]
|
||||
## TYPE = app/plat => Module Type
|
||||
|
||||
## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Debug ]
|
||||
## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Release]
|
||||
|
||||
## BUILD = lib/exef => Output file format
|
||||
## CFG = debug/release => Build Configuration
|
||||
|
||||
## SRC_PATH = [Source file path]
|
||||
## INC_PATH = [Include file path]
|
||||
## APP_PATH = [App Module path]
|
||||
## PLT_PATH = [Plat Module path]
|
||||
|
||||
## PLT_LIB = [Needed plat lib for Link] => just for test or wxc2main
|
||||
## APP_LIB = [Needed app lib for Link] => just for test or wxc2main
|
||||
## LIB_ADD = [Needed Extend lib for Link] => just for test or wxc2main
|
||||
|
||||
## PLT_LIB e.g. = haepub fsm mng proto kernel aif mgc mgcp sip rtp \
|
||||
## 8ecp bicc smpp xapp tcap mtp3 m2ua \
|
||||
## snmp iptrans debug sccp public
|
||||
##
|
||||
## APP_LIB e.g. = msc vlr ssf hlr ae pps mnp smsc vms aas
|
||||
## LIB_ADD e.g. = -liba3a8 -lm
|
||||
|
||||
## OBJ_ADD = [Extend third party object files needed]
|
||||
## TEST_OBJ_PATH = [module object files Path for test ] => just for test
|
||||
##---------------------------------------------------------------------##
|
||||
|
||||
MODULE = radiustest
|
||||
TYPE = app
|
||||
|
||||
DBUG_FLAGS_ADD = -D_LKSCTP
|
||||
RELS_FLAGS_ADD = -D_LKSCTP
|
||||
|
||||
##Default commonly as below
|
||||
|
||||
BUILD = exef
|
||||
CFG = debug
|
||||
|
||||
APP_LIB = mnp vlr hlr msc vlr smsc ssf ae pps aas opr iif
|
||||
|
||||
PLT_LIB = radius megaco scf sccp haepub aif mgc_v2 mgcp rtp \
|
||||
8ecp isup bicc smpp xapp tcap sccp mtp3 m2ua \
|
||||
debug snmp iptrans public pal isdn
|
||||
|
||||
LIB_ADD = -L../../../mss/ae/src/lib -lpubfunc \
|
||||
-la3a8 -ldl -lpopt -lncurses -L/usr/lib -lsrfvar -L/usr/local/lib -lcunit
|
||||
|
||||
SRC_PATH = ./
|
||||
INC_PATH = ./
|
||||
PLT_PATH = ../../../plat
|
||||
APP_PATH = ../../../mss
|
||||
|
||||
OBJ_ADD =
|
||||
TEST_OBJ_PATH = ./obj
|
||||
|
||||
PREPROC_CMD = cd ../;make rebuild; cd ./ut ;##cd ../../../plat;make rebuild CCFLAG_SWITCH=on DBUG_FLAGS_ADD+=-DEBUG_TEST;cd -; cd ../;make rebuild; cd ./ut
|
||||
POSTPROC_CMD =
|
||||
|
||||
##---------------------------------------------------------------------##
|
||||
##--------------------------------------
|
||||
##
|
||||
## Make configuration(Customer define)
|
||||
##
|
||||
##--------------------------------------
|
||||
|
||||
## CCFLAG_SWITCH = on/off => gcc flag show on/off
|
||||
## COVER_NEED = yes/no => PTF cover report needed
|
||||
## COVER_REPORT_PATH = [path ] => PTF cover report path
|
||||
|
||||
CCFLAG_SWITCH = off
|
||||
COVER_NEED = no
|
||||
COVER_REPORT_PATH = ./output
|
||||
|
||||
##---------------------------------------------------------------------##
|
||||
|
||||
|
||||
##--------------------------------------
|
||||
##
|
||||
## include makefile.rules (Do not change)
|
||||
##
|
||||
##--------------------------------------
|
||||
include Makefile.rules
|
||||
49
plat/radius/ut/radius_test_main.c
Normal file
49
plat/radius/ut/radius_test_main.c
Normal file
@@ -0,0 +1,49 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
//#include "../src/include/megaco_pub.h"
|
||||
#include "radius_unit_test.h"
|
||||
|
||||
#include "/usr/local/include/CUnit/Basic.h"
|
||||
#include "/usr/local/include/CUnit/Automated.h"
|
||||
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
// signal(SIGSEGV, &dump);
|
||||
CU_pSuite pSuite1 = NULL;
|
||||
CU_pSuite pSuite2 = NULL;
|
||||
CU_pSuite pSuite3 = NULL;
|
||||
|
||||
/* initialize the CUnit test registry */
|
||||
if (CUE_SUCCESS != CU_initialize_registry())
|
||||
return CU_get_error();
|
||||
|
||||
/* add a suite to the registry */
|
||||
pSuite1 = CU_add_suite("function test of radius", test_radius_init, NULL);
|
||||
|
||||
if (NULL == pSuite1)
|
||||
{
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
|
||||
/* add the tests to the suite */
|
||||
if ((NULL == CU_add_test(pSuite1, "code test of radius", test_radius))
|
||||
)
|
||||
{
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
|
||||
/* Run all tests using the CUnit Basic interface */
|
||||
CU_basic_set_mode(CU_BRM_VERBOSE);
|
||||
CU_basic_run_tests();
|
||||
// CU_automated_run_tests();
|
||||
CU_list_tests_to_file();
|
||||
|
||||
CU_cleanup_registry();
|
||||
return CU_get_error();
|
||||
}
|
||||
157
plat/radius/ut/radius_unit_test.c
Normal file
157
plat/radius/ut/radius_unit_test.c
Normal file
@@ -0,0 +1,157 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../src/include/radius_if.h"
|
||||
|
||||
#include "/usr/local/include/CUnit/CUnit.h"
|
||||
|
||||
int test_radius_ind(WORD *usr_pid, WORD pid, RADIUS_MSG *msg_pdu)
|
||||
{
|
||||
static int count = 0;
|
||||
int i;
|
||||
int num;
|
||||
BYTE str[64] = "";
|
||||
BYTE tmp[4] = "";
|
||||
RADIUS_MSG pdu;
|
||||
RADIUS_ACCESS_REQUEST *access_request;
|
||||
RADIUS_ACCESS_ACCEPT *access_accept;
|
||||
RADIUS_VENDOR_SPECIFIC *vendor_specific;
|
||||
RADIUS_VENDOR_ATTRIBUTE_3GPP2_PPAC *ppac;
|
||||
RADIUS_VENDOR_ATTRIBUTE_3GPP2_PPAQ *ppaq;
|
||||
RADIUS_DISCONNECT_REQUEST *disconnect_request;
|
||||
RADIUS_ADDR addr;
|
||||
RADIUS_ATTRIBUTE_REPLY_MESSAGE *reply_message;
|
||||
|
||||
*usr_pid = 0;
|
||||
|
||||
if (msg_pdu->msg_type != RADIUS_MSG_TYPE_ACCESS_REQUEST)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
access_request = &msg_pdu->msg.access_request;
|
||||
|
||||
if (access_request->user_password.flag == 1)
|
||||
{
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
sprintf(tmp, "%02x", access_request->user_password.user_password.value[i]);
|
||||
strcat(str, tmp);
|
||||
}
|
||||
|
||||
printf("user password=%s\r\n", str);
|
||||
}
|
||||
|
||||
memset(&pdu, 0, sizeof(RADIUS_MSG));
|
||||
|
||||
pdu.msg_type = RADIUS_MSG_TYPE_ACCESS_ACCEPT;
|
||||
|
||||
access_accept = &pdu.msg.access_accept;
|
||||
|
||||
vendor_specific = &access_accept->vendor_specific;
|
||||
|
||||
num = vendor_specific->num;
|
||||
|
||||
vendor_specific->vendor_specific[num].flag = 1;
|
||||
|
||||
vendor_specific->vendor_specific[num].vendor_type = RADIUS_VENDOR_TYPE_3GPP2_PPAC;
|
||||
|
||||
ppac = &vendor_specific->vendor_specific[num].attribute_3gpp2.ppac;
|
||||
|
||||
ppac->sfs.flag = 1;
|
||||
ppac->sfs.sfs = 2;//ppac->sfs.sfs = 1;//
|
||||
|
||||
vendor_specific->num++;
|
||||
|
||||
num = vendor_specific->num;
|
||||
|
||||
vendor_specific->vendor_specific[num].vendor_type = RADIUS_VENDOR_TYPE_3GPP2_PPAQ;
|
||||
|
||||
ppaq = &vendor_specific->vendor_specific[num].attribute_3gpp2.ppaq;
|
||||
|
||||
ppaq->qid.flag = 1;
|
||||
ppaq->qid.qid.value = 9;
|
||||
|
||||
/* ppaq->vq.flag = 1;
|
||||
ppaq->vq.vq.integer = (count + 1) * 102400;
|
||||
ppaq->vq.vq.exponent = 1;
|
||||
|
||||
ppaq->vt.flag = 1;
|
||||
ppaq->vt.vt.integer = (count + 1) * 102400 - 10240;
|
||||
ppaq->vt.vt.exponent = 1;*/
|
||||
|
||||
ppaq->dq.flag = 1;
|
||||
ppaq->dq.dq.value = (count + 1) * 25;
|
||||
|
||||
ppaq->dt.flag = 1;
|
||||
ppaq->dt.dt.value = (count + 1) * 25 - 7;
|
||||
|
||||
vendor_specific->num++;
|
||||
|
||||
access_accept->message_authenticator.flag = 1;
|
||||
|
||||
radius_send_access_accept(0, pid, 0, &pdu);
|
||||
|
||||
count++;
|
||||
|
||||
if (count == 3)
|
||||
{
|
||||
memset(&pdu, 0, sizeof(RADIUS_MSG));
|
||||
|
||||
disconnect_request = &pdu.msg.disconnect_request;
|
||||
|
||||
num = disconnect_request->reply_message.num;
|
||||
|
||||
reply_message = &disconnect_request->reply_message.reply_message[num];
|
||||
|
||||
reply_message->flag = 1;
|
||||
|
||||
strcpy(reply_message->reply_message.value,"Radius disconnect");
|
||||
|
||||
disconnect_request->reply_message.num++;
|
||||
|
||||
addr.addr.ipV4 = inet_addr("155.226.202.45");
|
||||
|
||||
radius_send_disconnect_request(0, 0, &pdu, &addr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_radius_cnf(WORD usr_pid, WORD pid, RADIUS_MSG *msg_pdu)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void test_radius_init()
|
||||
{
|
||||
int sap_index;
|
||||
RADIUS_SAP sap;
|
||||
RADIUS_NAS_INFORMATION nas;
|
||||
|
||||
strcpy(sap.name, "test_radius");
|
||||
|
||||
sap.radius_ind = test_radius_ind;
|
||||
sap.radius_cnf = test_radius_cnf;
|
||||
|
||||
radius_init();
|
||||
|
||||
sap_index = radius_bind(&sap);
|
||||
|
||||
nas.nas_ip = inet_addr("155.226.202.45");
|
||||
strcpy(nas.share_key, "topsecret");
|
||||
strcpy(nas.password, "test");
|
||||
|
||||
radius_set_nas_info(sap_index, 0, &nas);
|
||||
}
|
||||
|
||||
void test_radius(void)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
radius_timer();
|
||||
|
||||
usleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
7
plat/radius/ut/radius_unit_test.h
Normal file
7
plat/radius/ut/radius_unit_test.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef _MGC_TEST_CASE_H
|
||||
#define _MGC_TEST_CASE_H
|
||||
|
||||
void test_radius_init();
|
||||
void test_radius();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user