/**
 * @file slp-light_types.h
 *
 * @brief Service Location Protocol (SLP) - minimal implemenation (types).
 *
 * Copyright 2007-2008, Freie Universitaet Berlin. All rights reserved.
 * Please refer to the COPYING file for detailed licensing information.
 *
 * @author Georg Wittenburg
 *
 * $Id: slp-light_types.h 2685 2008-06-25 16:38:56Z wittenbu $
 */

#ifndef SLP_LIGHT_TYPES_H
#define SLP_LIGHT_TYPES_H

#include "../types.h"
#include "../service/service_types.h"



/*
 * SLP query types.
 */

/**
 * @brief A service instance found by a SLP query.
 */
typedef struct {
	C_addr_t		server;				///< Server address.
	uint8_t			hops;				///< Distance to the server in hops.
	C_time_t		delay;				///< Time it took the reply to arrive.
} SLP_service_instance_t;

/**
 * @brief Result of a SLP query.
 */
typedef struct {
	SERVICE_id_t		service_id[SERVICE_ID_LENGTH];	///< Service ID.
	list_t*			service_instances;		///< List of found service instances.
	C_errno_t		error_code;			///< Error code.
	callback_parameter_t	parameter;			///< Parameter for the callback function.
} SLP_query_result_t;

/**
 * @brief Active query data structure.
 */
typedef struct {
	SERVICE_id_t		service_id[SERVICE_ID_LENGTH];	///< Service ID.
	uint8_t			min_service_instances;		///< Minimal number of found service instances before the query is done.
	uint8_t			retries;			///< Number of retries left.
	C_time_t		start_time;			///< Time since the current retry started.
	uint16_t		callback_id;			///< ID of the timeout callback.
	callback_function_t	function;			///< Callback function.
	SLP_query_result_t*	result;				///< Parameter for callback function.
} SLP_query_t;



/*
 * Packet types.
 */

/**
 * @brief SLP QUERY packet.
 */
typedef struct {
	SERVICE_id_t		service_id[SERVICE_ID_LENGTH];	///< Service ID.
} SLP_QUERY_packet_t;

/**
 * @brief SLP REPLY packet.
 */
typedef struct {
	SERVICE_id_t		service_id[SERVICE_ID_LENGTH];	///< Service ID.
} SLP_REPLY_packet_t;

#endif	// SLP_LIGHT_TYPES_H
