1 /*
2  *  Copyright 2006  Serge van den Boom <svdb@stack.nl>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18 
19 #include "port.h"
20 
21 #define SOCKET_INTERNAL
22 #include "socket.h"
23 
24 #ifdef USE_WINSOCK
25 #	include <winsock2.h>
26 #else
27 #	include <sys/socket.h>
28 #	include <netinet/in.h>
29 #endif
30 
31 
32 ////////////////////////////////////////////////////////////////////////////
33 
34 
35 const int protocolFamilyTranslation[] = {
36 	/* .[PF_unspec] = */ PF_UNSPEC,
37 	/* .[PF_inet]   = */ PF_INET,
38 	/* .[PF_inet6]  = */ PF_INET6,
39 };
40 
41 const int protocolTranslation[] = {
42 	/* .[IPProto_tcp] = */ IPPROTO_TCP,
43 	/* .[IPProto_udp] = */ IPPROTO_UDP,
44 };
45 
46 const int socketTypeTranslation[] = {
47 	/* .[Sock_stream] = */ SOCK_STREAM,
48 	/* .[Sock_dgram]  = */ SOCK_DGRAM,
49 };
50 
51 
52 Socket *
Socket_open(ProtocolFamily domain,SocketType type,Protocol protocol)53 Socket_open(ProtocolFamily domain, SocketType type, Protocol protocol) {
54 	return Socket_openNative(protocolFamilyTranslation[domain],
55 			socketTypeTranslation[type], protocolTranslation[protocol]);
56 }
57 
58 
59 ////////////////////////////////////////////////////////////////////////////
60 
61 
62