5359edc160de518d8e43fdd3448365c15b912c3c galt Mon Jul 22 11:48:10 2019 -0700 Added ipv6 support. Listening processes us hybrid dual stack feature of OS to simplify implementation and use a single listening socket. Works with both TCP and UDP. Parasol working. geoIp also updated and ready for IPv6. Should be invisible to most users, while providing connections via ipv6 where available. Supports both ipv4 and ipv6. diff --git src/inc/rudp.h src/inc/rudp.h index 6bec32e..2d6a185 100644 --- src/inc/rudp.h +++ src/inc/rudp.h @@ -97,79 +97,77 @@ bits8 reserved1; /* Reserved, always zero for now. */ bits8 reserved2; /* Reserved, always zero for now. */ bits8 reserved3; /* Reserved, always zero for now. */ int pid; /* sender process id - helps filter out duplicate received packets */ int connId; /* sender conn id - helps filter out duplicate received packets */ }; struct packetSeen /* A packet was last seen when? */ { char *recvHashKey; /* hash key */ time_t lastChecked; /* Last time we checked machine in seconds past 1972 */ struct dlNode *node; /* List node of packetSeen. */ }; -typedef bits32 rudpHost; /* The IP address (in host order) of another computer. */ - #define udpEthMaxSize 1444 /* Max data size that will fit into a single ethernet packet after UDP and IP * headers. Things are faster & more reliable if you stay below this */ #define rudpMaxSize (udpEthMaxSize - sizeof(struct rudpHeader) ) struct rudp *rudpNew(int socket); /* Wrap a rudp around a socket. Call rudpFree when done, or * rudpClose if you also want to close(socket). */ void rudpFree(struct rudp **pRu); /* Free up rudp. Note this does *not* close the associated socket. */ -struct rudp *rudpOpen(); +struct rudp *rudpOpen(void); /* Open up an unbound rudp. This is suitable for * writing to and for reading responses. However * you'll want to rudpOpenBound if you want to listen for * incoming messages. Call rudpClose() when done * with this one. Warns and returns NULL if there is * a problem. */ -struct rudp *rudpMustOpen(); +struct rudp *rudpMustOpen(void); /* Open up unbound rudp. Warn and die if there is a problem. */ -struct rudp *rudpOpenBound(struct sockaddr_in *sai); +struct rudp *rudpOpenBound(struct sockaddr_storage *sai); /* Open up a rudp socket bound to a particular port and address. * Use this rather than rudpOpen if you want to wait for * messages at a specific address in a server or the like. */ -struct rudp *rudpMustOpenBound(struct sockaddr_in *sai); +struct rudp *rudpMustOpenBound(struct sockaddr_storage *sai); /* Open up a rudp socket bound to a particular port and address * or die trying. */ void rudpClose(struct rudp **pRu); /* Close socket and free memory. */ -int rudpSend(struct rudp *ru, struct sockaddr_in *sai, void *message, int size); +int rudpSend(struct rudp *ru, struct sockaddr_storage *sai, void *message, int size); /* Send message of given size to port at host via rudp. Prints a warning and * sets errno and returns -1 if there's a problem. */ int rudpReceive(struct rudp *ru, void *messageBuf, int bufSize); /* Read message into buffer of given size. Returns actual size read on * success. On failure prints a warning, sets errno, and returns -1. */ int rudpReceiveFrom(struct rudp *ru, void *messageBuf, int bufSize, - struct sockaddr_in *retFrom); + struct sockaddr_storage *retFrom); /* Read message into buffer of given size. Returns actual size read on * success. On failure prints a warning, sets errno, and returns -1. * Also returns ip address of message source. */ int rudpReceiveTimeOut(struct rudp *ru, void *messageBuf, int bufSize, - struct sockaddr_in *retFrom, int timeOut); + struct sockaddr_storage *retFrom, int timeOut); /* Like rudpReceive from above, but with a timeOut (in microseconds) * parameter. If timeOut is zero then it will wait forever. */ void rudpPrintStatus(struct rudp *ru); /* Print out status info. */ -void rudpTest(); +void rudpTest(void); /* Test out rudp stuff. */ #endif /* RUDP_H */