1 /* @(#) $Id: os_net.h,v 1.12 2009/06/24 17:06:31 dcid Exp $ */
3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 3) as published by the FSF - Free Software
13 * APIs for many network operations.
22 * Bind a specific port (protocol and a ip).
23 * If the IP is not set, it is going to use ADDR_ANY
26 int OS_Bindporttcp(unsigned int _port, char *_ip);
27 int OS_Bindportudp(unsigned int _port, char *_ip);
30 * Bind to a specific file, using the "mode" permissions in
31 * a Unix Domain socket.
33 int OS_BindUnixDomain(char * path, int mode, int max_msg_size);
34 int OS_ConnectUnixDomain(char * path, int max_msg_size);
35 int OS_getsocketsize(int ossock);
39 * Connect to a TCP/UDP socket
41 int OS_ConnectTCP(unsigned int _port, char *_ip);
42 int OS_ConnectUDP(unsigned int _port, char *_ip);
45 * Receive a UDP packet. Return NULL if failed
47 char *OS_RecvUDP(int socket, int sizet);
48 int OS_RecvConnUDP(int socket, char *buffer, int buffer_size);
52 * Receive a message via a Unix socket
54 int OS_RecvUnix(int socket, int sizet, char *ret);
58 * Receive a TCP packet
60 int OS_AcceptTCP(int socket, char *srcip, int addrsize);
61 char *OS_RecvTCP(int socket, int sizet);
62 int OS_RecvTCPBuffer(int socket, char *buffer, int sizet);
66 * Send a TCP/UDP/UnixSocket packet (in a open socket)
68 int OS_SendTCP(int socket, char *msg);
69 int OS_SendTCPbySize(int socket, int size, char *msg);
71 int OS_SendUnix(int socket, char * msg, int size);
73 int OS_SendUDP(int socket, char *msg);
74 int OS_SendUDPbySize(int socket, int size, char *msg);
80 char *OS_GetHost(char *host, int attempts);