summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHåkon Nessjøen <haakon.nessjoen@gmail.com>2010-09-27 15:37:18 +0200
committerHåkon Nessjøen <haakon.nessjoen@gmail.com>2010-09-27 15:37:18 +0200
commitee5e037df930a4a877cd5de865dd884b3d83814f (patch)
tree02825cd1e950820f1cdcbb7132f698e64cb7210a
parent3afa38b2e38a53441ce55bf5932553a8672268bf (diff)
downloadMAC-Telnet-ee5e037df930a4a877cd5de865dd884b3d83814f.tar.gz
MAC-Telnet-ee5e037df930a4a877cd5de865dd884b3d83814f.zip
No need to re-invent a square version of the wheel... cleanup
-rw-r--r--main.c2
-rw-r--r--udp.c30
-rw-r--r--udp.h1
3 files changed, 1 insertions, 32 deletions
diff --git a/main.c b/main.c
index 5644448..0d90b0e 100644
--- a/main.c
+++ b/main.c
@@ -159,7 +159,7 @@ int main (int argc, char **argv) {
return 1;
}
- etherAddrton(dstmac, argv[2]);
+ ether_aton_r(argv[2], (struct ether_addr *)dstmac);
strncpy(username, argv[3], 254);
strncpy(password, argv[4], 254);
diff --git a/udp.c b/udp.c
index 066ec32..e8e0861 100644
--- a/udp.c
+++ b/udp.c
@@ -33,36 +33,6 @@ unsigned short in_cksum(unsigned short *addr, int len)
return (answer);
}
-unsigned char hex(const unsigned char c) {
- if ('0' <= c && c <= '9') return c - '0';
- if ('a' <= c && c <= 'f') return c - 'a' + 10;
- if ('A' <= c && c <= 'F') return c - 'A' + 10;
- return -1;
-}
-
-unsigned char hex2(const unsigned char *p) {
- int i;
- unsigned char c;
- i = hex(*p++);
- if (i < 0) return i;
- c = (i << 4);
- i = hex(*p);
- if (i < 0) return i;
- return c | i;
-}
-
-void etherAddrton(unsigned char *dest, const unsigned char *mac) {
- const unsigned char *p = mac;
- int i = 0;
-
- do {
- if (*p == ':') {
- continue;
- }
- dest[i++] = hex2(p++);
- } while (*p++ && *p);
-}
-
int sendCustomUDP(const int socket, const int ifindex, const unsigned char *sourcemac, const unsigned char *destmac, const struct in_addr *sourceip, const int sourceport, const struct in_addr *destip, const int destport, const char *data, const int datalen) {
struct sockaddr_ll socket_address;
void* buffer = (void*)malloc(ETH_FRAME_LEN);
diff --git a/udp.h b/udp.h
index 9f3644c..d43e5ee 100644
--- a/udp.h
+++ b/udp.h
@@ -1,5 +1,4 @@
#ifndef _UDP_H
#define _UDP_H 1
extern int sendCustomUDP(const int socket, const int ifindex, const unsigned char *sourcemac, const unsigned char *destmac, const struct in_addr *sourceip, const int sourceport, const struct in_addr *destip, const int destport, const char *data, const int datalen);
-extern void etherAddrton(unsigned char *dest, const unsigned char *mac);
#endif