OSSP CVS Repository

ossp - Check-in [1070]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1070
Date: 2001-Oct-04 15:35:47 (local)
2001-Oct-04 13:35:47 (UTC)
User:ms
Branch:
Comment: More socket channel configuration parameter adjustments.
Tickets:
Inspections:
Files:
ossp-pkg/l2/l2_ch_socket.c      1.29 -> 1.30     26 inserted, 3 deleted
ossp-pkg/l2/l2_test.c      1.29 -> 1.30     2 inserted, 2 deleted

ossp-pkg/l2/l2_ch_socket.c 1.29 -> 1.30

--- l2_ch_socket.c       2001/09/26 08:55:19     1.29
+++ l2_ch_socket.c       2001/10/04 13:35:47     1.30
@@ -120,17 +120,40 @@
 static l2_result_t hook_configure(l2_context_t *ctx, l2_channel_t *ch, const char *fmt, va_list ap)
 {
     l2_ch_socket_t *cfg = (l2_ch_socket_t *)ctx->vp;
+    char *szProtocol = NULL;
+    char *szFamily = NULL;
     l2_param_t pa[5];
     l2_result_t rv;
 
     /* feed and call generic parameter parsing engine */
-    L2_PARAM_SET(pa[0], ipversion, INT,     &cfg->iFamily);
-    L2_PARAM_SET(pa[1], protocol,  INT,     &cfg->iProto );
+    L2_PARAM_SET(pa[0], ipversion, STRING,  szFamily);
+    L2_PARAM_SET(pa[1], protocol,  STRING,  szProtocol);
     L2_PARAM_SET(pa[2], host,      CHARPTR, &cfg->szHost);
-    L2_PARAM_SET(pa[3], port,      INT,     &cfg->iPort  );
+    L2_PARAM_SET(pa[3], port,      INT,     &cfg->iPort);
     L2_PARAM_END(pa[4]);
     rv = l2_util_setparams(pa, fmt, ap);
 
+    /* translate incoming configuration parameters */
+    if (szFamily != NULL) {
+        if (strcmp(szFamily, "AF_INET6") == 0)
+            cfg->iFamily = AF_INET6;
+        else if (strcmp(szFamily, "AF_INET") == 0)
+            cfg->iFamily = AF_INET;
+        else
+            return L2_ERR_ARG;
+    }
+
+    if (szProtocol != NULL) {
+        if (strcmp(szProtocol, "IPPROTO_UDP") == 0)
+            cfg->iProto = IPPROTO_UDP;
+        else if (strcmp(szProtocol, "IPPROTO_TCP") == 0)
+            cfg->iProto = IPPROTO_TCP;
+        else
+            return L2_ERR_ARG;
+    }
+
+    free(szFamily);
+    free(szProtocol);
     return rv;
 }
 


ossp-pkg/l2/l2_test.c 1.29 -> 1.30

--- l2_test.c    2001/10/04 12:53:54     1.29
+++ l2_test.c    2001/10/04 13:35:47     1.30
@@ -165,11 +165,11 @@
         die("failed to create socket channel");
 
     if (l2_channel_configure(chSock, "protocol,ipversion,host,port",\
-        "tcp", "ipv4", "localhost", 2002) != L2_OK)
+        "IPPROTO_TCP", "AF_INET", "localhost", 2002) != L2_OK)
         die("failed to configure socket tcp/ipv4 channel");
 #if 0
     if (l2_channel_configure(chSock, "protocol,ipversion,host,port",\
-          "tcp", "ipv6", "0:0:0:0:0:0:0:1", 2002) != L2_OK)
+          "IPPROTO_TCP", "AF_INET6", "0:0:0:0:0:0:0:1", 2002) != L2_OK)
           die("failed to configure socket tcp/ipv6 channel");
 #endif
     if (l2_channel_open(chSock) != L2_OK)

CVSTrac 2.0.1