PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmessage/net.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 71 lines | 25 code | 15 blank | 31 comment | 0 complexity | d32920d9eca9d26eca99f04b7bfc98f1 MD5 | raw file
 1/** 
 2 * @file net.h
 3 * @brief Cross platform UDP network code.
 4 *
 5 * $LicenseInfo:firstyear=2000&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2010, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27#ifndef LL_NET_H					
28#define LL_NET_H
29
30class LLTimer;
31class LLHost;
32
33#define NET_BUFFER_SIZE (0x2000)
34
35// Request a free local port from the operating system
36#define NET_USE_OS_ASSIGNED_PORT 0
37
38// Returns 0 on success, non-zero on error.
39// Sets socket handler/descriptor, changes nPort if port requested is unavailable.
40S32		start_net(S32& socket_out, int& nPort);								
41void	end_net(S32& socket_out);
42
43// returns size of packet or -1 in case of error
44S32		receive_packet(int hSocket, char * receiveBuffer);
45
46BOOL	send_packet(int hSocket, const char *sendBuffer, int size, U32 recipient, int nPort);	// Returns TRUE on success.
47
48//void	get_sender(char * tmp);
49LLHost	get_sender();
50U32		get_sender_port();
51U32		get_sender_ip(void);
52LLHost	get_receiving_interface();
53U32		get_receiving_interface_ip(void);
54
55const char*	u32_to_ip_string(U32 ip);					// Returns pointer to internal string buffer, "(bad IP addr)" on failure, cannot nest calls 
56char*		u32_to_ip_string(U32 ip, char *ip_string);	// NULL on failure, ip_string on success, you must allocate at least MAXADDRSTR chars
57U32			ip_string_to_u32(const char* ip_string);	// Wrapper for inet_addr()
58
59extern const char* LOOPBACK_ADDRESS_STRING;
60extern const char* BROADCAST_ADDRESS_STRING;
61
62
63// useful MTU consts
64
65const S32	MTUBYTES = 1200;	// 1500 = standard Ethernet MTU
66const S32	ETHERNET_MTU_BYTES = 1500;
67const S32	MTUBITS = MTUBYTES*8;
68const S32	MTUU32S = MTUBITS/32;
69
70
71#endif