Index: ossp-pkg/l2/l2_ch_socket.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_ch_socket.c,v rcsdiff -q -kk '-r1.29' '-r1.30' -u '/v/ossp/cvs/ossp-pkg/l2/l2_ch_socket.c,v' 2>/dev/null --- 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; } Index: ossp-pkg/l2/l2_test.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_test.c,v rcsdiff -q -kk '-r1.29' '-r1.30' -u '/v/ossp/cvs/ossp-pkg/l2/l2_test.c,v' 2>/dev/null --- 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)