view extensions/app_test/app_test.h @ 315:3cebe1c677ab

Change build system to CMake (lots of changes)
author Sebastien Decugis <sdecugis@nict.go.jp>
date Wed, 25 Feb 2009 16:49:16 +0900
parents 6537213b55b5
children 088ef7db9e52
line wrap: on
line source

/*********************************************************************************************************
* Software License Agreement (BSD License)                                                               *
* Author: Sebastien Decugis <sdecugis@nict.go.jp>							 *
*													 *
* Copyright (c) 2008, WIDE Project and NICT								 *
* All rights reserved.											 *
* 													 *
* Redistribution and use of this software in source and binary forms, with or without modification, are  *
* permitted provided that the following conditions are met:						 *
* 													 *
* * Redistributions of source code must retain the above 						 *
*   copyright notice, this list of conditions and the 							 *
*   following disclaimer.										 *
*    													 *
* * Redistributions in binary form must reproduce the above 						 *
*   copyright notice, this list of conditions and the 							 *
*   following disclaimer in the documentation and/or other						 *
*   materials provided with the distribution.								 *
* 													 *
* * Neither the name of the WIDE Project or NICT nor the 						 *
*   names of its contributors may be used to endorse or 						 *
*   promote products derived from this software without 						 *
*   specific prior written permission of WIDE Project and 						 *
*   NICT.												 *
* 													 *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 	 *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 	 *
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF   *
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.								 *
*********************************************************************************************************/

/* Header file for the app_test extension. 
 *
 *  This extension provides a way to send configurable messages on the network
 *
 *  See the app_test.conf.sample file for the format of the configuration file.
 */
 
#define IN_EXTENSION
#include <waaad/waaad.h>

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <assert.h>

/* Mode for the extension */
#define MODE_SERV	0x1
#define	MODE_CLI	0x2

/* The module configuration */
typedef struct {
	uint32_t	vendor_id;	/* default 999999 */
	uint32_t	appli_id;	/* default 123456 */
	uint32_t	cmd_id;		/* default 234567 */
	uint32_t	avp_id;		/* default 345678 */
	int		mode;		/* default MODE_SERV | MODE_CLI */
	char 	*	dest_realm;	/* default g_pconf->realm */
	char 	*	dest_host;	/* default NULL */
	int 		signal;		/* default SIGUSR1 */
} atst_conf_t;
extern atst_conf_t * atst_conf;


/* Parse the configuration file */
int atst_conf_handle(char * conffile);

/* Start or stop the signal handler */
int sig_init(void (*cb)(void));
void sig_fini(void);

/* Handle incoming messages (server) */
int serv_init(void);
void serv_fini(void);

/* Create outgoing message (client) */
int cli_init(void);
void cli_fini(void);

/* Initialize dictionary definitions */
int dict_init(void);


/* Some global variables for dictionary */
extern dict_object_t * atst_vendor;
extern dict_object_t * atst_appli;
extern dict_object_t * atst_cmd_r;
extern dict_object_t * atst_cmd_a;
extern dict_object_t * atst_avp;

extern dict_object_t * sess_id;
extern dict_object_t * origin_host;
extern dict_object_t * origin_realm;
extern dict_object_t * dest_host;
extern dict_object_t * dest_realm;
extern dict_object_t * res_code;


/**********************************************************************************
 * Define the TRACE_DEBUG macro to be used similarly as in the daemon (see log.h)
 **********************************************************************************/
#define NONE 0
#define INFO 1
#define FULL 2
#ifndef TRACE_LEVEL 
#define TRACE_LEVEL INFO
#endif /* TRACE_LEVEL */
static int debug_level = TRACE_LEVEL;
#define TRACE_DEBUG(level,format,args... ) \
	{ if ( level <= debug_level ) \
		log_debug("%-12s:%-4d( %-15s): " format "\n", __FILE__, __LINE__, __FUNCTION__, ## args); }
#define TRACE_ENTRY(_format,_args... ) \
	TRACE_DEBUG(FULL, "Entering ext function (parms: " _format ")", ##_args )
/**************************************************************************************/

#define ASSERT( _x ) assert( _x )

#define CHECK( _call ) {								\
	int __ret = ( _call );								\
	if ( __ret != 0 ) {								\
		TRACE_DEBUG(INFO, "Error in function call");				\
		log_error("Error in extension (" #_call "): %s\n", strerror(__ret));	\
		return __ret;								\
	}										\
}

#define CHECK_VOID( _call ) {								\
	int __ret = ( _call );								\
	if ( __ret != 0 ) {								\
		TRACE_DEBUG(INFO, "Error in function call");				\
		log_error("Error in extension (" #_call "): %s\n", strerror(__ret));	\
		return;								\
	}										\
}
"Welcome to our mercurial repository"