/**
	@file		types.h
	@brief 		File containing types definition for dsr packets and macros
	@author		Adrían Antoñana Gómez
	@author		Carlos Díaz Cánovas
	@version	rc-2008/12/07

*/
#ifndef _TYPES_H
#define _TYPES_H

#include <stdlib.h>
#include <stdio.h>

/*Our assigned nodes range with a macro*/
#define NODE_MIN 1
#define NODE_MAX 100
#define NODE_IN_LIMS(x) ((x < NODE_MIN || x > NODE_MAX)? 0 : 1)

/*Route type (00=request, FF=reply)*/
#define ROUTE_REQUEST	0
#define ROUTE_REPLY 	0xFF

/*Memory management*/
#define HEADER_LEN (sizeof(uint8_t)*7)
#define POS_SRC		0
#define POS_DST		1
#define POS_REQ_ID	2
#define POS_TYPE	3
#define POS_JUMP	4
#define POS_TTL		5
#define POS_PAYLOAD_LEN	6
#define MAX_ROUTE_LEN 50

/*Nice debug macro*/
#define DEBUGM(fmt, ...) printf("[%s] -> "fmt, __func__, ##__VA_ARGS__)

/*Structures for the packet management*/
typedef struct {

	uint8_t src;
	uint8_t dst;
	uint8_t req_id;
	uint8_t type;
	uint8_t jump;
	uint8_t ttl;
	uint8_t payload_len;

} _dsr_header;

typedef struct {

	uint8_t *data;

} _dsr_payload;

typedef struct {

	_dsr_header h;
	_dsr_payload p;

} _dsr_packet;

#endif

