--- 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;
}
|