bb2d391712fb0208347ffc0b88abe146df14dc0a
galt
  Fri Jun 21 18:21:50 2019 -0700
Adding Support for CIDR specification of subnets, e.g. 192.168.1.255/31. It still supports the older subnet format too, e.g. 192.168

diff --git src/inc/net.h src/inc/net.h
index ae7a18e..c8690a9 100644
--- src/inc/net.h
+++ src/inc/net.h
@@ -1,26 +1,27 @@
 /* Net.h some stuff to wrap around net communications. 
  *
  * This file is copyright 2002 Jim Kent, but license is hereby
  * granted for all use - public, private or commercial. */
 
 
 #ifndef NET_H
 #define NET_H
 
 #include "linefile.h"
 #include "dystring.h"
+#include "internet.h"
 
 #define DEFAULTCONNECTTIMEOUTMSEC 10000  /* default connect timeout for tcp in milliseconds */
 #define DEFAULTREADWRITETTIMEOUTSEC 120  /* default read/write timeout for tcp in seconds */
 #define MAXURLSIZE 4096 /* maximum size in characters for a URL, but also see the struct netParsedUrl definition */
 
 int setReadWriteTimeouts(int sd, int seconds);
 /* Set read and write timeouts on socket sd 
  * Return -1 if there are any errors, 0 if successful. */
 
 /* add a failure to connFailures[]
  *  which can save time and avoid more timeouts */
 int netConnect(char *hostName, int port);
 /* Start connection with a server having resolved port. Return < 0 if error. */
 
 int netMustConnect(char *hostName, int port);
@@ -28,31 +29,31 @@
 
 int netMustConnectTo(char *hostName, char *portName);
 /* Start connection with a server and a port that needs to be converted to integer */
 
 int netAcceptingSocket(int port, int queueSize);
 /* Create a socket for to accept connections. */
 
 int netAcceptingSocketFrom(int port, int queueSize, char *host);
 /* Create a socket that can accept connections from a 
  * IP address on the current machine if the current machine
  * has multiple IP addresses. */
 
 int netAccept(int sd);
 /* Accept incoming connection from socket descriptor. */
 
-int netAcceptFrom(int sd, unsigned char subnet[4]);
+int netAcceptFrom(int acceptor, struct cidr *subnet);
 /* Wait for incoming connection from socket descriptor
  * from IP address in subnet.  Subnet is something
  * returned from netParseDottedQuad.  */
 
 FILE *netFileFromSocket(int socket);
 /* Wrap a FILE around socket.  This should be fclose'd
  * and separately the socket close'd. */
 
 int netWaitForData(int sd, int microseconds);
 /* Wait for descriptor to have some data to read, up to given number of
  * microseconds.  Returns amount of data there or zero if timed out. */
 
 void netBlockBrokenPipes();
 /* Make it so a broken pipe doesn't kill us. */
 
@@ -97,34 +98,30 @@
 
 char *netGetHugeString(int sd);
 /* Read string up to 4 gig and return it.  freeMem
  * the result when done.  Print warning message and
  * return NULL if any problem. */
 
 void netCatchPipes();
 /* Set up to catch broken pipe signals. */
 
 boolean netPipeIsBroken();
 /* Return TRUE if pipe is broken */
 
 void  netClearPipeFlag();
 /* Clear broken pipe flag. */
 
-void netParseSubnet(char *in, unsigned char out[4]);
-/* Parse subnet, which is a prefix of a normal dotted quad form.
- * Out will contain 255's for the don't care bits. */
-
 struct netParsedUrl
 /* A parsed URL. */
    {
    char protocol[16];	/* Protocol - http or ftp, etc. */
    char user[2048];	/* User name (optional)  */
    char password[2048];	/* Password  (optional)  */
    char host[2048];	/* Name of host computer - www.yahoo.com, etc. */
    char port[16];       /* Port, usually 80 or 8080. */
    char file[4096];	/* Remote file name/query string, starts with '/' */
    ssize_t byteRangeStart; /* Start of byte range, use -1 for none */
    ssize_t byteRangeEnd;   /* End of byte range use -1 for none */
    };
 
 void netParseUrl(char *url, struct netParsedUrl *parsed);
 /* Parse a URL into components.   A full URL is made up as so:
@@ -261,17 +258,18 @@
  *    char *newUrl = NULL;
  *    int newSd = 0;
  *    netSkipHttpHeaderLine(sd, url, &newSd, &newUrl);
  *    if (newUrl != NULL)
  *          // Update sd with newSd, free url if appropriate and replace it with newUrl, etc.
  *          //  free newUrl when finished.
  * This routine handles up to 5 steps of redirection.
  * The logic to this routine is also complicated a little to make it work in a pipe, which means we
  * can't attach a lineFile since filling the lineFile buffer reads in more than just the http header. */
 
 boolean netGetFtpInfo(char *url, long long *retSize, time_t *retTime);
 /* Return date in UTC and size of ftp url file */
 
 boolean hasProtocol(char *urlOrPath);
 /* Return TRUE if it looks like it has http://, ftp:// etc. */
+
 #endif /* NET_H */