OSSP CVS Repository

ossp - Difference in ossp-pkg/l2/l2_ut_sa.c versions 1.8 and 1.9
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/l2/l2_ut_sa.c 1.8 -> 1.9

--- l2_ut_sa.c   2001/09/13 20:07:17     1.8
+++ l2_ut_sa.c   2001/09/13 20:13:08     1.9
@@ -582,7 +582,7 @@
 #ifdef AF_INET6
         struct sockaddr_in6 sa6;
 #endif
-    } sa4a6;
+    } sa_buf;
     socklen_t sa_len;
     int s;
 
@@ -602,10 +602,10 @@
         if (n <= 0)
             return SA_ERR_SYS;
     }
-    sa_len = sizeof(sa4a6);
-    if ((s = accept(sa->sSocket, (struct sockaddr *)&sa4a6, &sa_len)) == -1)
+    sa_len = sizeof(sa_buf);
+    if ((s = accept(sa->sSocket, (struct sockaddr *)&sa_buf, &sa_len)) == -1)
         return SA_ERR_SYS;
-    if ((rv = sa_s2a(caddr, (struct sockaddr *)&sa4a6, sa_len)) != SA_OK)
+    if ((rv = sa_s2a(caddr, (struct sockaddr *)&sa_buf, sa_len)) != SA_OK)
         return rv;
     if ((rv = sa_create(csa)) != SA_OK) {
         free(*caddr);
@@ -615,6 +615,44 @@
     return SA_OK;
 }
 
+sa_rc_t sa_getremote(sa_t *sa, sa_addr_t **raddr)
+{
+    sa_rc_t rv;
+    union {
+        struct sockaddr_in sa4;
+#ifdef AF_INET6
+        struct sockaddr_in6 sa6;
+#endif
+    } sa_buf;
+    socklen_t sa_len;
+
+    sa_len = sizeof(sa_buf);
+    if (getpeername(sa->sSocket, (struct sockaddr *)&sa_buf, &sa_len) < 0)
+        return SA_ERR_SYS;
+    if ((rv = sa_s2a(raddr, (struct sockaddr *)&sa_buf, sa_len)) != SA_OK)
+        return rv;
+    return SA_OK;
+}
+
+sa_rc_t sa_getlocal(sa_t *sa, sa_addr_t **laddr)
+{
+    sa_rc_t rv;
+    union {
+        struct sockaddr_in sa4;
+#ifdef AF_INET6
+        struct sockaddr_in6 sa6;
+#endif
+    } sa_buf;
+    socklen_t sa_len;
+
+    sa_len = sizeof(sa_buf);
+    if (getsockname(sa->sSocket, (struct sockaddr *)&sa_buf, &sa_len) < 0)
+        return SA_ERR_SYS;
+    if ((rv = sa_s2a(laddr, (struct sockaddr *)&sa_buf, sa_len)) != SA_OK)
+        return rv;
+    return SA_OK;
+}
+
 static int sa_read_raw(sa_t *sa, char *cpBuf, int nBufLen)
 {
     int rv;

CVSTrac 2.0.1