More consistent variable naming.
authorGuus Sliepen <guus@tinc-vpn.org>
Fri, 18 May 2007 11:19:31 +0000 (11:19 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Fri, 18 May 2007 11:19:31 +0000 (11:19 +0000)
src/bsd/device.c
src/cygwin/device.c
src/linux/device.c
src/meta.c
src/mingw/device.c
src/raw_socket/device.c
src/solaris/device.c
src/uml_socket/device.c

index 474612f1f20463d7345c027845c6d5a7ce8a6469..70f4757fedbf5669e1b75c834df1072bc4ab06cd 100644 (file)
@@ -142,13 +142,13 @@ void close_device(void) {
 }
 
 bool read_packet(vpn_packet_t *packet) {
-       int lenin;
+       int inlen;
 
        cp();
 
        switch(device_type) {
                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,
                                           device, strerror(errno));
                                return false;
@@ -170,14 +170,14 @@ bool read_packet(vpn_packet_t *packet) {
                                        return false;
                        }
 
-                       packet->len = lenin + 14;
+                       packet->len = inlen + 14;
                        break;
 
                case DEVICE_TYPE_TUNIFHEAD: {
                        u_int32_t type;
                        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,
                                           device, strerror(errno));
                                return false;
@@ -201,18 +201,18 @@ bool read_packet(vpn_packet_t *packet) {
                                        return false;
                        }
 
-                       packet->len = lenin + 10;
+                       packet->len = inlen + 10;
                        break;
                }
 
                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,
                                           device, strerror(errno));
                                return false;
                        }
 
-                       packet->len = lenin;
+                       packet->len = inlen;
                        break;
 
                default:
index db8cc9e63c8db7fc0224e2b7eda207b5f2c0f5f8..c4c85d8083a4923683d00cc1675ef3d147308919 100644 (file)
@@ -176,7 +176,7 @@ bool setup_device(void) {
                   It passes everything it reads to the socket. */
        
                char buf[MTU];
-               long lenin;
+               long inlen;
 
                CloseHandle(device_handle);
 
@@ -199,8 +199,8 @@ bool setup_device(void) {
                /* Pass packets */
 
                for(;;) {
-                       ReadFile(device_handle, buf, MTU, &lenin, NULL);
-                       write(sp[1], buf, lenin);
+                       ReadFile(device_handle, buf, MTU, &inlen, NULL);
+                       write(sp[1], buf, inlen);
                }
        }
 
@@ -228,17 +228,17 @@ void close_device(void) {
 }
 
 bool read_packet(vpn_packet_t *packet) {
-       int lenin;
+       int inlen;
 
        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,
                           device, strerror(errno));
                return false;
        }
        
-       packet->len = lenin;
+       packet->len = inlen;
 
        device_total_in += packet->len;
 
@@ -249,14 +249,14 @@ bool read_packet(vpn_packet_t *packet) {
 }
 
 bool write_packet(vpn_packet_t *packet) {
-       long lenout;
+       long outlen;
 
        cp();
 
        ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
                           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()));
                return false;
        }
index 519896e71c4e513d1559d12ef48a7bfce5b53b71..90ba384921fe337bd374be6fca086626886ddd63 100644 (file)
@@ -118,43 +118,43 @@ void close_device(void) {
 }
 
 bool read_packet(vpn_packet_t *packet) {
-       int lenin;
+       int inlen;
        
        cp();
 
        switch(device_type) {
                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"),
                                           device_info, device, strerror(errno));
                                return false;
                        }
 
-                       packet->len = lenin + 10;
+                       packet->len = inlen + 10;
                        break;
                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"),
                                           device_info, device, strerror(errno));
                                return false;
                        }
 
-                       packet->len = lenin;
+                       packet->len = inlen;
                        break;
                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"),
                                           device_info, device, strerror(errno));
                                return false;
                        }
 
-                       packet->len = lenin - 2;
+                       packet->len = inlen - 2;
                        break;
        }
 
index af37d0187ad78c1ada3d678af7cd475ce70e7265..78b81604a354bf22b5c0b951ad671a20ce8025fb 100644 (file)
@@ -137,7 +137,7 @@ void broadcast_meta(connection_t *from, const char *buffer, int length) {
 
 bool receive_meta(connection_t *c) {
        int oldlen, i, result;
-       int lenin, lenout, reqlen;
+       int inlen, outlen, reqlen;
        bool decrypted = false;
        char inbuf[MAXBUFSIZE];
 
@@ -152,10 +152,10 @@ bool receive_meta(connection_t *c) {
           - 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(!lenin || !errno) {
+       if(inlen <= 0) {
+               if(!inlen || !errno) {
                        ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection closed by %s (%s)"),
                                           c->name, c->hostname);
                } else if(errno == EINTR)
@@ -168,19 +168,19 @@ bool receive_meta(connection_t *c) {
        }
 
        oldlen = c->buflen;
-       c->buflen += lenin;
+       c->buflen += inlen;
 
-       while(lenin > 0) {
+       while(inlen > 0) {
                /* Decrypt */
 
                if(c->status.decryptin && !decrypted) {
-                       result = EVP_DecryptUpdate(c->inctx, (unsigned char *)inbuf, &lenout, (unsigned char *)c->buffer + oldlen, lenin);
-                       if(!result || lenout != lenin) {
+                       result = EVP_DecryptUpdate(c->inctx, (unsigned char *)inbuf, &outlen, (unsigned char *)c->buffer + oldlen, inlen);
+                       if(!result || outlen != inlen) {
                                logger(LOG_ERR, _("Error while decrypting metadata from %s (%s): %s"),
                                                c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
                                return false;
                        }
-                       memcpy(c->buffer + oldlen, inbuf, lenin);
+                       memcpy(c->buffer + oldlen, inbuf, inlen);
                        decrypted = true;
                }
 
@@ -191,7 +191,7 @@ bool receive_meta(connection_t *c) {
                                receive_tcppacket(c, c->buffer, c->tcplen);
 
                                c->buflen -= c->tcplen;
-                               lenin -= c->tcplen - oldlen;
+                               inlen -= c->tcplen - oldlen;
                                memmove(c->buffer, c->buffer + c->tcplen, c->buflen);
                                oldlen = 0;
                                c->tcplen = 0;
@@ -219,7 +219,7 @@ bool receive_meta(connection_t *c) {
                                return false;
 
                        c->buflen -= reqlen;
-                       lenin -= reqlen - oldlen;
+                       inlen -= reqlen - oldlen;
                        memmove(c->buffer, c->buffer + reqlen, c->buflen);
                        oldlen = 0;
                        continue;
index 0e203e645b468db58b6bbfd849cffa9ef4864151..b3cbe3b327c9732a422892b5b6ee6248708deb77 100644 (file)
@@ -336,7 +336,7 @@ bool read_packet(vpn_packet_t *packet) {
 }
 
 bool write_packet(vpn_packet_t *packet) {
-       long lenout;
+       long outlen;
        OVERLAPPED overlapped = {0};
 
        cp();
@@ -344,7 +344,7 @@ bool write_packet(vpn_packet_t *packet) {
        ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Writing packet of %d bytes to %s"),
                           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()));
                return false;
        }
index ac7cc57ab65df0eab5fbe7815d17e7293d514e7a..c246d1bb0e7b2b5f615210328315c7353d9b8c06 100644 (file)
@@ -91,17 +91,17 @@ void close_device(void) {
 }
 
 bool read_packet(vpn_packet_t *packet) {
-       int lenin;
+       int inlen;
 
        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,
                           device, strerror(errno));
                return false;
        }
 
-       packet->len = lenin;
+       packet->len = inlen;
 
        device_total_in += packet->len;
 
index c66db906db929266359d707b63ceb61a13d0a25d..25f66f389c822f63b51ecae82758b8e78b0f58aa 100644 (file)
@@ -114,11 +114,11 @@ void close_device(void) {
 }
 
 bool read_packet(vpn_packet_t *packet) {
-       int lenin;
+       int inlen;
 
        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,
                           device, strerror(errno));
                return false;
@@ -140,7 +140,7 @@ bool read_packet(vpn_packet_t *packet) {
                        return false;
        }
 
-       packet->len = lenin + 14;
+       packet->len = inlen + 14;
 
        device_total_in += packet->len;
 
index 669d78edeb2eebb375559a5243123c4c81663868..27fdd337aea77445a1268c1d1e06877ac1f35702 100644 (file)
@@ -172,7 +172,7 @@ void close_device(void) {
 }
 
 bool read_packet(vpn_packet_t *packet) {
-       int lenin;
+       int inlen;
 
        cp();
 
@@ -202,7 +202,7 @@ bool read_packet(vpn_packet_t *packet) {
                }
 
                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,
                                           device, strerror(errno));
                                running = false;
@@ -232,14 +232,14 @@ bool read_packet(vpn_packet_t *packet) {
                }
 
                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,
                                           device, strerror(errno));
                                running = false;
                                return false;
                        }
 
-                       packet->len = lenin;
+                       packet->len = inlen;
 
                        device_total_in += packet->len;