diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llmessage/net.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/linden/indra/llmessage/net.h b/linden/indra/llmessage/net.h new file mode 100644 index 0000000..d406006 --- /dev/null +++ b/linden/indra/llmessage/net.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /** | ||
2 | * @file net.h | ||
3 | * @brief Cross platform UDP network code. | ||
4 | * | ||
5 | * Copyright (c) 2000-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_NET_H | ||
29 | #define LL_NET_H | ||
30 | |||
31 | class LLTimer; | ||
32 | class LLHost; | ||
33 | |||
34 | #define NET_BUFFER_SIZE (0x2000) | ||
35 | |||
36 | // Request a free local port from the operating system | ||
37 | #define NET_USE_OS_ASSIGNED_PORT 0 | ||
38 | |||
39 | // Returns 0 on success, non-zero on error. | ||
40 | // Sets socket handler/descriptor, changes nPort if port requested is unavailable. | ||
41 | S32 start_net(S32& socket_out, int& nPort); | ||
42 | void end_net(); | ||
43 | |||
44 | // returns size of packet or -1 in case of error | ||
45 | S32 receive_packet(int hSocket, char * receiveBuffer); | ||
46 | |||
47 | BOOL send_packet(int hSocket, const char *sendBuffer, int size, U32 recipient, int nPort); // Returns TRUE on success. | ||
48 | |||
49 | //void get_sender(char * tmp); | ||
50 | LLHost get_sender(); | ||
51 | U32 get_sender_port(); | ||
52 | U32 get_sender_ip(void); | ||
53 | |||
54 | const char* u32_to_ip_string(U32 ip); // Returns pointer to internal string buffer, "(bad IP addr)" on failure, cannot nest calls | ||
55 | char* u32_to_ip_string(U32 ip, char *ip_string); // NULL on failure, ip_string on success, you must allocate at least MAXADDRSTR chars | ||
56 | U32 ip_string_to_u32(const char* ip_string); // Wrapper for inet_addr() | ||
57 | |||
58 | extern const char* LOOPBACK_ADDRESS_STRING; | ||
59 | |||
60 | |||
61 | // useful MTU consts | ||
62 | |||
63 | const S32 MTUBYTES = 1200; // 1500 = standard Ethernet MTU | ||
64 | const S32 ETHERNET_MTU_BYTES = 1500; | ||
65 | const S32 MTUBITS = MTUBYTES*8; | ||
66 | const S32 MTUU32S = MTUBITS/32; | ||
67 | |||
68 | |||
69 | #endif | ||