diff options
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | main.c | 10 | ||||
-rw-r--r-- | udp.c | 2 |
3 files changed, 16 insertions, 1 deletions
@@ -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 @@ -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; } @@ -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; } |