diff options
author | Håkon Nessjøen <haakon.nessjoen@gmail.com> | 2010-12-27 00:22:38 +0100 |
---|---|---|
committer | Håkon Nessjøen <haakon.nessjoen@gmail.com> | 2010-12-27 00:22:38 +0100 |
commit | 82fd4b116dd061b72dd88800a45b4cd302191b57 (patch) | |
tree | fa5708fc81204d3fda8ee96a7277d5321b302313 /mactelnet.c | |
parent | e28d1808ff78900205bfd6e52964a695e5048118 (diff) | |
download | MAC-Telnet-82fd4b116dd061b72dd88800a45b4cd302191b57.tar.gz MAC-Telnet-82fd4b116dd061b72dd88800a45b4cd302191b57.zip |
Added support for broadcast packets in mactelnetd also. Fixed a bug where the device index was hardcoded in send_custom_udp(). Renamed "broadcast_mode" to "use_raw_socket".
Diffstat (limited to 'mactelnet.c')
-rw-r--r-- | mactelnet.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/mactelnet.c b/mactelnet.c index 8ed8877..6f21b09 100644 --- a/mactelnet.c +++ b/mactelnet.c @@ -50,7 +50,7 @@ static unsigned int incounter = 0; static int sessionkey = 0; static int running = 1; -static unsigned char broadcast_mode = 1; +static unsigned char use_raw_socket = 0; static unsigned char terminal_mode = 0; static unsigned char srcmac[ETH_ALEN]; @@ -83,7 +83,7 @@ static int send_udp(struct mt_packet *packet, int retransmit) { /* Clear keepalive counter */ keepalive_counter = 0; - if (broadcast_mode) { + if (!use_raw_socket) { /* Init SendTo struct */ struct sockaddr_in socket_address; socket_address.sin_family = AF_INET; @@ -370,7 +370,7 @@ int main (int argc, char **argv) { switch (c) { case 'n': - broadcast_mode = 0; + use_raw_socket = 1; break; case 'u': @@ -425,12 +425,12 @@ int main (int argc, char **argv) { /* Seed randomizer */ srand(time(NULL)); - if (!broadcast_mode && geteuid() != 0) { - fprintf(stderr, "You need to have root privileges to use the -n parameter.\n"); - return 1; - } + if (use_raw_socket) { + if (geteuid() != 0) { + fprintf(stderr, "You need to have root privileges to use the -n parameter.\n"); + return 1; + } - if (!broadcast_mode) { /* Transmit raw packets with this socket */ sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (sockfd < 0) { @@ -446,7 +446,7 @@ int main (int argc, char **argv) { return 1; } - if (broadcast_mode) { + if (!use_raw_socket) { if (setsockopt(insockfd, SOL_SOCKET, SO_BROADCAST, &optval, sizeof (optval))==-1) { perror("SO_BROADCAST"); return 1; |