--- l2_ch_socket.c 2001/09/04 13:52:59 1.7
+++ l2_ch_socket.c 2001/09/04 15:41:17 1.8
@@ -95,7 +95,7 @@
} l2_ch_socket_t;
/* create channel */
-static int hook_create(l2_context_t *ctx)
+static int hook_create(l2_context_t *ctx, l2_channel_t *ch)
{
l2_ch_socket_t *cfg = NULL;
@@ -115,7 +115,7 @@
}
/* configure channel */
-static int hook_configure(l2_context_t *ctx, const char *fmt, va_list ap)
+static int hook_configure(l2_context_t *ctx, l2_channel_t *ch, const char *fmt, va_list ap)
{
l2_ch_socket_t *cfg;
l2_param_t pa[3];
@@ -135,12 +135,13 @@
}
/* open channel */
-static int hook_open(l2_context_t *ctx, l2_channel_t *downstream)
+static int hook_open(l2_context_t *ctx, l2_channel_t *ch)
{
l2_ch_socket_t *cfg;
struct hostent *pHostentry;
struct sockaddr_in IP4Sockaddr;
struct sockaddr_in6 IP6Sockaddr;
+ l2_channel_t *downstream;
/* parameter checks */
if ((cfg = (l2_ch_socket_t *)ctx->vp) == NULL)
@@ -188,7 +189,7 @@
}
/* optionally open downstream channel, too */
- if (downstream != NULL)
+ if ((downstream = l2_channel_downstream(ch)) != NULL)
if (l2_channel_open(downstream) == L2_ERROR)
return L2_ERROR;
@@ -196,10 +197,11 @@
}
/* write to channel */
-static int hook_write(l2_context_t *ctx, l2_channel_t *downstream,
+static int hook_write(l2_context_t *ctx, l2_channel_t *ch,
const char *buf, size_t buf_size)
{
l2_ch_socket_t *cfg;
+ l2_channel_t *downstream;
/* parameter checks */
if ((cfg = (l2_ch_socket_t *)ctx->vp) == NULL)
@@ -212,7 +214,7 @@
return L2_ERROR;
/* optionally write to downstream channel, too */
- if (downstream != NULL)
+ if ((downstream = l2_channel_downstream(ch)) != NULL)
if (l2_channel_write(downstream, buf, buf_size) == L2_ERROR)
return L2_ERROR;
@@ -220,12 +222,14 @@
}
/* flush channel */
-static int hook_flush(l2_context_t *ctx, l2_channel_t *downstream)
+static int hook_flush(l2_context_t *ctx, l2_channel_t *ch)
{
+ l2_channel_t *downstream;
+
/* NOP for this channel, because Unix I/O sockets are unbuffered! */
/* optionally flush downstream channel, too */
- if (downstream != NULL)
+ if ((downstream = l2_channel_downstream(ch)) != NULL)
if (l2_channel_flush(downstream) == L2_ERROR)
return L2_ERROR;
@@ -233,12 +237,13 @@
}
/* close channel */
-static int hook_close(l2_context_t *ctx, l2_channel_t *downstream)
+static int hook_close(l2_context_t *ctx, l2_channel_t *ch)
{
l2_ch_socket_t *cfg;
+ l2_channel_t *downstream;
/* optionally close downstream channel, too */
- if (downstream != NULL)
+ if ((downstream = l2_channel_downstream(ch)) != NULL)
if (l2_channel_close(downstream) == L2_ERROR)
return L2_ERROR;
@@ -256,7 +261,7 @@
}
/* destroy channel */
-static int hook_destroy(l2_context_t *ctx)
+static int hook_destroy(l2_context_t *ctx, l2_channel_t *ch)
{
/* parameter checks */
if (ctx->vp == NULL)
@@ -270,6 +275,7 @@
/* exported channel handler structure */
l2_handler_t l2_handler_socket = {
+ L2_CHANNEL_OUTPUT,
hook_create,
hook_configure,
hook_open,
|