Repository : ssh://git@open-mesh.org/alfred
On branch : master
commit 713ea75bbae0f5804119ac4c12976cd42b47bb93 Author: Sven Eckelmann sven@open-mesh.com Date: Fri Jan 11 13:38:00 2013 +0100
alfred: Place all network struct definitions in packet.h
Signed-off-by: Sven Eckelmann sven@open-mesh.com
713ea75bbae0f5804119ac4c12976cd42b47bb93 alfred.h | 24 +----------------------- util.c => packet.h | 39 +++++++++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 35 deletions(-)
diff --git a/alfred.h b/alfred.h index ae3f8ba..6632571 100644 --- a/alfred.h +++ b/alfred.h @@ -29,30 +29,8 @@ #include <netinet/in.h> #include <time.h> #include "hash.h" -#define __packed __attribute__ ((packed)) - -struct alfred_data { - uint8_t source[ETH_ALEN]; - uint8_t type; - uint8_t version; - uint16_t length; -} __packed; - -struct alfred_packet { - uint8_t type; - uint8_t version; - uint16_t length; -} __packed; - -enum alfred_packet_type { - ALFRED_PUSH_DATA = 0, - ALFRED_ANNOUNCE_MASTER = 1, - ALFRED_REQUEST = 2, -}; +#include "packet.h"
-#define ALFRED_VERSION 0 -#define ALFRED_PORT 0x4242 -#define ALFRED_MAX_RESERVED_TYPE 64 #define ALFRED_INTERVAL 10 #define ALFRED_REQUEST_TIMEOUT 1 #define ALFRED_SERVER_TIMEOUT 60 diff --git a/util.c b/packet.h similarity index 60% copy from util.c copy to packet.h index 0d026b1..5b8bfb5 100644 --- a/util.c +++ b/packet.h @@ -19,17 +19,32 @@ * */
-#include <sys/time.h> +#ifndef _ALFRED_PACKET_H +#define _ALFRED_PACKET_H
-int time_diff(struct timeval *tv1, struct timeval *tv2, - struct timeval *tvdiff) { - tvdiff->tv_sec = tv1->tv_sec - tv2->tv_sec; - if (tv1->tv_usec < tv2->tv_usec) { - tvdiff->tv_usec = 1000000 + tv1->tv_usec - tv2->tv_usec; - tvdiff->tv_sec -= 1; - } else { - tvdiff->tv_usec = tv1->tv_usec - tv2->tv_usec; - } +#define __packed __attribute__ ((packed))
- return (tvdiff->tv_sec >= 0); -} +struct alfred_data { + uint8_t source[ETH_ALEN]; + uint8_t type; + uint8_t version; + uint16_t length; +} __packed; + +struct alfred_packet { + uint8_t type; + uint8_t version; + uint16_t length; +} __packed; + +enum alfred_packet_type { + ALFRED_PUSH_DATA = 0, + ALFRED_ANNOUNCE_MASTER = 1, + ALFRED_REQUEST = 2, +}; + +#define ALFRED_VERSION 0 +#define ALFRED_PORT 0x4242 +#define ALFRED_MAX_RESERVED_TYPE 64 + +#endif