From 065bb72362c52603bd615b0a69e24a6f00f03932 Mon Sep 17 00:00:00 2001 From: Håkon Nessjøen Date: Sun, 3 Oct 2010 02:44:37 +0200 Subject: Changed how packet generation functions get access to the buffer, so they won't let you overflow the buffer, and they will keep track of the packet size "internally". --- mactelnet.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'mactelnet.h') diff --git a/mactelnet.h b/mactelnet.h index 2a62353..d992de4 100644 --- a/mactelnet.h +++ b/mactelnet.h @@ -22,6 +22,8 @@ #define MT_HEADER_LEN 22 #define MT_CPHEADER_LEN 9 +#define MT_PACKET_LEN 1500 + /* Packet type */ #define MT_PTYPE_SESSIONSTART 0 #define MT_PTYPE_DATA 1 @@ -58,8 +60,13 @@ struct mt_mactelnet_control_hdr { unsigned char *data; }; -extern int initPacket(unsigned char *data, unsigned char ptype, unsigned char *srcmac, unsigned char *dstmac, unsigned short sessionkey, unsigned short counter); -extern int addControlPacket(unsigned char *data, unsigned char cptype, void *cpdata, int data_len); +struct mt_packet { + int size; + unsigned char data[MT_PACKET_LEN]; +}; + +extern int initPacket(struct mt_packet *packet, unsigned char ptype, unsigned char *srcmac, unsigned char *dstmac, unsigned short sessionkey, unsigned short counter); +extern int addControlPacket(struct mt_packet *packet, char cptype, void *cpdata, int data_len); extern void parsePacket(unsigned char *data, struct mt_mactelnet_hdr *pkthdr); extern int parseControlPacket(unsigned char *data, const int data_len, struct mt_mactelnet_control_hdr *cpkthdr); -- cgit v1.2.3