summaryrefslogtreecommitdiff
path: root/protocol.c
diff options
context:
space:
mode:
authorHåkon Nessjøen <haakon.nessjoen@gmail.com>2011-11-12 04:53:12 +0100
committerHåkon Nessjøen <haakon.nessjoen@gmail.com>2011-11-12 04:53:12 +0100
commit94ac14d2765051a8992c3a822547bc09260492df (patch)
tree53774d06d9c482c1b56fd7539ae48c7ac81f8775 /protocol.c
parent904d05c3d9dec35bad0413f933ea690868a09f4f (diff)
downloadMAC-Telnet-94ac14d2765051a8992c3a822547bc09260492df.tar.gz
MAC-Telnet-94ac14d2765051a8992c3a822547bc09260492df.zip
Rewrote the interface handling. Added full support for kFreeBSD, have not tested with FreeBSD.
Diffstat (limited to 'protocol.c')
-rw-r--r--protocol.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/protocol.c b/protocol.c
index 43fd6b0..53380d1 100644
--- a/protocol.c
+++ b/protocol.c
@@ -21,7 +21,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#ifdef __LINUX__
#include <linux/if_ether.h>
+#endif
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/ether.h>
@@ -157,10 +159,10 @@ void parse_packet(unsigned char *data, struct mt_mactelnet_hdr *pkthdr) {
pkthdr->ptype = data[1];
/* src ethernet addr */
- memcpy(pkthdr->srcaddr, data+2,6);
+ memcpy(pkthdr->srcaddr, data + 2, ETH_ALEN);
/* dst ethernet addr */
- memcpy(pkthdr->dstaddr, data+8,6);
+ memcpy(pkthdr->dstaddr, data + 8, ETH_ALEN);
if (mt_direction_fromserver) {
/* Session key */
@@ -168,10 +170,10 @@ void parse_packet(unsigned char *data, struct mt_mactelnet_hdr *pkthdr) {
pkthdr->seskey = ntohs(pkthdr->seskey);
/* server type */
- memcpy(&(pkthdr->clienttype), data+16, 2);
+ memcpy(&(pkthdr->clienttype), data + 16, 2);
} else {
/* server type */
- memcpy(&(pkthdr->clienttype), data+14, 2);
+ memcpy(&(pkthdr->clienttype), data + 14, 2);
/* Session key */
memcpy(&(pkthdr->seskey), data + 16, sizeof(pkthdr->seskey));