summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--main.c10
-rw-r--r--udp.c2
3 files changed, 16 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index f7786b0..5a7429d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,10 @@
all: mactelnet
+clean: dist-clean
+
+dist-clean:
+ rm -f mactelnet
+
mactelnet: main.c udp.h udp.c
gcc -o mactelnet main.c udp.c
diff --git a/main.c b/main.c
index 402b676..3020db6 100644
--- a/main.c
+++ b/main.c
@@ -1,7 +1,17 @@
#include <stdio.h>
+#include <sys/socket.h>
+#include <linux/if_ether.h>
#include "udp.h"
int main (int argc, char **argv) {
+ int sockfd;
+ int result;
+ char data[11] = "1234567890";
+
+ sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
+ result = sendCustomUDP(sockfd, "00:19:db:66:e5::bf", "04:1e:64:ea:e5:15", "10.0.0.100", 20561, "255.255.255.255", 20561, data, 10);
+ printf("Send result: %d\n", result);
+ close(sockfd);
return 0;
}
diff --git a/udp.c b/udp.c
index 191054d..b4bfb34 100644
--- a/udp.c
+++ b/udp.c
@@ -122,5 +122,5 @@ int sendCustomUDP(const int socket, const char *sourcemac, const char *destmac,
send_result = sendto(socket, buffer, datalen+8+14+20, 0, (struct sockaddr*)&socket_address, sizeof(socket_address));
free(buffer);
- return send_result;
+ return send_result-8-14-20;
}