More consistent variable naming.

This commit is contained in:
Guus Sliepen 2007-05-18 11:19:31 +00:00
parent 29fbce4497
commit e37ef57a95
8 changed files with 48 additions and 48 deletions

View file

@ -142,13 +142,13 @@ void close_device(void) {
} }
bool read_packet(vpn_packet_t *packet) { bool read_packet(vpn_packet_t *packet) {
int lenin; int inlen;
cp(); cp();
switch(device_type) { switch(device_type) {
case DEVICE_TYPE_TUN: case DEVICE_TYPE_TUN:
if((lenin = read(device_fd, packet->data + 14, MTU - 14)) <= 0) { if((inlen = read(device_fd, packet->data + 14, MTU - 14)) <= 0) {
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
device, strerror(errno)); device, strerror(errno));
return false; return false;
@ -170,14 +170,14 @@ bool read_packet(vpn_packet_t *packet) {
return false; return false;
} }
packet->len = lenin + 14; packet->len = inlen + 14;
break; break;
case DEVICE_TYPE_TUNIFHEAD: { case DEVICE_TYPE_TUNIFHEAD: {
u_int32_t type; u_int32_t type;
struct iovec vector[2] = {{&type, sizeof(type)}, {packet->data + 14, MTU - 14}}; struct iovec vector[2] = {{&type, sizeof(type)}, {packet->data + 14, MTU - 14}};
if((lenin = readv(device_fd, vector, 2)) <= 0) { if((inlen = readv(device_fd, vector, 2)) <= 0) {
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
device, strerror(errno)); device, strerror(errno));
return false; return false;
@ -201,18 +201,18 @@ bool read_packet(vpn_packet_t *packet) {
return false; return false;
} }
packet->len = lenin + 10; packet->len = inlen + 10;
break; break;
} }
case DEVICE_TYPE_TAP: case DEVICE_TYPE_TAP:
if((lenin = read(device_fd, packet->data, MTU)) <= 0) { if((inlen = read(device_fd, packet->data, MTU)) <= 0) {
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
device, strerror(errno)); device, strerror(errno));
return false; return false;
} }
packet->len = lenin; packet->len = inlen;
break; break;
default: default:

View file

@ -176,7 +176,7 @@ bool setup_device(void) {
It passes everything it reads to the socket. */ It passes everything it reads to the socket. */
char buf[MTU]; char buf[MTU];
long lenin; long inlen;
CloseHandle(device_handle); CloseHandle(device_handle);
@ -199,8 +199,8 @@ bool setup_device(void) {
/* Pass packets */ /* Pass packets */
for(;;) { for(;;) {
ReadFile(device_handle, buf, MTU, &lenin, NULL); ReadFile(device_handle, buf, MTU, &inlen, NULL);
write(sp[1], buf, lenin); write(sp[1], buf, inlen);
} }
} }
@ -228,17 +228,17 @@ void close_device(void) {
} }
bool read_packet(vpn_packet_t *packet) { bool read_packet(vpn_packet_t *packet) {
int lenin; int inlen;
cp(); cp();
if((lenin = read(sp[0], packet->data, MTU)) <= 0) { if((inlen = read(sp[0], packet->data, MTU)) <= 0) {
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
device, strerror(errno)); device, strerror(errno));
return false; return false;
} }
packet->len = lenin; packet->len = inlen;
device_total_in += packet->len; device_total_in += packet->len;
@ -249,14 +249,14 @@ bool read_packet(vpn_packet_t *packet) {
} }
bool write_packet(vpn_packet_t *packet) { bool write_packet(vpn_packet_t *packet) {
long lenout; long outlen;
cp(); cp();
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"), ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
packet->len, device_info); packet->len, device_info);
if(!WriteFile (device_handle, packet->data, packet->len, &lenout, NULL)) { if(!WriteFile (device_handle, packet->data, packet->len, &outlen, NULL)) {
logger(LOG_ERR, _("Error while writing to %s %s: %s"), device_info, device, winerror(GetLastError())); logger(LOG_ERR, _("Error while writing to %s %s: %s"), device_info, device, winerror(GetLastError()));
return false; return false;
} }

View file

@ -118,43 +118,43 @@ void close_device(void) {
} }
bool read_packet(vpn_packet_t *packet) { bool read_packet(vpn_packet_t *packet) {
int lenin; int inlen;
cp(); cp();
switch(device_type) { switch(device_type) {
case DEVICE_TYPE_TUN: case DEVICE_TYPE_TUN:
lenin = read(device_fd, packet->data + 10, MTU - 10); inlen = read(device_fd, packet->data + 10, MTU - 10);
if(lenin <= 0) { if(inlen <= 0) {
logger(LOG_ERR, _("Error while reading from %s %s: %s"), logger(LOG_ERR, _("Error while reading from %s %s: %s"),
device_info, device, strerror(errno)); device_info, device, strerror(errno));
return false; return false;
} }
packet->len = lenin + 10; packet->len = inlen + 10;
break; break;
case DEVICE_TYPE_TAP: case DEVICE_TYPE_TAP:
lenin = read(device_fd, packet->data, MTU); inlen = read(device_fd, packet->data, MTU);
if(lenin <= 0) { if(inlen <= 0) {
logger(LOG_ERR, _("Error while reading from %s %s: %s"), logger(LOG_ERR, _("Error while reading from %s %s: %s"),
device_info, device, strerror(errno)); device_info, device, strerror(errno));
return false; return false;
} }
packet->len = lenin; packet->len = inlen;
break; break;
case DEVICE_TYPE_ETHERTAP: case DEVICE_TYPE_ETHERTAP:
lenin = read(device_fd, packet->data - 2, MTU + 2); inlen = read(device_fd, packet->data - 2, MTU + 2);
if(lenin <= 0) { if(inlen <= 0) {
logger(LOG_ERR, _("Error while reading from %s %s: %s"), logger(LOG_ERR, _("Error while reading from %s %s: %s"),
device_info, device, strerror(errno)); device_info, device, strerror(errno));
return false; return false;
} }
packet->len = lenin - 2; packet->len = inlen - 2;
break; break;
} }

View file

@ -137,7 +137,7 @@ void broadcast_meta(connection_t *from, const char *buffer, int length) {
bool receive_meta(connection_t *c) { bool receive_meta(connection_t *c) {
int oldlen, i, result; int oldlen, i, result;
int lenin, lenout, reqlen; int inlen, outlen, reqlen;
bool decrypted = false; bool decrypted = false;
char inbuf[MAXBUFSIZE]; char inbuf[MAXBUFSIZE];
@ -152,10 +152,10 @@ bool receive_meta(connection_t *c) {
- If not, keep stuff in buffer and exit. - If not, keep stuff in buffer and exit.
*/ */
lenin = recv(c->socket, c->buffer + c->buflen, MAXBUFSIZE - c->buflen, 0); inlen = recv(c->socket, c->buffer + c->buflen, MAXBUFSIZE - c->buflen, 0);
if(lenin <= 0) { if(inlen <= 0) {
if(!lenin || !errno) { if(!inlen || !errno) {
ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection closed by %s (%s)"), ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection closed by %s (%s)"),
c->name, c->hostname); c->name, c->hostname);
} else if(errno == EINTR) } else if(errno == EINTR)
@ -168,19 +168,19 @@ bool receive_meta(connection_t *c) {
} }
oldlen = c->buflen; oldlen = c->buflen;
c->buflen += lenin; c->buflen += inlen;
while(lenin > 0) { while(inlen > 0) {
/* Decrypt */ /* Decrypt */
if(c->status.decryptin && !decrypted) { if(c->status.decryptin && !decrypted) {
result = EVP_DecryptUpdate(c->inctx, (unsigned char *)inbuf, &lenout, (unsigned char *)c->buffer + oldlen, lenin); result = EVP_DecryptUpdate(c->inctx, (unsigned char *)inbuf, &outlen, (unsigned char *)c->buffer + oldlen, inlen);
if(!result || lenout != lenin) { if(!result || outlen != inlen) {
logger(LOG_ERR, _("Error while decrypting metadata from %s (%s): %s"), logger(LOG_ERR, _("Error while decrypting metadata from %s (%s): %s"),
c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL)); c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
return false; return false;
} }
memcpy(c->buffer + oldlen, inbuf, lenin); memcpy(c->buffer + oldlen, inbuf, inlen);
decrypted = true; decrypted = true;
} }
@ -191,7 +191,7 @@ bool receive_meta(connection_t *c) {
receive_tcppacket(c, c->buffer, c->tcplen); receive_tcppacket(c, c->buffer, c->tcplen);
c->buflen -= c->tcplen; c->buflen -= c->tcplen;
lenin -= c->tcplen - oldlen; inlen -= c->tcplen - oldlen;
memmove(c->buffer, c->buffer + c->tcplen, c->buflen); memmove(c->buffer, c->buffer + c->tcplen, c->buflen);
oldlen = 0; oldlen = 0;
c->tcplen = 0; c->tcplen = 0;
@ -219,7 +219,7 @@ bool receive_meta(connection_t *c) {
return false; return false;
c->buflen -= reqlen; c->buflen -= reqlen;
lenin -= reqlen - oldlen; inlen -= reqlen - oldlen;
memmove(c->buffer, c->buffer + reqlen, c->buflen); memmove(c->buffer, c->buffer + reqlen, c->buflen);
oldlen = 0; oldlen = 0;
continue; continue;

View file

@ -336,7 +336,7 @@ bool read_packet(vpn_packet_t *packet) {
} }
bool write_packet(vpn_packet_t *packet) { bool write_packet(vpn_packet_t *packet) {
long lenout; long outlen;
OVERLAPPED overlapped = {0}; OVERLAPPED overlapped = {0};
cp(); cp();
@ -344,7 +344,7 @@ bool write_packet(vpn_packet_t *packet) {
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"), ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
packet->len, device_info); packet->len, device_info);
if(!WriteFile(device_handle, packet->data, packet->len, &lenout, &overlapped)) { if(!WriteFile(device_handle, packet->data, packet->len, &outlen, &overlapped)) {
logger(LOG_ERR, _("Error while writing to %s %s: %s"), device_info, device, winerror(GetLastError())); logger(LOG_ERR, _("Error while writing to %s %s: %s"), device_info, device, winerror(GetLastError()));
return false; return false;
} }

View file

@ -91,17 +91,17 @@ void close_device(void) {
} }
bool read_packet(vpn_packet_t *packet) { bool read_packet(vpn_packet_t *packet) {
int lenin; int inlen;
cp(); cp();
if((lenin = read(device_fd, packet->data, MTU)) <= 0) { if((inlen = read(device_fd, packet->data, MTU)) <= 0) {
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
device, strerror(errno)); device, strerror(errno));
return false; return false;
} }
packet->len = lenin; packet->len = inlen;
device_total_in += packet->len; device_total_in += packet->len;

View file

@ -114,11 +114,11 @@ void close_device(void) {
} }
bool read_packet(vpn_packet_t *packet) { bool read_packet(vpn_packet_t *packet) {
int lenin; int inlen;
cp(); cp();
if((lenin = read(device_fd, packet->data + 14, MTU - 14)) <= 0) { if((inlen = read(device_fd, packet->data + 14, MTU - 14)) <= 0) {
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
device, strerror(errno)); device, strerror(errno));
return false; return false;
@ -140,7 +140,7 @@ bool read_packet(vpn_packet_t *packet) {
return false; return false;
} }
packet->len = lenin + 14; packet->len = inlen + 14;
device_total_in += packet->len; device_total_in += packet->len;

View file

@ -172,7 +172,7 @@ void close_device(void) {
} }
bool read_packet(vpn_packet_t *packet) { bool read_packet(vpn_packet_t *packet) {
int lenin; int inlen;
cp(); cp();
@ -202,7 +202,7 @@ bool read_packet(vpn_packet_t *packet) {
} }
case 1: { case 1: {
if((lenin = read(request_fd, &request, sizeof request)) != sizeof request) { if((inlen = read(request_fd, &request, sizeof request)) != sizeof request) {
logger(LOG_ERR, _("Error while reading request from %s %s: %s"), device_info, logger(LOG_ERR, _("Error while reading request from %s %s: %s"), device_info,
device, strerror(errno)); device, strerror(errno));
running = false; running = false;
@ -232,14 +232,14 @@ bool read_packet(vpn_packet_t *packet) {
} }
case 2: { case 2: {
if((lenin = read(data_fd, packet->data, MTU)) <= 0) { if((inlen = read(data_fd, packet->data, MTU)) <= 0) {
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info, logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
device, strerror(errno)); device, strerror(errno));
running = false; running = false;
return false; return false;
} }
packet->len = lenin; packet->len = inlen;
device_total_in += packet->len; device_total_in += packet->len;