struct Socket_tag {
struct socket_function_table *fn;
/* the above variable absolutely *must* be the first in this structure */
- char *error;
+ const char *error;
int s;
Plug plug;
void *private_ptr;
typedef struct Socket_tag *Actual_Socket;
struct SockAddr_tag {
- char *error;
+ const char *error;
/*
* Which address family this address belongs to. AF_INET for
* IPv4; AF_INET6 for IPv6; AF_UNSPEC indicates that name
static int cmpforsearch(void *av, void *bv)
{
Actual_Socket b = (Actual_Socket) bv;
- int as = (int) av, bs = b->s;
+ int as = *(int *)av, bs = b->s;
if (as < bs)
return -1;
if (as > bs)
}
}
-char *error_string(int error)
+const char *error_string(int error)
{
return strerror(error);
}
static void sk_tcp_set_private_ptr(Socket s, void *ptr);
static void *sk_tcp_get_private_ptr(Socket s);
static void sk_tcp_set_frozen(Socket s, int is_frozen);
-static char *sk_tcp_socket_error(Socket s);
+static const char *sk_tcp_socket_error(Socket s);
static struct socket_function_table tcp_fn_table = {
sk_tcp_plug,
sk_tcp_socket_error
};
-Socket sk_register(void *sock, Plug plug)
+Socket sk_register(OSSocket sockfd, Plug plug)
{
Actual_Socket ret;
ret->oobpending = FALSE;
ret->listener = 0;
- ret->s = (int)sock;
+ ret->s = sockfd;
if (ret->s < 0) {
ret->error = error_string(errno);
uxsel_tell(ret);
add234(sktree, ret);
+ sk_addr_free(addr);
+
return (Socket) ret;
}
u_long atmark;
/* Find the Socket structure */
- s = find234(sktree, (void *) fd, cmpforsearch);
+ s = find234(sktree, &fd, cmpforsearch);
if (!s)
return 1; /* boggle */
ret = recv(s->s, buf, sizeof(buf), MSG_OOB);
noise_ultralight(ret);
if (ret <= 0) {
- char *str = (ret == 0 ? "Internal networking trouble" :
- error_string(errno));
+ const char *str = (ret == 0 ? "Internal networking trouble" :
+ error_string(errno));
/* We're inside the Unix frontend here, so we know
* that the frontend handle is unnecessary. */
logevent(NULL, str);
if (s->localhost_only && !ipv4_is_loopback(isa.sin_addr)) {
close(t); /* someone let nonlocal through?! */
- } else if (plug_accepting(s->plug, (void*)t)) {
+ } else if (plug_accepting(s->plug, t)) {
close(t); /* denied or error */
}
break;
* if there's a problem. These functions extract an error message,
* or return NULL if there's no problem.
*/
-char *sk_addr_error(SockAddr addr)
+const char *sk_addr_error(SockAddr addr)
{
return addr->error;
}
-static char *sk_tcp_socket_error(Socket sock)
+static const char *sk_tcp_socket_error(Socket sock)
{
Actual_Socket s = (Actual_Socket) sock;
return s->error;