/*
** CBLM v3
** $Id: util.h,v 1.2 2006/05/08 01:52:14 sella Exp $
** Copyright (c) 2004 James M. Sella. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
** 
** Cheap Bastard Latency Monitor v3
*/

#ifndef __DGS_UTIL_H
#define __DGS_UTIL_H

#include "data.h"
#include "packet.h"

#ifndef __USE_BSD
	#define __USE_BSD
#endif
#include <netinet/ip.h>
#ifndef __FAVOR_BSD
	#define __FAVOR_BSD
#endif
#include <netinet/udp.h>

#include <stdio.h>
#include <stdlib.h>
#include <net/if.h> 
#include <sys/ioctl.h>

#define inaddrr(x) (*(struct in_addr *) &ifr->x[sizeof sa.sin_port])
#define IFRSIZE   ((int)(size * sizeof (struct ifreq)))

#define tvtousec(x) (x.tv_usec + (x.tv_sec * 1000000))

void source_ip(char *interface, struct in_addr *ip);
unsigned short csum(unsigned short *buf, int nwords);

int subtract_timeval(struct timeval *dst, struct timeval *src);
void display_packet(struct packet_t* packet, size_t len);
void display_data(struct data_t *data);
struct timeval htontv(const struct timeval src);
struct timeval ntohtv(const struct timeval src);

#endif

/*
** Local Variables:
** c-basic-offset: 3
** tab-width: 3
** End:
** vim: noet ts=3 sw=3
*/
