/**
* This include file contains the general prototypes of all applications of the 
* Communication Services Manager
*
* @author	: Asanga Udugama (adu@comnets.uni-bremen.de)
* @date 	: 07-jun-2005
* 
*/

#ifndef CSM_H
#define CSM_H

#define CSM_VERSION_STR				"0.1"

// general defines
#define CSM_INTERPROCESS_ID			"/tmp/csm_pipe"
#define MAX_SOCKET_BUFFER_SIZE			512


// Error codes returned by CSM functions
#define CSM_OPERATION_SUCCEEDED			0
#define CSM_ERROR_COMM_FAILURE			(-1)

#define CSM_ERROR_DAEMONIZING_PROBLEM		(-24)

#define CSM_ERROR_INVALID_PROFILE		(-64)
#define CSM_ERROR_CAPABILITIES_EXCEEDED		(-65)
#define CSM_ERROR_NO_SESSIONS			(-66)
#define CSM_ERROR_NOTHING_ACTIVATED		(-67)
#define CSM_ERROR_ACTIVATION_PROBLEM		(-68)
#define CSM_ERROR_DEACTIVATION_PROBLEM		(-69)
#define CSM_ERROR_UNSUITABLE_ACTIVATED		(-70)
#define CSM_ERROR_PARAM_ERROR			(-71)
#define CSM_ERROR_LOGGING_ERROR			(-72)
#define CSM_ERROR_LOAD_PROFILE_ERROR		(-73)
#define CSM_ERROR_LOAD_CAPABILITY_ERROR		(-74)
#define CSM_ERROR_INVALID_SESSION		(-75)
#define CSM_ERROR_FAILED_SCRIPT			(-76)
#define CSM_ERROR_THREAD_CREATION_FAILED	(-77)
#define CSM_ERROR_DAEMONIZING_FAILED		(-78)

#define CSM_LOGGING_ERROR			1
#define CSM_LOGGING_INFORMATION			2
#define CSM_LOGGING_MIN				1
#define CSM_LOGGING_MAX				2

#define MAX_SOCKET_WAITING_CLIENTS		10


#define CSM_OP_START_COMM			1
#define CSM_OP_STOP_COMM			2


#define MAX_PROFILE_ID_SIZE			128
#define MAX_NETWORK_ID_SIZE			128
#define MAX_INIT_SIZE				512
#define MAX_ENABLER_SIZE			512
#define MAX_DISABLER_SIZE			512
#define MAX_WATCHER_SIZE			512
#define MAX_LOGGING_BUFFER_SIZE			1024


#ifndef NULL
#define NULL					0
#endif

#ifndef TRUE
#define TRUE					1
#endif

#ifndef FALSE
#define FALSE					0
#endif

#ifndef SUCCESS
#define SUCCESS					0
#endif


// structure to hold a single session identifier
typedef struct sess_info_t {
	int sess_id;
	int process_id;
	char profile_id[MAX_PROFILE_ID_SIZE];
	int conn_socket_id;
} sess_info_t;

// struct to hold a single profile
typedef struct profile_info_t {
	char profile_id[MAX_PROFILE_ID_SIZE];
	int bandwidth;
} profile_info_t;

// struct to hold a single network capability
typedef struct capability_info_t {
	char network_id[MAX_NETWORK_ID_SIZE];
	int actual_bandwidth;
	int bandwidth;

	// computation variable for bandwidth
	int bestfit_bandwidth;

	// names of scripts to bring up/take down scripts
	char init[MAX_INIT_SIZE];
	char enabler[MAX_ENABLER_SIZE];
	char disabler[MAX_DISABLER_SIZE];
	char watcher[MAX_WATCHER_SIZE];

	// is this capability currently available
	int is_available;

	// the capability is currently active 
	int is_active;

	// capability must be ativated now
	int to_activate;

} capability_info_t;

// Structure of a single linked list entry 
typedef struct ll_entry {
	struct ll_entry *prev;
	struct ll_entry *next;
	char *data;
	int count;

	struct ll_entry *read_next;
} ll_entry_t;

#endif
