]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
s/host/addr/ in a few network functions
authorTimo Sirainen <tss@iki.fi>
Sun, 18 May 2003 16:37:04 +0000 (19:37 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 18 May 2003 16:37:04 +0000 (19:37 +0300)
--HG--
branch : HEAD

src/imap-login/client.c
src/lib/fd-close-on-exec.c
src/lib/network.c
src/lib/network.h
src/login-common/ssl-proxy-gnutls.c
src/login-common/ssl-proxy-openssl.c
src/master/mail-process.c
src/pop3-login/client.c

index 889b35a95f5963033a4162989467b820dbd2488a..4d068f38278918f54d15ddb64837febd57a87c11 100644 (file)
@@ -49,7 +49,7 @@ static void client_set_title(struct imap_client *client)
        if (!verbose_proctitle || !process_per_connection)
                return;
 
-       host = net_ip2host(&client->common.ip);
+       host = net_ip2addr(&client->common.ip);
        if (host == NULL)
                host = "??";
 
@@ -438,7 +438,7 @@ void client_syslog(struct imap_client *client, const char *text)
 {
        const char *host;
 
-       host = net_ip2host(&client->common.ip);
+       host = net_ip2addr(&client->common.ip);
        if (host == NULL)
                host = "??";
 
index ba31669237ef73eee632057901ed60c3e2563bcc..7f995a717208bc9953a0477a71f889f9805d9fe7 100644 (file)
@@ -68,7 +68,7 @@ void fd_debug_verify_leaks(int first_fd, int last_fd)
                                }
 
                                i_panic("Leaked socket fd %d: %s:%u",
-                                       first_fd, net_ip2host(&addr), port);
+                                       first_fd, net_ip2addr(&addr), port);
                        }
 
                        if (fstat(first_fd, &st) == 0) {
index 875df3b86bbd53fdb73da9f8dcdc50554a0a782e..d75fd1df135002e5350abea4554fa0548933c292 100644 (file)
@@ -499,16 +499,16 @@ int net_getsockname(int fd, struct ip_addr *addr, unsigned int *port)
        return 0;
 }
 
-const char *net_ip2host(const struct ip_addr *ip)
+const char *net_ip2addr(const struct ip_addr *ip)
 {
 #ifdef HAVE_IPV6
-       char host[MAX_IP_LEN+1];
+       char addr[MAX_IP_LEN+1];
 
-       host[MAX_IP_LEN] = '\0';
-       if (inet_ntop(ip->family, &ip->ip, host, MAX_IP_LEN) == NULL)
+       addr[MAX_IP_LEN] = '\0';
+       if (inet_ntop(ip->family, &ip->ip, addr, MAX_IP_LEN) == NULL)
                return NULL;
 
-       return t_strdup(host);
+       return t_strdup(addr);
 #else
        unsigned long ip4;
 
@@ -525,13 +525,13 @@ const char *net_ip2host(const struct ip_addr *ip)
        return 0;
 }
 
-int net_host2ip(const char *host, struct ip_addr *ip)
+int net_addr2ip(const char *addr, struct ip_addr *ip)
 {
-       if (strchr(host, ':') != NULL) {
+       if (strchr(addr, ':') != NULL) {
                /* IPv6 */
                ip->family = AF_INET6;
 #ifdef HAVE_IPV6
-               if (inet_pton(AF_INET6, host, &ip->ip) == 0)
+               if (inet_pton(AF_INET6, addr, &ip->ip) == 0)
                        return -1;
 #else
                ip->ip.s_addr = 0;
@@ -539,7 +539,7 @@ int net_host2ip(const char *host, struct ip_addr *ip)
        } else {
                /* IPv4 */
                ip->family = AF_INET;
-               if (inet_aton(host, (struct in_addr *) &ip->ip) == 0)
+               if (inet_aton(addr, (struct in_addr *) &ip->ip) == 0)
                        return -1;
        }
 
@@ -607,23 +607,23 @@ char *net_getservbyport(unsigned short port)
        return entry == NULL ? NULL : entry->s_name;
 }
 
-int is_ipv4_address(const char *host)
+int is_ipv4_address(const char *addr)
 {
-       while (*host != '\0') {
-               if (*host != '.' && !i_isdigit(*host))
+       while (*addr != '\0') {
+               if (*addr != '.' && !i_isdigit(*addr))
                        return 0;
-                host++;
+                addr++;
        }
 
        return 1;
 }
 
-int is_ipv6_address(const char *host)
+int is_ipv6_address(const char *addr)
 {
-       while (*host != '\0') {
-               if (*host != ':' && !i_isxdigit(*host))
+       while (*addr != '\0') {
+               if (*addr != ':' && !i_isxdigit(*addr))
                        return 0;
-                host++;
+                addr++;
        }
 
        return 1;
index df5bbfeef76314d5ce8ba0f910e116e086051921..b48c0399007cc4dcf860e753bed3a2aca6dd7fc6 100644 (file)
@@ -91,9 +91,9 @@ int net_hosterror_notfound(int error);
 int net_getsockname(int fd, struct ip_addr *addr, unsigned int *port);
 
 /* Returns ip_addr as string, or NULL if ip is invalid. */
-const char *net_ip2host(const struct ip_addr *ip);
+const char *net_ip2addr(const struct ip_addr *ip);
 /* char* -> struct ip_addr translation. */
-int net_host2ip(const char *host, struct ip_addr *ip);
+int net_addr2ip(const char *addr, struct ip_addr *ip);
 
 /* Get socket error */
 int net_geterror(int fd);
@@ -101,7 +101,7 @@ int net_geterror(int fd);
 /* Get name of TCP service */
 char *net_getservbyport(unsigned short port);
 
-int is_ipv4_address(const char *host);
-int is_ipv6_address(const char *host);
+int is_ipv4_address(const char *addr);
+int is_ipv6_address(const char *addr);
 
 #endif
index 50b70bafb02eefad3b78213e1a3bb71c51e922df..c2c3c55e607e3c39493a16e1b94d392d288c897d 100644 (file)
@@ -68,11 +68,11 @@ static int handle_ssl_error(struct ssl_proxy *proxy, int error)
                if (error == GNUTLS_E_WARNING_ALERT_RECEIVED) {
                        i_warning("Received SSL warning alert: %s [%s]",
                                  get_alert_text(proxy),
-                                 net_ip2host(&proxy->ip));
+                                 net_ip2addr(&proxy->ip));
                } else {
                        i_warning("Non-fatal SSL error: %s: %s",
                                  get_alert_text(proxy),
-                                 net_ip2host(&proxy->ip));
+                                 net_ip2addr(&proxy->ip));
                }
                return 0;
        }
@@ -82,11 +82,11 @@ static int handle_ssl_error(struct ssl_proxy *proxy, int error)
                if (error == GNUTLS_E_FATAL_ALERT_RECEIVED) {
                        i_warning("Received SSL fatal alert: %s [%s]",
                                  get_alert_text(proxy),
-                                 net_ip2host(&proxy->ip));
+                                 net_ip2addr(&proxy->ip));
                } else {
                        i_warning("Error reading from SSL client: %s [%s]",
                                  gnutls_strerror(error),
-                                 net_ip2host(&proxy->ip));
+                                 net_ip2addr(&proxy->ip));
                }
        }
 
index 47f741ccdb95fa8a81f13d8f956be57c83960eb1..62386e393e1b53c78396c8ee427c491685adb01c 100644 (file)
@@ -198,7 +198,7 @@ static void ssl_handle_error(struct ssl_proxy *proxy, int ret, const char *func)
                        }
 
                        i_warning("%s syscall failed: %s [%s]",
-                                 func, errstr, net_ip2host(&proxy->ip));
+                                 func, errstr, net_ip2addr(&proxy->ip));
                }
                ssl_proxy_destroy(proxy);
                break;
@@ -209,13 +209,13 @@ static void ssl_handle_error(struct ssl_proxy *proxy, int ret, const char *func)
        case SSL_ERROR_SSL:
                if (verbose_ssl) {
                        i_warning("%s failed: %s [%s]", func, ssl_last_error(),
-                                 net_ip2host(&proxy->ip));
+                                 net_ip2addr(&proxy->ip));
                }
                ssl_proxy_destroy(proxy);
                break;
        default:
                i_warning("%s failed: unknown failure %d (%s) [%s]",
-                         func, err, ssl_last_error(), net_ip2host(&proxy->ip));
+                         func, err, ssl_last_error(), net_ip2addr(&proxy->ip));
                ssl_proxy_destroy(proxy);
                break;
        }
index f8242e5acdad720c386206883577ab1a0aba61c1..b9d91353be0d5d0c07320307f3ba7675fbaf1bfd 100644 (file)
@@ -105,7 +105,7 @@ int create_mail_process(int socket, struct ip_addr *ip,
                        struct auth_master_reply *reply, const char *data)
 {
        static const char *argv[] = { NULL, NULL, NULL };
-       const char *host, *mail, *chroot_dir, *home_dir, *full_home_dir;
+       const char *addr, *mail, *chroot_dir, *home_dir, *full_home_dir;
        char title[1024];
        pid_t pid;
        int i, err;
@@ -216,15 +216,15 @@ int create_mail_process(int socket, struct ip_addr *ip,
        env_put(t_strconcat("MAIL=", mail, NULL));
        env_put(t_strconcat("USER=", data + reply->virtual_user_idx, NULL));
 
-       host = net_ip2host(ip);
-       env_put(t_strconcat("IP=", host, NULL));
+       addr = net_ip2addr(ip);
+       env_put(t_strconcat("IP=", addr, NULL));
 
        if (set->verbose_proctitle) {
-               if (host == NULL)
-                       host = "??";
+               if (addr == NULL)
+                       addr = "??";
 
                i_snprintf(title, sizeof(title), "[%s %s]",
-                          data + reply->virtual_user_idx, host);
+                          data + reply->virtual_user_idx, addr);
                argv[1] = title;
        }
 
index efc99f5ec0e3cae997a6919a88363700d9e93ce7..4fdab6ac6ab0c409b9bf04da911566ba8fbd0ed2 100644 (file)
@@ -42,7 +42,7 @@ static void client_set_title(struct pop3_client *client)
        if (!verbose_proctitle || !process_per_connection)
                return;
 
-       host = net_ip2host(&client->common.ip);
+       host = net_ip2addr(&client->common.ip);
        if (host == NULL)
                host = "??";
 
@@ -323,7 +323,7 @@ void client_syslog(struct pop3_client *client, const char *text)
 {
        const char *host;
 
-       host = net_ip2host(&client->common.ip);
+       host = net_ip2addr(&client->common.ip);
        if (host == NULL)
                host = "??";