00001 00032 #ifndef LL_NET_H 00033 #define LL_NET_H 00034 00035 class LLTimer; 00036 class LLHost; 00037 00038 #define NET_BUFFER_SIZE (0x2000) 00039 00040 // Request a free local port from the operating system 00041 #define NET_USE_OS_ASSIGNED_PORT 0 00042 00043 // Returns 0 on success, non-zero on error. 00044 // Sets socket handler/descriptor, changes nPort if port requested is unavailable. 00045 S32 start_net(S32& socket_out, int& nPort); 00046 void end_net(S32& socket_out); 00047 00048 // returns size of packet or -1 in case of error 00049 S32 receive_packet(int hSocket, char * receiveBuffer); 00050 00051 BOOL send_packet(int hSocket, const char *sendBuffer, int size, U32 recipient, int nPort); // Returns TRUE on success. 00052 00053 //void get_sender(char * tmp); 00054 LLHost get_sender(); 00055 U32 get_sender_port(); 00056 U32 get_sender_ip(void); 00057 00058 const char* u32_to_ip_string(U32 ip); // Returns pointer to internal string buffer, "(bad IP addr)" on failure, cannot nest calls 00059 char* u32_to_ip_string(U32 ip, char *ip_string); // NULL on failure, ip_string on success, you must allocate at least MAXADDRSTR chars 00060 U32 ip_string_to_u32(const char* ip_string); // Wrapper for inet_addr() 00061 00062 extern const char* LOOPBACK_ADDRESS_STRING; 00063 00064 00065 // useful MTU consts 00066 00067 const S32 MTUBYTES = 1200; // 1500 = standard Ethernet MTU 00068 const S32 ETHERNET_MTU_BYTES = 1500; 00069 const S32 MTUBITS = MTUBYTES*8; 00070 const S32 MTUU32S = MTUBITS/32; 00071 00072 00073 #endif