Ejemplo n.º 1
0
/* entry point */
static int acct_entry(char * conffile)
{
	struct disp_when data;
	
	TRACE_ENTRY("%p", conffile);
	
#ifndef TEST_DEBUG /* We do this differently in the test scenario */
	/* Initialize the configuration and parse the file */
	CHECK_FCT( acct_conf_init() );
	CHECK_FCT( acct_conf_parse(conffile) );
	CHECK_FCT( acct_conf_check(conffile) );
#endif /* TEST_DEBUG */
	
	/* Now initialize the database module */
	CHECK_FCT( acct_db_init() );
	
	/* Search the AVPs we will need in this file */
	CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Record-Number", &acct_dict.Accounting_Record_Number, ENOENT) );
	CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Record-Type", &acct_dict.Accounting_Record_Type, ENOENT) );
	
	/* Register the dispatch callbacks */
	memset(&data, 0, sizeof(data));
	CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Diameter Base Accounting", &data.app, ENOENT) );
	CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &data.command, ENOENT) );
	CHECK_FCT( fd_disp_register( acct_cb, DISP_HOW_CC, &data, NULL, NULL ) );
	
	/* Advertise the support for the Diameter Base Accounting application in the peer */
	CHECK_FCT( fd_disp_app_support ( data.app, NULL, 0, 1 ) );
	
	return 0;
}
Ejemplo n.º 2
0
/* The extension-specific initialization code */
static int sample_main(char * conffile)
{
	/* The debug macro from main tree can be used the same way */
	TRACE_ENTRY("%p", conffile);
	
	/* This is how we access daemon's global vars */
	fprintf(stdout, "I am extension " __FILE__ " running on host %s.", fd_g_config->cnf_diamid);
	
	/* The configuration file name is received in the conffile var. It's up to extension to parse it */
	if (conffile) {
		fprintf(stdout, "I should parse my configuration file there: %s\n", conffile);
	} else {
		fprintf(stdout, "I received no configuration file to parse\n");
	}
	
	/* Functions from the libfreediameter can also be used as demonstrated here: */
	TRACE_DEBUG(INFO, "Let's create that 'Example-AVP'...");
	{
		struct dict_object * origin_host_avp = NULL;
		struct dict_object * session_id_avp = NULL;
		struct dict_object * example_avp_avp = NULL;
		struct dict_rule_data rule_data = { NULL, RULE_REQUIRED, 0, -1, 1 };
		struct dict_avp_data example_avp_data = { 999999, 0, "Example-AVP", AVP_FLAG_VENDOR , 0, AVP_TYPE_GROUPED };

		CHECK_FCT( fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &origin_host_avp, ENOENT));
		CHECK_FCT( fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &session_id_avp, ENOENT));
		
		CHECK_FCT( fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &example_avp_data , NULL, &example_avp_avp ));
		
		rule_data.rule_avp = origin_host_avp;
		rule_data.rule_min = 1;
		rule_data.rule_max = 1;
		CHECK_FCT( fd_dict_new ( fd_g_config->cnf_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ));
		
		rule_data.rule_avp = session_id_avp;
		rule_data.rule_min = 1;
		rule_data.rule_max = -1;
		CHECK_FCT( fd_dict_new ( fd_g_config->cnf_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ));
		
	}
	TRACE_DEBUG(INFO, "'Example-AVP' created without error");
	
	/* Call the c++ function */
	mycppfunc();
	
	/* The initialization function returns an error code with the standard POSIX meaning (ENOMEM, and so on) */
	return 0;
}
Ejemplo n.º 3
0
/* Main test routine */
int main(int argc, char *argv[])
{
	/* First, initialize the daemon modules */
	INIT_FD();
	
	/* Test creating and searching all types of objects */
	{
		struct dict_object * obj1 = NULL;
		struct dict_object * obj2 = NULL;
		struct dict_object * obj3 = NULL;

		vendor_id_t vendor_id = 735671;
		struct dict_vendor_data vendor1_data = { 735671, "Vendor test 1" };
		struct dict_vendor_data vendor2_data = { 735672, "Vendor test 2" };
		struct dict_application_data app1_data = { 735674, "Application test 1" };
		
		
		/* Create two vendors */
		CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_VENDOR, &vendor1_data , NULL, &obj1 ) );
		CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_VENDOR, &vendor2_data , NULL, NULL ) );
		
		/* Check we always retrieve the correct vendor object */
		CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, &obj2, ENOENT ) );
		CHECK( obj1, obj2);
		CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 1", &obj2, ENOENT ) );
		CHECK( obj1, obj2);
		
		/* Check the error conditions */
		CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, NULL, ENOENT ) );
		
		vendor_id = 735673; /* Not defined */
		CHECK( ENOENT, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, NULL, ENOENT ) );
		CHECK( ENOENT, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", NULL, ENOENT ) );
		CHECK( ENOENT, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_ID, &vendor_id, &obj2, ENOENT ) );
		CHECK( ENOENT, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", &obj2, ENOENT ) );
		CHECK( ENOTSUP, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_NAME, "Vendor test 3", &obj2, ENOTSUP ) );
		
		/* Check the get_* functions */
		CHECK( 0, fd_dict_getval ( obj1, &vendor1_data ) );
		CHECK( 735671, vendor1_data.vendor_id );
		CHECK( 0, strcmp(vendor1_data.vendor_name, "Vendor test 1") );
		/* error conditions */
		CHECK( EINVAL, fd_dict_getval ( (struct dict_object *)"not an object", &vendor1_data ) );
		
		/* Create the application with vendor1 as parent */
		CHECK( EINVAL, fd_dict_new ( fd_g_config->cnf_dict, DICT_APPLICATION, &app1_data , (struct dict_object *)"bad object", &obj2 ) );
		CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_APPLICATION, &app1_data , obj1, &obj2 ) );
		
		CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_OF_APPLICATION, obj2, &obj3, ENOENT ) );
		CHECK( obj1, obj3);
		
		/* Creating and searching the other objects is already done in dictionary initialization */
	}

	/* Test creation of the "Example-AVP" grouped AVP from the RFC */
	{
		int nbr = 0;
		struct dict_object * origin_host_avp = NULL;
		struct dict_object * session_id_avp = NULL;
		struct dict_object * example_avp_avp = NULL;
		struct dict_rule_data rule_data = { NULL, RULE_REQUIRED, -1, -1 };
		struct dict_avp_data example_avp_data = { 999999, 0, "Example-AVP", AVP_FLAG_VENDOR , 0, AVP_TYPE_GROUPED };

		CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &origin_host_avp, ENOENT ) );
		CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &session_id_avp, ENOENT ) );
		
		CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &example_avp_data , NULL, &example_avp_avp ) );
		
		rule_data.rule_avp = origin_host_avp;
		rule_data.rule_min = 1;
		rule_data.rule_max = 1;
		CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ) );
		
		rule_data.rule_avp = session_id_avp;
		rule_data.rule_min = 1;
		rule_data.rule_max = -1;
		CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_RULE, &rule_data, example_avp_avp, NULL ) );
		
		CHECK( 0, fd_dict_iterate_rules ( example_avp_avp, &nbr, iter_test) );
		CHECK( 2, nbr );
	}
	
	/* Test list function */
	{
		struct fd_list * li = NULL;
		struct fd_list * sentinel = NULL;
		enum dict_object_type	type;
		struct dict_object * defvnd=NULL;
		vendor_id_t vid = 0;
		int first = 1;
		
		CHECK( 0, fd_dict_getlistof(VENDOR_BY_ID, fd_g_config->cnf_dict, &sentinel));
		
		for (li = sentinel; (li != sentinel) || (first != 0); li = li->next) {
			first = 0;
			CHECK(0, fd_dict_gettype(li->o, &type));
			CHECK(DICT_VENDOR, type);
#if 0
			struct dict_vendor_data data;
			CHECK( 0, fd_dict_getval(li->o, &data) );
			printf("%d : %s\n", data.vendor_id, data.vendor_name);
#endif
		}
		
		CHECK( 0, fd_dict_search(fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_ID, &vid, &defvnd, ENOENT) );
		
		CHECK( 0, fd_dict_getlistof(AVP_BY_NAME, defvnd, &sentinel));
		for (li = sentinel->next; li != sentinel; li = li->next) {
			CHECK(0, fd_dict_gettype(li->o, &type));
			CHECK(DICT_AVP, type);
#if 0
			struct dict_avp_data data;
			CHECK( 0, fd_dict_getval(li->o, &data) );
			printf("%d : %s\n", data.avp_code, data.avp_name);
#endif
		}
	}

	/* Test delete function */
	{
		struct fd_list * li = NULL;
		struct fd_list * sentinel = NULL;
		struct dict_object * obj=NULL;
		vendor_id_t vid = 0;
		int count = 0, cntbkp;
		
		CHECK( 0, fd_dict_search(fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_ID, &vid, &obj, ENOENT) );
		
		CHECK( EINVAL, fd_dict_delete(obj) );
			
		
		CHECK( 0, fd_dict_getlistof(AVP_BY_NAME, obj, &sentinel));
		obj = NULL;
		
		for (li = sentinel->next; li != sentinel; li = li->next) {
			struct dict_avp_data data;
			CHECK( 0, fd_dict_getval(li->o, &data) );
			count++;
			if (data.avp_basetype != AVP_TYPE_GROUPED)
				obj = li->o;
		}
		
		CHECK(1, obj ? 1 : 0 );
#if 1
		fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, obj));
#endif
		CHECK( 0, fd_dict_delete(obj) );
		cntbkp = count;
		count = 0;
		for (li = sentinel->next; li != sentinel; li = li->next) {
			count++;
		}
		CHECK( 1, cntbkp - count );
		
	}
	
	LOG_D( "Dictionary at the end of %s: %s", __FILE__, fd_dict_dump(FD_DUMP_TEST_PARAMS, fd_g_config->cnf_dict) ?: "error");
	
	/* That's all for the tests yet */
	PASSTEST();
} 
Ejemplo n.º 4
0
static int dcca_entry(char * conffile)
{
    struct disp_when data;

    TRACE_ENTRY("%p", conffile);

    // get AVPs from dict by name
    // TODO: temporary, needs to be done more universal

    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &dcca_dict.Auth_Application_Id, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "CC-Request-Type", &dcca_dict.CC_Request_Type, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "CC-Request-Number", &dcca_dict.CC_Request_Number, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-State-Id", &dcca_dict.Origin_State_Id, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Event-Timestamp", &dcca_dict.Event_Timestamp, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Multiple-Services-Credit-Control", &dcca_dict.Multiple_Services_Credit_Control, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Granted-Service-Unit", &dcca_dict.Granted_Service_Unit, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "CC-Total-Octets", &dcca_dict.CC_Total_Octets, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Validity-Time", &dcca_dict.Validity_Time, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Result-Code", &dcca_dict.Result_Code, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Rating-Group", &dcca_dict.Rating_Group, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Used-Service-Unit", &dcca_dict.Used_Service_Unit, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "CC-Input-Octets", &dcca_dict.CC_Input_Octets, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "CC-Output-Octets", &dcca_dict.CC_Output_Octets, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Subscription-Id", &dcca_dict.Subscription_Id, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Subscription-Id-Type", &dcca_dict.Subscription_Id_Type, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Subscription-Id-Data", &dcca_dict.Subscription_Id_Data, ENOENT) );

    // Register the dispatch callbacks

    memset(&data, 0, sizeof(data));
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Diameter Credit Control Application", &data.app, ENOENT) );
    CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Credit-Control-Request", &data.command, ENOENT) );
    CHECK_FCT( fd_disp_register( dcca_cb, DISP_HOW_CC, &data, NULL, NULL ) );

    // Advertise the support for the Diameter Base Accounting application in the peer

    CHECK_FCT( fd_disp_app_support ( data.app, NULL, 0, 1 ) );

    return 0;
}
Ejemplo n.º 5
0
//Called to send a UAR
int test_sip_SAR_cb()
{
	struct dict_object * sar_model=NULL;
	struct msg * message=NULL;
	struct avp *avp=NULL;
	union avp_value value;
	
	//Fake values START
	char *sip_aor="sip:[email protected]";
	size_t aor_len=strlen(sip_aor); 
	char *destination_realm="tera.ics.keio.ac.jp";
	size_t destination_realmlen=strlen(destination_realm);
	char *destination_host="suika.tera.ics.keio.ac.jp";
	size_t destination_hostlen=strlen(destination_host);
	char *username="******";
	size_t usernamelen=strlen(username);
	char *sipserveruri="sip:[email protected]";
	size_t sipserverurilen=strlen(sipserveruri);
	// char *visitednetwork="Pink";
	//size_t visitednetworklen=strlen(visitednetwork);
	//int registrationtype = 2;
	int data_already_available=0;
	int assignment_type=0;
	//Fake values STOP
	
	//Create the base message for an RTR
	CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Server-Assignment-Request", &sar_model, ENOENT) );
	CHECK_FCT( fd_msg_new (sar_model, 0, &message));
	
	
	
	// Create a new session 
	{
		CHECK_FCT( fd_msg_new_session( message, (os0_t)"appsip", CONSTSTRLEN("appsip") ) );
	}
	
	//Add the Auth-Application-Id 
	{
		CHECK_FCT( fd_msg_avp_new ( sip_dict.Auth_Application_Id, 0, &avp ) );
		value.i32 = 6;
		CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
		CHECK_FCT( fd_msg_avp_add ( message, MSG_BRW_LAST_CHILD, avp) );
	}	
	//Auth_Session_State
	{
		CHECK_FCT( fd_msg_avp_new ( sip_dict.Auth_Session_State, 0, &avp ) );
		value.i32=1;
		CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
		CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
	}
	
	//Origin_Host & Origin_Realm
	CHECK_FCT( fd_msg_add_origin ( message, 0 ));
	
	//Destination_Host
	{
		CHECK_FCT( fd_msg_avp_new ( sip_dict.Destination_Host, 0, &avp ) );
		value.os.data=(unsigned char *)destination_host;
		value.os.len=destination_hostlen;
		CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
		CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
	}
	//Destination_Realm
	{
		CHECK_FCT( fd_msg_avp_new ( sip_dict.Destination_Realm, 0, &avp ) );
		value.os.data=(unsigned char *)destination_realm;
		value.os.len=destination_realmlen;
		CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
		CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
	}
	
	//SIP_AOR
	{
		
		CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_AOR, 0, &avp ) );
		value.os.data=(unsigned char *)sip_aor;
		value.os.len=aor_len;
		CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
		CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
		
	}
	//Username
	{
		
		CHECK_FCT( fd_msg_avp_new ( sip_dict.User_Name, 0, &avp ) );
		value.os.data=(unsigned char *)username;
		value.os.len=usernamelen;
		CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
		CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
		
	}
	//SIP_User_Data_Already_Available
	{
		CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_User_Data_Already_Available, 0, &avp ) );
		value.i32=data_already_available;
		CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
		CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
	}
	
	//SIP_Server_Assignment_Type;
	{
		CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_Server_Assignment_Type, 0, &avp ) );
		value.i32=assignment_type;
		CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
		CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
	}
	//SIP_server_uri
	{
		
		CHECK_FCT( fd_msg_avp_new ( sip_dict.SIP_Server_URI, 0, &avp ) );
		value.os.data=(unsigned char *)sipserveruri;
		value.os.len=sipserverurilen;
		CHECK_FCT( fd_msg_avp_setvalue( avp, &value ) );
		CHECK_FCT( fd_msg_avp_add( message, MSG_BRW_LAST_CHILD, avp ) );
		
	}
	
	CHECK_FCT( fd_msg_send( &message, NULL, NULL ));
	
	return 0;
}
Ejemplo n.º 6
0
int
s6a_fd_init_dict_objs (
  void)
{
  struct disp_when                        when;
  vendor_id_t                             vendor_3gpp = VENDOR_3GPP;
  application_id_t                        app_s6a = APP_S6A;

  /*
   * Pre-loading vendor object
   */
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_ID, (void *)&vendor_3gpp, &s6a_fd_cnf.dataobj_s6a_vendor, ENOENT));
  /*
   * Pre-loading application object
   */
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_ID, (void *)&app_s6a, &s6a_fd_cnf.dataobj_s6a_app, ENOENT));
  /*
   * Pre-loading commands objects
   */
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Authentication-Information-Request", &s6a_fd_cnf.dataobj_s6a_air, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Authentication-Information-Answer", &s6a_fd_cnf.dataobj_s6a_aia, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Update-Location-Request", &s6a_fd_cnf.dataobj_s6a_ulr, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Update-Location-Answer", &s6a_fd_cnf.dataobj_s6a_ula, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Purge-UE-Request", &s6a_fd_cnf.dataobj_s6a_pur, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Purge-UE-Answer", &s6a_fd_cnf.dataobj_s6a_pua, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Cancel-Location-Request", &s6a_fd_cnf.dataobj_s6a_clr, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Cancel-Location-Answer", &s6a_fd_cnf.dataobj_s6a_cla, ENOENT));
  /*
   * Pre-loading base avps
   */
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Host", &s6a_fd_cnf.dataobj_s6a_destination_host, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Realm", &s6a_fd_cnf.dataobj_s6a_destination_realm, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "User-Name", &s6a_fd_cnf.dataobj_s6a_user_name, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &s6a_fd_cnf.dataobj_s6a_session_id, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Auth-Session-State", &s6a_fd_cnf.dataobj_s6a_auth_session_state, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Result-Code", &s6a_fd_cnf.dataobj_s6a_result_code, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Experimental-Result", &s6a_fd_cnf.dataobj_s6a_experimental_result, ENOENT));
  /*
   * Pre-loading S6A specifics AVPs
   */
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Visited-PLMN-Id", &s6a_fd_cnf.dataobj_s6a_visited_plmn_id, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "RAT-Type", &s6a_fd_cnf.dataobj_s6a_rat_type, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "ULR-Flags", &s6a_fd_cnf.dataobj_s6a_ulr_flags, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "ULA-Flags", &s6a_fd_cnf.dataobj_s6a_ula_flags, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Subscription-Data", &s6a_fd_cnf.dataobj_s6a_subscription_data, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Requested-EUTRAN-Authentication-Info", &s6a_fd_cnf.dataobj_s6a_req_eutran_auth_info, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Number-Of-Requested-Vectors", &s6a_fd_cnf.dataobj_s6a_number_of_requested_vectors, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Immediate-Response-Preferred", &s6a_fd_cnf.dataobj_s6a_immediate_response_pref, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Authentication-Info", &s6a_fd_cnf.dataobj_s6a_authentication_info, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Re-Synchronization-Info", &s6a_fd_cnf.dataobj_s6a_re_synchronization_info, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "Service-Selection", &s6a_fd_cnf.dataobj_s6a_service_selection, ENOENT));
  CHECK_FD_FCT (fd_dict_search (fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_ALL_VENDORS, "UE-SRVCC-Capability", &s6a_fd_cnf.dataobj_s6a_ue_srvcc_cap, ENOENT));
  /*
   * Register callbacks
   */
  memset (&when, 0, sizeof (when));
  when.command = s6a_fd_cnf.dataobj_s6a_ula;
  when.app = s6a_fd_cnf.dataobj_s6a_app;
  /*
   * Register the callback for Update Location Answer S6A Application
   */
  CHECK_FD_FCT (fd_disp_register (s6a_ula_cb, DISP_HOW_CC, &when, NULL, &s6a_fd_cnf.ula_hdl));
  DevAssert (s6a_fd_cnf.ula_hdl != NULL);
  when.command = s6a_fd_cnf.dataobj_s6a_aia;
  when.app = s6a_fd_cnf.dataobj_s6a_app;
  /*
   * Register the callback for Authentication Information Answer S6A Application
   */
  CHECK_FD_FCT (fd_disp_register (s6a_aia_cb, DISP_HOW_CC, &when, NULL, &s6a_fd_cnf.aia_hdl));
  DevAssert (s6a_fd_cnf.aia_hdl != NULL);
  /*
   * Advertise the support for the test application in the peer
   */
  CHECK_FD_FCT (fd_disp_app_support (s6a_fd_cnf.dataobj_s6a_app, s6a_fd_cnf.dataobj_s6a_vendor, 1, 0));
  return 0;
}
Ejemplo n.º 7
0
static int s6a_init_objs(void)
{
  vendor_id_t vendor_3gpp = VENDOR_3GPP;
  application_id_t app_s6a = APP_S6A;

  memset(&s6a_cnf, 0, sizeof(s6a_cnf));

  /* Pre-loading vendor object */
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_ID,
                           (void*)&vendor_3gpp, &s6a_cnf.dataobj_s6a_vendor, ENOENT));
  /* Pre-loading application object */
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_APPLICATION,
                           APPLICATION_BY_ID, (void*)&app_s6a,
                           &s6a_cnf.dataobj_s6a_app, ENOENT));

  /* Pre-loading commands objects */
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND,
                           CMD_BY_NAME, "Authentication-Information-Request",
                           &s6a_cnf.dataobj_s6a_auth_cmd, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND,
                           CMD_BY_NAME, "Update-Location-Request",
                           &s6a_cnf.dataobj_s6a_loc_up, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND,
                           CMD_BY_NAME, "Purge-UE-Request",
                           &s6a_cnf.dataobj_s6a_purge_ue, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND,
                           CMD_BY_NAME, "Cancel-Location-Request",
                           &s6a_cnf.dataobj_s6a_cancel_loc_req, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_COMMAND,
                           CMD_BY_NAME, "Cancel-Location-Answer",
                           &s6a_cnf.dataobj_s6a_cancel_loc_ans, ENOENT));

  /* Pre-loading AVPs objects */
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME, "Origin-Host",
                           &s6a_cnf.dataobj_s6a_origin_host, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME, "Origin-Realm",
                           &s6a_cnf.dataobj_s6a_origin_realm, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "User-Name",
                           &s6a_cnf.dataobj_s6a_imsi, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "IMEI",
                           &s6a_cnf.dataobj_s6a_imei, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Software-Version",
                           &s6a_cnf.dataobj_s6a_software_version, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Supported-Features",
                           &s6a_cnf.dataobj_s6a_supported_features, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Requested-EUTRAN-Authentication-Info",
                           &s6a_cnf.dataobj_s6a_req_e_utran_auth_info, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Number-Of-Requested-Vectors",
                           &s6a_cnf.dataobj_s6a_req_nb_of_req_vectors, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Re-Synchronization-Info",
                           &s6a_cnf.dataobj_s6a_req_resync_info, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Requested-UTRAN-GERAN-Authentication-Info",
                           &s6a_cnf.dataobj_s6a_req_geran_auth_info, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Immediate-Response-Preferred",
                           &s6a_cnf.dataobj_s6a_immediate_response_pref, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Visited-PLMN-Id",
                           &s6a_cnf.dataobj_s6a_visited_plmn_id, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME, "Result-Code",
                           &s6a_cnf.dataobj_s6a_result_code, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME, "Experimental-Result",
                           &s6a_cnf.dataobj_s6a_experimental_result, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME, "Vendor-Id",
                           &s6a_cnf.dataobj_s6a_vendor_id, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME, "Experimental-Result-Code",
                           &s6a_cnf.dataobj_s6a_experimental_result_code, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Auth-Session-State",
                           &s6a_cnf.dataobj_s6a_auth_session_state, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Authentication-Info",
                           &s6a_cnf.dataobj_s6a_authentication_info, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "E-UTRAN-Vector",
                           &s6a_cnf.dataobj_s6a_e_utran_vector, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "RAND",
                           &s6a_cnf.dataobj_s6a_rand, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "XRES",
                           &s6a_cnf.dataobj_s6a_xres, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "AUTN",
                           &s6a_cnf.dataobj_s6a_autn, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "KASME",
                           &s6a_cnf.dataobj_s6a_kasme, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "ULR-Flags",
                           &s6a_cnf.dataobj_s6a_ulr_flags, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "ULA-Flags",
                           &s6a_cnf.dataobj_s6a_ula_flags, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "PUR-Flags",
                           &s6a_cnf.dataobj_s6a_pur_flags, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "PUA-Flags",
                           &s6a_cnf.dataobj_s6a_pua_flags, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "RAT-Type",
                           &s6a_cnf.dataobj_s6a_rat_type, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Terminal-Information",
                           &s6a_cnf.dataobj_s6a_terminal_info, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "UE-SRVCC-Capability",
                           &s6a_cnf.dataobj_s6a_ue_srvcc_cap, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "GMLC-Address",
                           &s6a_cnf.dataobj_s6a_gmlc_addr, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Subscription-Data",
                           &s6a_cnf.dataobj_s6a_subscription_data, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Subscriber-Status",
                           &s6a_cnf.dataobj_s6a_subscriber_status, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "MSISDN",
                           &s6a_cnf.dataobj_s6a_msisdn, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "AMBR",
                           &s6a_cnf.dataobj_s6a_ambr, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Network-Access-Mode",
                           &s6a_cnf.dataobj_s6a_network_access_mode, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Access-Restriction-Data",
                           &s6a_cnf.dataobj_s6a_access_restriction_data, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "APN-Configuration-Profile",
                           &s6a_cnf.dataobj_s6a_apn_configuration_profile, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Subscribed-Periodic-RAU-TAU-Timer",
                           &s6a_cnf.dataobj_s6a_subscribed_rau_tau_timer, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Context-Identifier",
                           &s6a_cnf.dataobj_s6a_context_identifier, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "All-APN-Configurations-Included-Indicator",
                           &s6a_cnf.dataobj_s6a_all_apn_conf_inc_ind, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "APN-Configuration",
                           &s6a_cnf.dataobj_s6a_apn_configuration, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-UL",
                           &s6a_cnf.dataobj_s6a_max_bandwidth_ul, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Max-Requested-Bandwidth-DL",
                           &s6a_cnf.dataobj_s6a_max_bandwidth_dl, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "PDN-Type",
                           &s6a_cnf.dataobj_s6a_pdn_type, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Service-Selection",
                           &s6a_cnf.dataobj_s6a_service_selection, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "EPS-Subscribed-QoS-Profile",
                           &s6a_cnf.dataobj_s6a_eps_subscribed_qos_profile, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "QoS-Class-Identifier",
                           &s6a_cnf.dataobj_s6a_qos_class_identifier, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Allocation-Retention-Priority",
                           &s6a_cnf.dataobj_s6a_allocation_retention_priority, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Priority-Level",
                           &s6a_cnf.dataobj_s6a_priority_level, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Capability",
                           &s6a_cnf.dataobj_s6a_pre_emption_capability, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Pre-emption-Vulnerability",
                           &s6a_cnf.dataobj_s6a_pre_emption_vulnerability, ENOENT));
  CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
                           AVP_BY_NAME_ALL_VENDORS, "Served-Party-IP-Address",
                           &s6a_cnf.dataobj_s6a_served_party_ip_addr, ENOENT));

  /* Advertise the support for the test application in the peer */
  CHECK_FCT(fd_disp_app_support(s6a_cnf.dataobj_s6a_app,
                                s6a_cnf.dataobj_s6a_vendor, 1, 0));

  return 0;
}