xref: /haiku/headers/private/net/r5_compatibility.h (revision fc7456e9b1ec38c941134ed6d01c438cf289381e)
1 /*
2  * Copyright 2006, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef NET_R5_COMPATIBILITY_H
6 #define NET_R5_COMPATIBILITY_H
7 
8 
9 #include <SupportDefs.h>
10 
11 
12 #define R5_SOCK_DGRAM	1
13 #define R5_SOCK_STREAM	2
14 
15 #define R5_AF_INET		1
16 
17 #define R5_IPPROTO_UDP	1
18 #define R5_IPPROTO_TCP	2
19 #define R5_IPPROTO_ICMP	3
20 
21 // setsockopt() defines
22 
23 #define R5_SOL_SOCKET	1
24 
25 #define R5_SO_DEBUG		1
26 #define R5_SO_REUSEADDR	2
27 #define R5_SO_NONBLOCK	3
28 #define R5_SO_REUSEPORT	4
29 #define R5_SO_FIONREAD	5
30 
31 #define R5_MSG_OOB		0x01
32 
33 
34 struct r5_sockaddr_in {
35 	uint16	sin_family;
36 	uint16	sin_port;
37 	uint32	sin_addr;
38 	char	sin_zero[4];
39 };
40 
41 
42 #ifdef __HAIKU_BEOS_COMPATIBLE
43 extern bool __gR5Compatibility;
44 extern addr_t __gNetworkStart;
45 extern addr_t __gNetworkEnd;
46 
47 
48 static inline bool
49 check_r5_compatibility()
50 {
51 	if (!__gR5Compatibility)
52 		return false;
53 
54 #ifndef __i386__
55 	return false;
56 #else
57 
58 	struct stack_frame {
59 		struct stack_frame*	previous;
60 		addr_t					return_address;
61 	};
62 
63 	stack_frame* frame = (stack_frame*)get_stack_frame();
64 	if (frame->return_address >= __gNetworkStart
65 		&& frame->return_address < __gNetworkEnd) {
66 		return false;
67 	}
68 
69 	return true;
70 #endif
71 }
72 #else
73 #define check_r5_compatibility() (false)
74 #endif
75 
76 
77 #endif	// NET_R5_COMPATIBILITY_H
78