--- l2_ch_socket.c 2001/09/05 16:15:38 1.13
+++ l2_ch_socket.c 2001/09/06 14:37:53 1.14
@@ -110,7 +110,7 @@
/* allocate private channel configuration */
if ((cfg = (l2_ch_socket_t *)malloc(sizeof(l2_ch_socket_t))) == NULL)
- return L2_ERROR;
+ return L2_ERR_MEM;
/* initialize configuration with reasonable defaults */
cfg->pszHost = NULL;
@@ -132,7 +132,7 @@
/* parameter checks */
if ((cfg = (l2_ch_socket_t *)ctx->vp) == NULL)
- return L2_ERROR;
+ return L2_ERR_ARG;
/* feed and call generic parameter parsing engine */
L2_PARAM_SET(pa[0], ipversion, INT, &cfg->iFamily);
@@ -155,9 +155,9 @@
/* parameter checks */
if ((cfg = (l2_ch_socket_t *)ctx->vp) == NULL)
- return L2_ERROR;
+ return L2_ERR_ARG;
if (cfg->pszHost == NULL)
- return L2_ERROR;
+ return L2_ERR_USE;
/* open channel socket */
if (cfg->iFamily == AF_INET) /* IPv4 */
@@ -181,19 +181,19 @@
}
else
- return L2_ERROR; /* what?? we specify IPv4 when it is not? */
+ return L2_ERR_USE; /* what?? we specify IPv4 when it is not? */
}
else /* host string was not parsable for some reason */
- return L2_ERROR;
+ return L2_ERR_SYS;
if ((cfg->iSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
- return L2_ERROR;
+ return L2_ERR_SYS;
if (connect(cfg->iSocket, (struct sockaddr *)&IP4Sockaddr, sizeof(IP4Sockaddr)))
{
close(cfg->iSocket);
- return L2_ERROR;
+ return L2_ERR_SYS;
}
return L2_OK; /* we are connected */
@@ -220,25 +220,25 @@
}
else
- return L2_ERROR; /* what?? we specify IPv6 when it is not? */
+ return L2_ERR_USE; /* what?? we specify IPv6 when it is not? */
}
else /* host string was not parsable for some reason */
- return L2_ERROR;
+ return L2_ERR_SYS;
if ((cfg->iSocket = socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP)) == -1)
- return L2_ERROR;
+ return L2_ERR_SYS;
if (connect(cfg->iSocket, (struct sockaddr *)&IP6Sockaddr, sizeof(IP6Sockaddr)))
{
close(cfg->iSocket);
- return L2_ERROR;
+ return L2_ERR_SYS;
}
return L2_OK; /* we are connected */
}
- return L2_ERROR;
+ return L2_ERR_USE;
}
/* write to channel */
@@ -251,9 +251,9 @@
/* parameter checks */
if ((cfg = (l2_ch_socket_t *)ctx->vp) == NULL)
- return L2_ERROR;
+ return L2_ERR_ARG;
if (cfg->iSocket == -1)
- return L2_ERROR;
+ return L2_ERR_USE;
/* write message to channel socket, but check to make */
/* sure that the whole message was successfully written */
@@ -265,7 +265,7 @@
sizeRemain = sizeRemain - sizeWrite; /* how much is left? */
if (sizeWrite == -1)
- return L2_ERROR;
+ return L2_ERR_SYS;
}
return L2_OK;
@@ -286,13 +286,13 @@
/* parameter checks */
if ((cfg = (l2_ch_socket_t *)ctx->vp) == NULL)
- return L2_ERROR;
+ return L2_ERR_ARG;
if (cfg->iSocket == -1)
- return L2_ERROR;
+ return L2_ERR_USE;
/* close channel socket */
if ((shutdown(cfg->iSocket, SHUT_RDWR)) || (close(cfg->iSocket)))
- return L2_ERROR;
+ return L2_ERR_SYS;
return L2_OK;
}
@@ -302,7 +302,7 @@
{
/* parameter checks */
if (ctx->vp == NULL)
- return L2_ERROR;
+ return L2_ERR_ARG;
/* destroy channel configuration */
free(ctx->vp);
|