]> jfr.im git - irc/ircd-hybrid/libopm.git/commitdiff
Added SENDBUFLEN and READBUFLEN.
authorstrtok <redacted>
Thu, 7 Nov 2002 01:37:33 +0000 (01:37 +0000)
committerstrtok <redacted>
Thu, 7 Nov 2002 01:37:33 +0000 (01:37 +0000)
src/libopm.c
src/libopm.h
src/proxy.c
src/proxy.h

index 7e21ea21f83b33c0f1108cc2d23ac5abf8e376f6..bcb320c759419e06abb28253fda9c2bf266b7df9 100644 (file)
@@ -1115,7 +1115,7 @@ static void libopm_do_readready(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION
                continue;
             }
              
-            if(conn->readlen < 128
+            if(conn->readlen < READBUFLEN
             {  /* -1 to pad for null term */
                conn->readbuf[++(conn->readlen) - 1] = c;
             }
index 23ae072275a59fd3c8495b63479ffdb57d95c756..6a5ee72f794727b795e4c10c81fc7e36bf7cd425 100644 (file)
@@ -5,7 +5,9 @@
 #include "opm_common.h"
 #include "opm.h"
 
-#define CBLEN 5
+#define CBLEN 5            /* Number of callback functions  */
+#define READBUFLEN 128     /* Size of conn->readbuf         */
+#define SENDBUFLEN 512     /* Size of sendbuffer in proxy.c */
 
 typedef struct  _OPM_SCAN             OPM_SCAN_T;
 typedef struct  _OPM_CONNECTION       OPM_CONNECTION_T;
@@ -31,7 +33,7 @@ struct _OPM_CONNECTION {
 
    int                fd;               /* Allocated file descriptor, 0 if not yet allocated */
    unsigned short int bytes_read;       /* Bytes read so far in this connection */
-   char               readbuf[128];     /* 128 byte read buffer, anything over 128 is probably not of use */
+   char               readbuf[READBUFLEN + 1]; /* 128 byte read buffer, anything over 128 is probably not of use */
    unsigned short int readlen;          /* Length of readbuf */
    unsigned short int state;            /* State of connection */
    time_t             creation;         /* When this connection was established */
index dc4c0c5770d0472be673b5f4d4ca807a7ec764e9..e4f15f483683d6dc7a6a14bf9c55ff80afe891f7 100644 (file)
 
 RCSID("$Id$");
 
-static char SENDBUFF[512];
-
+static char SENDBUF[SENDBUFLEN + 1];
 
 int libopm_proxy_http_write(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
 {
-   snprintf(SENDBUFF, 128, "CONNECT %s:%d HTTP/1.0\r\n\r\n",
+   snprintf(SENDBUF, SENDBUFLEN, "CONNECT %s:%d HTTP/1.0\r\n\r\n",
       (char *) libopm_config(scanner->config, OPM_CONFIG_SCAN_IP), 
       *(int *) libopm_config(scanner->config, OPM_CONFIG_SCAN_PORT));
  
-   if(send(conn->fd, SENDBUFF, strlen(SENDBUFF), 0) == -1)
+   if(send(conn->fd, SENDBUF, strlen(SENDBUF), 0) == -1)
       return 0; /* Return error code ? */
 
    return OPM_SUCCESS;
@@ -77,13 +76,13 @@ int libopm_proxy_socks4_write(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T
 
    laddr = htonl(addr.s_addr);
 
-   len = snprintf(SENDBUFF, 512, "%c%c%c%c%c%c%c%c%c",  4, 1,
+   len = snprintf(SENDBUF, SENDBUFLEN, "%c%c%c%c%c%c%c%c%c",  4, 1,
                  (((unsigned short) scan_port) >> 8) & 0xFF,
                  (((unsigned short) scan_port) & 0xFF),
                  (char) (laddr >> 24) & 0xFF, (char) (laddr >> 16) & 0xFF,
                  (char) (laddr >> 8) & 0xFF, (char) laddr & 0xFF, 0);
 
-   send(conn->fd, SENDBUFF, len, 0);
+   send(conn->fd, SENDBUF, len, 0);
 
    return OPM_SUCCESS;
 }
@@ -147,21 +146,21 @@ int libopm_proxy_socks5_write(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T
 
    /* Form authentication string */
    /* Version 5, 1 number of methods, 0 method (no auth). */
-   len = snprintf(SENDBUFF, 512, "%c%c%c", 5, 1, 0);
-   send(conn->fd, SENDBUFF, len, 0);
+   len = snprintf(SENDBUF, SENDBUFLEN, "%c%c%c", 5, 1, 0);
+   send(conn->fd, SENDBUF, len, 0);
 
    /* Form request string */
 
    /* Will need to write ipv6 support here in future
     * as socks5 is ipv6 compatible
     */
-   len = snprintf(SENDBUFF, 512, "%c%c%c%c%c%c%c%c%c%c", 5, 1, 0, 1,
+   len = snprintf(SENDBUF, SENDBUFLEN, "%c%c%c%c%c%c%c%c%c%c", 5, 1, 0, 1,
                  (char) (laddr >> 24) & 0xFF, (char) (laddr >> 16) & 0xFF,
                  (char) (laddr >> 8) & 0xFF, (char) laddr & 0xFF,
                  (((unsigned short) scan_port) >> 8) & 0xFF,
                  (((unsigned short) scan_port) & 0xFF));
 
-   send(conn->fd, SENDBUFF, len, 0);
+   send(conn->fd, SENDBUF, len, 0);
    return OPM_SUCCESS;
 
 }
@@ -179,8 +178,8 @@ int libopm_proxy_wingate_write(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_
    scan_ip = (char *) libopm_config(scanner->config, OPM_CONFIG_SCAN_IP);
    scan_port = *(int *) libopm_config(scanner->config, OPM_CONFIG_SCAN_PORT);
 
-   len = snprintf(SENDBUFF, 512, "%s:%d\r\n", scan_ip, scan_port);
-   send(conn->fd, SENDBUFF, len, 0);
+   len = snprintf(SENDBUF, SENDBUFLEN, "%s:%d\r\n", scan_ip, scan_port);
+   send(conn->fd, SENDBUF, len, 0);
 
    return OPM_SUCCESS;
 }
@@ -202,11 +201,11 @@ int libopm_proxy_router_write(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T
    scan_ip = (char *) libopm_config(scanner->config, OPM_CONFIG_SCAN_IP);
    scan_port = *(int *) libopm_config(scanner->config, OPM_CONFIG_SCAN_PORT);
 
-   len = snprintf(SENDBUFF, 512, "cisco\r\n");
-   send(conn->fd, SENDBUFF, len, 0);
+   len = snprintf(SENDBUF, SENDBUFLEN, "cisco\r\n");
+   send(conn->fd, SENDBUF, len, 0);
 
-   len = snprintf(SENDBUFF, 512, "telnet %s %d\r\n", scan_ip, scan_port);
-   send(conn->fd, SENDBUFF, len, 0);
+   len = snprintf(SENDBUF, SENDBUFLEN, "telnet %s %d\r\n", scan_ip, scan_port);
+   send(conn->fd, SENDBUF, len, 0);
 
    return OPM_SUCCESS;
 }
@@ -225,12 +224,12 @@ int libopm_proxy_httppost_write(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION
    scan_ip = (char *) libopm_config(scanner->config, OPM_CONFIG_SCAN_IP);
    scan_port = *(int *) libopm_config(scanner->config, OPM_CONFIG_SCAN_PORT);
 
-   len = snprintf(SENDBUFF, 128, "POST http://%s:%d/ HTTP/1.0\r\n"
+   len = snprintf(SENDBUF, SENDBUFLEN, "POST http://%s:%d/ HTTP/1.0\r\n"
             "Content-type: text/plain\r\n"
             "Content-length: 5\r\n\r\n"
             "quit\r\n\r\n",
             scan_ip, scan_port);
 
-   send(conn->fd, SENDBUFF, len, 0);
+   send(conn->fd, SENDBUF, len, 0);
    return(1);
 }
index ad5a7c4cd75dff3a7084ef451f1a6edeefe2efab..ef21d5e192f3c2ec09b96ec42cadd9e9db3b05e6 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "libopm.h"
 
-
 int libopm_proxy_http_write(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
 int libopm_proxy_socks4_write(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
 int libopm_proxy_socks5_write(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);