
struct packet {
	char type;
	uint32_t ttl;                // 1 for alive 0 for dead in lsp      
	struct sockaddr_in source;   // holds the sockaddr for the node in lsp
	struct sockaddr_in destination;

	/* non sent fields */
	struct sockaddr_in from;
	int sequence;
};




/* PACKET STUFF ***************************************************/
uint8_t* packet_to_buffer(struct packet *packet, unsigned int *packet_size);
struct packet* buffer_to_packet(uint8_t *);

void packet_send(int sockfd, struct packet* packet);

struct packet* packet_receive(int sockfd);

void print_packet(struct packet* packet);
void print_sockaddr(struct sockaddr_in* a);



/* MISC STUFF ***************************************************/
double get_time();
void error(char *message);
unsigned int options_parse_port();
void str_to_sockaddr_in(struct sockaddr_in *addr, const char *s);
char host_cmp(struct sockaddr_in *a, struct sockaddr_in *b);



/* WRAPPER STUFF ***************************************************/
int Socket(int domain, int type, int protocol);
int Bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen);
int Sendto(int s, void *buf, size_t len, int flags, 
		struct sockaddr *to, socklen_t tolen);
ssize_t Recvfrom(int s, void *buf, size_t len, int flags,
				struct sockaddr *from, socklen_t *fromlen);
FILE *Fopen(char *path, char *mode);
ssize_t Write(int fd, const void *buf, size_t count);




