Blob Blame History Raw
diff --git a/ncat/ncat_connect.c b/ncat/ncat_connect.c
index a420126..048dc46 100644
--- a/ncat/ncat_connect.c
+++ b/ncat/ncat_connect.c
@@ -265,20 +265,20 @@ static void connect_report(nsock_iod nsi)
     union sockaddr_u peer;
     zmem(&peer, sizeof(peer.storage));
 
-    nsock_iod_get_communication_info(nsi, NULL, NULL, NULL, &peer.sockaddr,
+    nsi_getlastcommunicationinfo(nsi, NULL, NULL, NULL, &peer.sockaddr,
                                      sizeof(peer.storage));
     if (o.verbose) {
 #ifdef HAVE_OPENSSL
-        if (nsock_iod_check_ssl(nsi)) {
+        if (nsi_checkssl(nsi)) {
             X509 *cert;
             X509_NAME *subject;
             char digest_buf[SHA1_STRING_LENGTH + 1];
             char *fp;
 
             loguser("SSL connection to %s:%d.", inet_socktop(&peer),
-                    nsock_iod_get_peerport(nsi));
+                    nsi_peerport(nsi));
 
-            cert = SSL_get_peer_certificate((SSL *)nsock_iod_get_ssl(nsi));
+            cert = SSL_get_peer_certificate((SSL *)nsi_getssl(nsi));
             ncat_assert(cert != NULL);
 
             subject = X509_get_subject_name(cert);
@@ -303,7 +303,7 @@ static void connect_report(nsock_iod nsi)
             else
 #endif
                 loguser("Connected to %s:%d.\n", inet_socktop(&peer),
-                        nsock_iod_get_peerport(nsi));
+                        nsi_peerport(nsi));
         }
 #else
 #if HAVE_SYS_UN_H
@@ -312,7 +312,7 @@ static void connect_report(nsock_iod nsi)
         else
 #endif
             loguser("Connected to %s:%d.\n", inet_socktop(&peer),
-                    nsock_iod_get_peerport(nsi));
+                    nsi_peerport(nsi));
 #endif
     }
 }
@@ -892,32 +892,32 @@ int ncat_connect(void)
         nsock_set_default_engine("select");
 
     /* Create an nsock pool */
-    if ((mypool = nsock_pool_new(NULL)) == NULL)
+    if ((mypool = nsp_new(NULL)) == NULL)
         bye("Failed to create nsock_pool.");
 
     if (o.debug >= 6)
-        nsock_set_loglevel(NSOCK_LOG_DBG_ALL);
+        nsock_set_loglevel(mypool, NSOCK_LOG_DBG_ALL);
     else if (o.debug >= 3)
-        nsock_set_loglevel(NSOCK_LOG_DBG);
+        nsock_set_loglevel(mypool, NSOCK_LOG_DBG);
     else if (o.debug >= 1)
-        nsock_set_loglevel(NSOCK_LOG_INFO);
+        nsock_set_loglevel(mypool, NSOCK_LOG_INFO);
     else
-        nsock_set_loglevel(NSOCK_LOG_ERROR);
+        nsock_set_loglevel(mypool, NSOCK_LOG_ERROR);
 
     /* Allow connections to broadcast addresses. */
     nsock_pool_set_broadcast(mypool, 1);
 
 #ifdef HAVE_OPENSSL
-    set_ssl_ctx_options((SSL_CTX *) nsock_pool_ssl_init(mypool, 0));
+    set_ssl_ctx_options((SSL_CTX *) nsock_pool_ssl_init(mypool));
 #endif
 
     if (!o.proxytype) {
         /* A non-proxy connection. Create an iod for a new socket. */
-        cs.sock_nsi = nsock_iod_new(mypool, NULL);
+        cs.sock_nsi = nsi_new(mypool, NULL);
         if (cs.sock_nsi == NULL)
             bye("Failed to create nsock_iod.");
 
-        if (nsock_iod_set_hostname(cs.sock_nsi, o.target) == -1)
+        if (nsi_set_hostname(cs.sock_nsi, o.target) == -1)
             bye("Failed to set hostname on iod.");
 
 #if HAVE_SYS_UN_H
@@ -945,7 +945,7 @@ int ncat_connect(void)
                 strncpy(srcaddr.un.sun_path, tmp_name, sizeof(srcaddr.un.sun_path));
                 free (tmp_name);
             }
-            nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage,
+            nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage,
                                 SUN_LEN((struct sockaddr_un *)&srcaddr.storage));
 
             if (o.verbose)
@@ -957,23 +957,23 @@ int ncat_connect(void)
           case AF_UNSPEC:
             break;
           case AF_INET:
-            nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage,
+            nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage,
                                     sizeof(srcaddr.in));
             break;
 #ifdef AF_INET6
           case AF_INET6:
-            nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage,
+            nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage,
                                     sizeof(srcaddr.in6));
             break;
 #endif
 #if HAVE_SYS_UN_H
           case AF_UNIX:
-            nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage,
+            nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage,
                                     SUN_LEN((struct sockaddr_un *)&srcaddr.storage));
             break;
 #endif
           default:
-            nsock_iod_set_localaddr(cs.sock_nsi, &srcaddr.storage,
+            nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage,
                                     sizeof(srcaddr.storage));
             break;
         }
@@ -986,7 +986,7 @@ int ncat_connect(void)
                 bye("Sorry, -g can only currently be used with IPv4.");
             ipopts = buildsrcrte(targetaddrs->addr.in.sin_addr, o.srcrtes, o.numsrcrtes, o.srcrteptr, &ipoptslen);
 
-            nsock_iod_set_ipoptions(cs.sock_nsi, ipopts, ipoptslen);
+            nsi_set_ipoptions(cs.sock_nsi, ipopts, ipoptslen);
             free(ipopts); /* Nsock has its own copy */
         }
 
@@ -1029,10 +1029,10 @@ int ncat_connect(void)
 
         /* Once the proxy negotiation is done, Nsock takes control of the
            socket. */
-        cs.sock_nsi = nsock_iod_new2(mypool, connect_socket, NULL);
+        cs.sock_nsi = nsi_new2(mypool, connect_socket, NULL);
 
         /* Create IOD for nsp->stdin */
-        if ((cs.stdin_nsi = nsock_iod_new2(mypool, 0, NULL)) == NULL)
+        if ((cs.stdin_nsi = nsi_new2(mypool, 0, NULL)) == NULL)
             bye("Failed to create stdin nsiod.");
 
         post_connect(mypool, cs.sock_nsi);
@@ -1049,8 +1049,8 @@ int ncat_connect(void)
         gettimeofday(&end_time, NULL);
         time = TIMEVAL_MSEC_SUBTRACT(end_time, start_time) / 1000.0;
         loguser("%lu bytes sent, %lu bytes received in %.2f seconds.\n",
-            nsock_iod_get_write_count(cs.sock_nsi),
-            nsock_iod_get_read_count(cs.sock_nsi), time);
+            nsi_get_write_count(cs.sock_nsi),
+            nsi_get_read_count(cs.sock_nsi), time);
     }
 
 #if HAVE_SYS_UN_H
@@ -1061,7 +1061,7 @@ int ncat_connect(void)
     }
 #endif
 
-    nsock_pool_delete(mypool);
+    nsp_delete(mypool);
 
     return rc == NSOCK_LOOP_ERROR ? 1 : 0;
 }
@@ -1127,7 +1127,7 @@ static void connect_handler(nsock_pool nsp, nsock_event evt, void *data)
             if (o.verbose) {
                 union sockaddr_u peer;
                 zmem(&peer, sizeof(peer.storage));
-                nsock_iod_get_communication_info(cs.sock_nsi, NULL, NULL, NULL,
+                nsi_getlastcommunicationinfo(cs.sock_nsi, NULL, NULL, NULL,
                     &peer.sockaddr, sizeof(peer.storage));
                 loguser("Connection to %s failed: %s.\n", inet_socktop(&peer), socket_strerror(errcode));
                 loguser("Trying next address...\n");
@@ -1146,10 +1146,10 @@ static void connect_handler(nsock_pool nsp, nsock_event evt, void *data)
     }
 
 #ifdef HAVE_OPENSSL
-    if (nsock_iod_check_ssl(cs.sock_nsi)) {
+    if (nsi_checkssl(cs.sock_nsi)) {
         /* Check the domain name. ssl_post_connect_check prints an
            error message if appropriate. */
-        if (!ssl_post_connect_check((SSL *)nsock_iod_get_ssl(cs.sock_nsi), o.target))
+        if (!ssl_post_connect_check((SSL *)nsi_getssl(cs.sock_nsi), o.target))
             bye("Certificate verification error.");
     }
 #endif
@@ -1160,7 +1160,7 @@ static void connect_handler(nsock_pool nsp, nsock_event evt, void *data)
     }
 
     /* Create IOD for nsp->stdin */
-    if ((cs.stdin_nsi = nsock_iod_new2(nsp, 0, NULL)) == NULL)
+    if ((cs.stdin_nsi = nsi_new2(nsp, 0, NULL)) == NULL)
         bye("Failed to create stdin nsiod.");
 
     post_connect(nsp, nse_iod(evt));
@@ -1174,9 +1174,9 @@ static void post_connect(nsock_pool nsp, nsock_iod iod)
     if (o.cmdexec) {
         struct fdinfo info;
 
-        info.fd = nsock_iod_get_sd(iod);
+        info.fd = nsi_getsd(iod);
 #ifdef HAVE_OPENSSL
-        info.ssl = (SSL *)nsock_iod_get_ssl(iod);
+        info.ssl = (SSL *)nsi_getssl(iod);
 #endif
         /* Convert Nsock's non-blocking socket to an ordinary blocking one. It's
            possible for a program to write fast enough that it will get an
@@ -1217,7 +1217,7 @@ static void read_stdin_handler(nsock_pool nsp, nsock_event evt, void *data)
 
     if (status == NSE_STATUS_EOF) {
       if (!o.noshutdown)
-        shutdown(nsock_iod_get_sd(cs.sock_nsi), SHUT_WR);
+        shutdown(nsi_getsd(cs.sock_nsi), SHUT_WR);
         /* In --send-only mode or non-TCP mode, exit after EOF on stdin. */
         if (o.proto != IPPROTO_TCP || (o.proto == IPPROTO_TCP && o.sendonly))
             nsock_loop_quit(nsp);
@@ -1288,7 +1288,7 @@ static void read_socket_handler(nsock_pool nsp, nsock_event evt, void *data)
         ncat_delay_timer(o.linedelay);
 
     if (o.telnet)
-        dotelnet(nsock_iod_get_sd(nse_iod(evt)), (unsigned char *) buf, nbytes);
+        dotelnet(nsi_getsd(nse_iod(evt)), (unsigned char *) buf, nbytes);
 
     /* Write socket data to stdout */
     Write(STDOUT_FILENO, buf, nbytes);
diff --git a/ncat/util.h b/ncat/util.h
index 63f4c6f..f81d577 100644
--- a/ncat/util.h
+++ b/ncat/util.h
@@ -175,6 +175,8 @@ do { \
 
 void die(char *);
 
+#define NORETURN __attribute__((noreturn))
+
 NORETURN void bye(const char *, ...)
      __attribute__ ((format (printf, 1, 2)));
 
diff --git a/ncat/ncat_connect.c b/ncat/ncat_connect.c
index 048dc46..8680278 100644
--- a/ncat/ncat_connect.c
+++ b/ncat/ncat_connect.c
@@ -905,10 +905,10 @@ int ncat_connect(void)
         nsock_set_loglevel(mypool, NSOCK_LOG_ERROR);
 
     /* Allow connections to broadcast addresses. */
-    nsock_pool_set_broadcast(mypool, 1);
+    nsp_setbroadcast(mypool, 1);
 
 #ifdef HAVE_OPENSSL
-    set_ssl_ctx_options((SSL_CTX *) nsock_pool_ssl_init(mypool));
+    set_ssl_ctx_options((SSL_CTX *) nsp_ssl_init(mypool));
 #endif
 
     if (!o.proxytype) {