- /* The address was valid ipv4,
- * but the mask that went with it wasnt.
- */
- free(mask);
- return false;
- }
- }
- else
- {
- /* The address was neither ipv4 or ipv6 */
- free(mask);
- return false;
- }
-
- /* Low-level-match the bits in the raw data */
- free(mask);
- return MatchCIDRBits(addr_raw, mask_raw, bits);
-}
-
-inline void irc::sockets::Blocking(int s)
-{
- int flags = fcntl(s, F_GETFL, 0);
- fcntl(s, F_SETFL, flags ^ O_NONBLOCK);
-}
-
-inline void irc::sockets::NonBlocking(int s)
-{
- int flags = fcntl(s, F_GETFL, 0);
- fcntl(s, F_SETFL, flags | O_NONBLOCK);
-}
-
-
-/** This will bind a socket to a port. It works for UDP/TCP.
- * It can only bind to IP addresses, if you wish to bind to hostnames
- * you should first resolve them using class 'Resolver'.
- */
-bool InspIRCd::BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server, int port, char* addr)
-{
- memset(&server,0,sizeof(server));
- insp_inaddr addy;
-
- if (*addr == '*')
- *addr = 0;
-
- if ((*addr) && (insp_aton(addr,&addy) < 1))
- {
- ilog(this,DEBUG,"Invalid IP '%s' given to BindSocket()", addr);
- return false;;
- }
-
-#ifdef IPV6
- server.sin6_family = AF_FAMILY;
-#else
- server.sin_family = AF_FAMILY;
-#endif
- if (!*addr)
- {