/*
* IRC - Internet Relay Chat, ircd/os_openbsd.c
- * Copyright (C) 1999 Joseph Bongaarts
+ * Copyright (C) 2001 Joseph Bongaarts
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* $Id$
*
*/
-#include "ircd_osdep.h"
#include "config.h"
+
+#define _XOPEN_SOURCE /* Need this for IOV_MAX */
+
+/* These typedef's are needed for socket.h to be happy. Bleep PROMISES to make
+ * to make this less hackish in the future... HONEST. -GW
+ */
+typedef unsigned char u_char;
+typedef unsigned short u_short;
+typedef unsigned int u_int;
+typedef unsigned long u_long;
+
+#include "ircd_osdep.h"
#include "msgq.h"
#include <assert.h>
(const char*) &opt, sizeof(opt)));
}
-int os_set_sockbufs(int fd, unsigned int size)
+int os_set_sockbufs(int fd, unsigned int ssize, unsigned int rsize)
{
- unsigned int opt = size;
+ unsigned int sopt = ssize;
+ unsigned int ropt = rsize;
return (0 == setsockopt(fd, SOL_SOCKET, SO_RCVBUF,
- (const char*) &opt, sizeof(opt)) &&
+ (const char*) &ropt, sizeof(ropt)) &&
0 == setsockopt(fd, SOL_SOCKET, SO_SNDBUF,
- (const char*) &opt, sizeof(opt)));
+ (const char*) &sopt, sizeof(sopt)));
}
int os_set_tos(int fd,int tos)
return IO_FAILURE;
}
-int os_connect_nonb(int fd, const struct sockaddr_in* sin)
+IOResult os_connect_nonb(int fd, const struct sockaddr_in* sin)
{
- if (connect(fd, (struct sockaddr*) sin, sizeof(struct sockaddr_in))) {
- if (errno != EINPROGRESS)
- return 0;
- }
- return 1;
+ if (connect(fd, (struct sockaddr*) sin, sizeof(struct sockaddr_in)))
+ return (errno == EINPROGRESS) ? IO_BLOCKED : IO_FAILURE;
+ return IO_SUCCESS;
}
int os_get_sockname(int fd, struct sockaddr_in* sin_out)