summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--console.c8
-rw-r--r--devices.c36
-rw-r--r--mactelnet.c10
-rw-r--r--mactelnetd.c38
-rw-r--r--protocol.c22
-rw-r--r--protocol.h2
6 files changed, 58 insertions, 58 deletions
diff --git a/console.c b/console.c
index 60c854e..43990f4 100644
--- a/console.c
+++ b/console.c
@@ -24,17 +24,17 @@
#include <termios.h>
#include <unistd.h>
-struct termios origTerm;
+struct termios orig_term;
int raw_term() {
struct termios new;
- if (tcgetattr(STDIN_FILENO, &origTerm) < 0) {
+ if (tcgetattr(STDIN_FILENO, &orig_term) < 0) {
perror("tcgetattr");
return -1;
}
- memcpy(&new, &origTerm, sizeof(struct termios) );
+ memcpy(&new, &orig_term, sizeof(struct termios) );
/* raw mode, from tcsetattr man page */
new.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
@@ -50,7 +50,7 @@ int raw_term() {
}
int reset_term() {
- if (tcsetattr(STDIN_FILENO, TCSANOW, &origTerm) < 0) {
+ if (tcsetattr(STDIN_FILENO, TCSANOW, &orig_term) < 0) {
perror("tcsetattr");
return -1;
}
diff --git a/devices.c b/devices.c
index ffdc6b3..57d134a 100644
--- a/devices.c
+++ b/devices.c
@@ -35,11 +35,11 @@
/* Functions using NETDEVICE api */
-int get_device_index(int sockfd, char *deviceName) {
+int get_device_index(int sockfd, char *device_name) {
struct ifreq ifr;
- /* Find interface index from deviceName */
- strncpy(ifr.ifr_name, deviceName, 16);
+ /* Find interface index from device_name */
+ strncpy(ifr.ifr_name, device_name, 16);
if (ioctl(sockfd, SIOCGIFINDEX, &ifr) != 0) {
return -1;
}
@@ -48,11 +48,11 @@ int get_device_index(int sockfd, char *deviceName) {
return ifr.ifr_ifindex;
}
-int get_device_mac(const int sockfd, const char *deviceName, unsigned char *mac) {
+int get_device_mac(const int sockfd, const char *device_name, unsigned char *mac) {
struct ifreq ifr;
- /* Find interface hardware address from deviceName */
- strncpy(ifr.ifr_name, deviceName, 16);
+ /* Find interface hardware address from device_name */
+ strncpy(ifr.ifr_name, device_name, 16);
if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) != 0) {
return -1;
}
@@ -62,10 +62,10 @@ int get_device_mac(const int sockfd, const char *deviceName, unsigned char *mac)
return 1;
}
-int get_device_ip(const int sockfd, const char *deviceName, struct sockaddr_in *ip) {
+int get_device_ip(const int sockfd, const char *device_name, struct sockaddr_in *ip) {
struct ifconf ifc;
struct ifreq *ifr;
- int i,numDevices;
+ int i,device_count;
/*
* Do a initial query without allocating ifreq structs
@@ -93,9 +93,9 @@ int get_device_ip(const int sockfd, const char *deviceName, struct sockaddr_in *
}
/* Iterate through all devices, searching for interface */
- numDevices = ifc.ifc_len / sizeof(struct ifreq);
- for (i = 0; i < numDevices; ++i) {
- if (strcmp(ifr[i].ifr_name, deviceName) == 0) {
+ device_count = ifc.ifc_len / sizeof(struct ifreq);
+ for (i = 0; i < device_count; ++i) {
+ if (strcmp(ifr[i].ifr_name, device_name) == 0) {
/* Fetch IP for found interface */
memcpy(ip, &(ifr[i].ifr_addr), sizeof(ip));
free(ifr);
@@ -106,11 +106,11 @@ int get_device_ip(const int sockfd, const char *deviceName, struct sockaddr_in *
return -1;
}
-int get_ips(char *name, int nameLen, struct sockaddr_in *ip) {
+int get_ips(char *name, int name_len, struct sockaddr_in *ip) {
static int first = 1;
static struct ifaddrs *int_addrs;
static const struct ifaddrs *int_cursor;
- const struct sockaddr_in *dlAddr;
+ const struct sockaddr_in *dl_addr;
if (first == 1) {
first = 0;
@@ -123,11 +123,11 @@ int get_ips(char *name, int nameLen, struct sockaddr_in *ip) {
}
if (int_cursor != NULL) {
while (int_cursor != NULL) {
- dlAddr = (const struct sockaddr_in *) int_cursor->ifa_addr;
- if (dlAddr != NULL && dlAddr->sin_family == AF_INET) {
- memcpy(ip, dlAddr, sizeof(struct sockaddr_in));
- strncpy(name, int_cursor->ifa_name, nameLen - 1);
- name[nameLen - 1] = '\0';
+ dl_addr = (const struct sockaddr_in *) int_cursor->ifa_addr;
+ if (dl_addr != NULL && dl_addr->sin_family == AF_INET) {
+ memcpy(ip, dl_addr, sizeof(struct sockaddr_in));
+ strncpy(name, int_cursor->ifa_name, name_len - 1);
+ name[name_len - 1] = '\0';
int_cursor = int_cursor->ifa_next;
return 1;
}
diff --git a/mactelnet.c b/mactelnet.c
index 54f9c96..7be1f2a 100644
--- a/mactelnet.c
+++ b/mactelnet.c
@@ -41,14 +41,14 @@
int sockfd;
int insockfd;
-int deviceIndex;
+int device_index;
unsigned int outcounter = 0;
unsigned int incounter = 0;
int sessionkey = 0;
int running = 1;
unsigned char broadcast_mode = 1;
-unsigned char terminalMode = 0;
+unsigned char terminal_mode = 0;
unsigned char srcmac[ETH_ALEN];
unsigned char dstmac[ETH_ALEN];
@@ -79,7 +79,7 @@ static int send_udp(struct mt_packet *packet) {
return sendto(send_socket, packet->data, packet->size, 0, (struct sockaddr*)&socket_address, sizeof(socket_address));
} else {
- return send_custom_udp(sockfd, deviceIndex, srcmac, dstmac, &sourceip, sourceport, &destip, MT_MACTELNET_PORT, packet->data, packet->size);
+ return send_custom_udp(sockfd, device_index, srcmac, dstmac, &sourceip, sourceport, &destip, MT_MACTELNET_PORT, packet->data, packet->size);
}
}
@@ -198,7 +198,7 @@ static void handle_packet(unsigned char *data, int data_len) {
setvbuf(stdin, (char*)NULL, _IONBF, 0);
/* we have entered "terminal mode" */
- terminalMode = 1;
+ terminal_mode = 1;
/* Add resize signal handler */
signal(SIGWINCH, sig_winch);
@@ -536,7 +536,7 @@ int main (int argc, char **argv) {
}
}
- if (terminalMode) {
+ if (terminal_mode) {
/* Reset terminal back to old settings */
reset_term();
}
diff --git a/mactelnetd.c b/mactelnetd.c
index 0245fe2..67980a3 100644
--- a/mactelnetd.c
+++ b/mactelnetd.c
@@ -49,7 +49,7 @@
int sockfd;
int insockfd;
-int deviceIndex;
+int device_index;
struct in_addr sourceip;
struct in_addr destip;
@@ -75,12 +75,12 @@ struct mt_connection {
unsigned int outcounter;
time_t lastdata;
- int terminalMode;
+ int terminal_mode;
int state;
int ptsfd;
int slavefd;
int pid;
- int waitForAck;
+ int wait_for_ack;
char username[30];
unsigned char srcip[4];
@@ -296,7 +296,7 @@ static void user_login(struct mt_connection *curconn, struct mt_mactelnet_hdr *p
curconn->state = STATE_ACTIVE;
/* Enter terminal mode */
- curconn->terminalMode = 1;
+ curconn->terminal_mode = 1;
/* Open pts handle */
curconn->ptsfd = posix_openpt(O_RDWR);
@@ -394,10 +394,10 @@ static void handle_data_packet(struct mt_connection *curconn, struct mt_mactelne
struct mt_mactelnet_control_hdr cpkt;
struct mt_packet pdata;
unsigned char *data = pkthdr->data;
- int gotUserPacket = 0;
- int gotPassPacket = 0;
- int gotWidthPacket = 0;
- int gotHeightPacket = 0;
+ int got_user_packet = 0;
+ int got_pass_packet = 0;
+ int got_width_packet = 0;
+ int got_height_packet = 0;
int success;
/* Parse first control packet */
@@ -423,17 +423,17 @@ static void handle_data_packet(struct mt_connection *curconn, struct mt_mactelne
memcpy(curconn->username, cpkt.data, cpkt.length > 29 ? 29 : cpkt.length);
curconn->username[cpkt.length > 29 ? 29 : cpkt.length] = 0;
- gotUserPacket = 1;
+ got_user_packet = 1;
} else if (cpkt.cptype == MT_CPTYPE_TERM_WIDTH) {
curconn->terminal_width = cpkt.data[0] | (cpkt.data[1]<<8);
- gotWidthPacket = 1;
+ got_width_packet = 1;
} else if (cpkt.cptype == MT_CPTYPE_TERM_HEIGHT) {
curconn->terminal_height = cpkt.data[0] | (cpkt.data[1]<<8);
- gotHeightPacket = 1;
+ got_height_packet = 1;
} else if (cpkt.cptype == MT_CPTYPE_TERM_TYPE) {
@@ -443,7 +443,7 @@ static void handle_data_packet(struct mt_connection *curconn, struct mt_mactelne
} else if (cpkt.cptype == MT_CPTYPE_PASSWORD) {
memcpy(trypassword, cpkt.data, 17);
- gotPassPacket = 1;
+ got_pass_packet = 1;
} else if (cpkt.cptype == MT_CPTYPE_PLAINDATA) {
@@ -460,11 +460,11 @@ static void handle_data_packet(struct mt_connection *curconn, struct mt_mactelne
success = parse_control_packet(NULL, 0, &cpkt);
}
- if (gotUserPacket && gotPassPacket) {
+ if (got_user_packet && got_pass_packet) {
user_login(curconn, pkthdr);
}
- if (curconn->state == STATE_ACTIVE && (gotWidthPacket || gotHeightPacket)) {
+ if (curconn->state == STATE_ACTIVE && (got_width_packet || got_height_packet)) {
set_terminal_size(curconn->ptsfd, curconn->terminal_width, curconn->terminal_height);
}
@@ -522,7 +522,7 @@ static void handle_packet(unsigned char *data, int data_len, const struct sockad
curconn->lastdata = time(NULL);
if (pkthdr.counter <= curconn->outcounter) {
- curconn->waitForAck = 0;
+ curconn->wait_for_ack = 0;
}
if (pkthdr.counter == curconn->outcounter) {
@@ -672,7 +672,7 @@ int main (int argc, char **argv) {
/* Add active connections to select queue */
for (p = connections_head; p != NULL; p = p->next) {
- if (p->state == STATE_ACTIVE && p->waitForAck == 0 && p->ptsfd > 0) {
+ if (p->state == STATE_ACTIVE && p->wait_for_ack == 0 && p->ptsfd > 0) {
FD_SET(p->ptsfd, &read_fds);
if (p->ptsfd > maxfd)
maxfd = p->ptsfd;
@@ -698,7 +698,7 @@ int main (int argc, char **argv) {
/* Handle data from terminal sessions */
for (p = connections_head; p != NULL; p = p->next) {
/* Check if we have data ready in the pty buffer for the active session */
- if (p->state == STATE_ACTIVE && p->ptsfd > 0 && p->waitForAck == 0 && FD_ISSET(p->ptsfd, &read_fds)) {
+ if (p->state == STATE_ACTIVE && p->ptsfd > 0 && p->wait_for_ack == 0 && FD_ISSET(p->ptsfd, &read_fds)) {
unsigned char keydata[1024];
int datalen,plen;
@@ -709,7 +709,7 @@ int main (int argc, char **argv) {
init_packet(&pdata, MT_PTYPE_DATA, p->dstmac, p->srcmac, p->seskey, p->outcounter);
plen = add_control_packet(&pdata, MT_CPTYPE_PLAINDATA, &keydata, datalen);
p->outcounter += plen;
- p->waitForAck = 1;
+ p->wait_for_ack = 1;
result = send_udp(p, &pdata);
} else {
/* Shell exited */
@@ -726,7 +726,7 @@ int main (int argc, char **argv) {
p = &tmp;
}
}
- else if (p->state == STATE_ACTIVE && p->ptsfd > 0 && p->waitForAck == 1 && FD_ISSET(p->ptsfd, &read_fds)) {
+ else if (p->state == STATE_ACTIVE && p->ptsfd > 0 && p->wait_for_ack == 1 && FD_ISSET(p->ptsfd, &read_fds)) {
printf("(%d) Waiting for ack\n", p->seskey);
}
}
diff --git a/protocol.c b/protocol.c
index 104c8e7..d8ab355 100644
--- a/protocol.c
+++ b/protocol.c
@@ -206,27 +206,27 @@ int parse_control_packet(unsigned char *packetdata, int data_len, struct mt_mact
}
}
-struct mt_mndp_packet *parse_mndp(const unsigned char *data, const int packetLen) {
+struct mt_mndp_packet *parse_mndp(const unsigned char *data, const int packet_len) {
static struct mt_mndp_packet packet;
- unsigned short nameLen = 0;
+ unsigned short name_len = 0;
/* Check for valid packet length */
- if (packetLen < 18) {
+ if (packet_len < 18) {
return NULL;
}
/* Fetch length of Identifier string */
- memcpy(&nameLen, data + 16,2);
- nameLen = (nameLen >> 8) | ((nameLen & 0xff) << 8);
+ memcpy(&name_len, data + 16,2);
+ name_len = (name_len >> 8) | ((name_len & 0xff) << 8);
/* Enforce maximum name length */
- nameLen = nameLen < MT_MNDP_MAX_IDENTITY_LENGTH ? nameLen : MT_MNDP_MAX_IDENTITY_LENGTH;
+ name_len = name_len < MT_MNDP_MAX_IDENTITY_LENGTH ? name_len : MT_MNDP_MAX_IDENTITY_LENGTH;
/* Read Identifier string */
- memcpy(packet.identity, data + 18, nameLen);
+ memcpy(packet.identity, data + 18, name_len);
/* Append zero */
- packet.identity[nameLen] = 0;
+ packet.identity[name_len] = 0;
/* Read source MAC address */
memcpy(packet.address, data + 8, ETH_ALEN);
@@ -242,11 +242,11 @@ int query_mndp(const char *identity, unsigned char *mac) {
unsigned char buff[MT_PACKET_LEN];
unsigned int message = 0;
struct timeval timeout;
- time_t startTime;
+ time_t start_time;
fd_set read_fds;
struct mt_mndp_packet *packet;
- startTime = time(0);
+ start_time = time(0);
/* Open a UDP socket handle */
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
@@ -285,7 +285,7 @@ int query_mndp(const char *identity, unsigned char *mac) {
while (1) {
/* Timeout, in case we receive a lot of packets, but from the wrong routers */
- if (time(0) - startTime > (fastlookup ? MT_MNDP_TIMEOUT : MT_MNDP_LONGTIMEOUT)) {
+ if (time(0) - start_time > (fastlookup ? MT_MNDP_TIMEOUT : MT_MNDP_LONGTIMEOUT)) {
goto done;
}
diff --git a/protocol.h b/protocol.h
index 385f8cd..4be9247 100644
--- a/protocol.h
+++ b/protocol.h
@@ -89,7 +89,7 @@ extern void parse_packet(unsigned char *data, struct mt_mactelnet_hdr *pkthdr);
extern int parse_control_packet(unsigned char *data, int data_len, struct mt_mactelnet_control_hdr *cpkthdr);
/* MNDP packets */
-struct mt_mndp_packet *parse_mndp(const unsigned char *data, const int packetLen);
+struct mt_mndp_packet *parse_mndp(const unsigned char *data, const int packet_len);
int query_mndp(const char *identity, unsigned char *mac);
/* Control packet magic header */