]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/socket.h
Fix crash due to null address in DNS
[user/henk/code/inspircd.git] / include / socket.h
index f97630d0463070d7e3d253415f52723fc4784aae..2941606a397281885d0cb46df394d2694ccce4d5 100644 (file)
@@ -96,10 +96,10 @@ namespace irc
                 * or a negative value upon failure (negative values are invalid file
                 * descriptors)
                 */
-               CoreExport int OpenTCPSocket(const char* addr, int socktype = SOCK_STREAM);
+               CoreExport int OpenTCPSocket(const std::string& addr, int socktype = SOCK_STREAM);
 
                /** Return the size of the structure for syscall passing */
-               CoreExport int sa_size(irc::sockets::sockaddrs& sa);
+               CoreExport int sa_size(const irc::sockets::sockaddrs& sa);
 
                /** Convert an address-port pair into a binary sockaddr
                 * @param addr The IP address, IPv4 or IPv6
@@ -107,7 +107,7 @@ namespace irc
                 * @param sa The structure to place the result in. Will be zeroed prior to conversion
                 * @return true if the conversion was successful, false if not.
                 */
-               CoreExport bool aptosa(const char* addr, int port, irc::sockets::sockaddrs* sa);
+               CoreExport bool aptosa(const std::string& addr, int port, irc::sockets::sockaddrs* sa);
                /** Convert a binary sockaddr to an address-port pair
                 * @param sa The structure to convert
                 * @param addr the IP address
@@ -133,9 +133,6 @@ namespace irc
 class CoreExport ListenSocketBase : public EventHandler
 {
  protected:
-       /** The creator/owner of this object
-        */
-       InspIRCd* ServerInstance;
        /** Socket description (shown in stats p) */
        std::string desc;
 
@@ -160,7 +157,7 @@ class CoreExport ListenSocketBase : public EventHandler
  public:
        /** Create a new listening socket
         */
-       ListenSocketBase(InspIRCd* Instance, int port, const std::string &addr);
+       ListenSocketBase(int port, const std::string &addr);
        /** Handle an I/O event
         */
        void HandleEvent(EventType et, int errornum = 0);
@@ -178,7 +175,7 @@ class CoreExport ListenSocketBase : public EventHandler
        const std::string& GetDescription() { return desc; }
        /** Get port number for socket
         */
-       const int GetPort() { return bind_port; }
+       int GetPort() const { return bind_port; }
 
        /** Get IP address socket is bound to
         */
@@ -200,7 +197,7 @@ class CoreExport ClientListenSocket : public ListenSocketBase
 {
        virtual void OnAcceptReady(int fd);
  public:
-       ClientListenSocket(InspIRCd* Instance, int port, const std::string &addr) : ListenSocketBase(Instance, port, addr) { }
+       ClientListenSocket(int port, const std::string &addr) : ListenSocketBase(port, addr) { }
 };
 
 #endif