xref: /haiku/headers/private/net/r5_compatibility.h (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
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 extern bool __gR5Compatibility;
42 extern addr_t __gNetworkStart;
43 extern addr_t __gNetworkEnd;
44 
45 
46 static inline bool
47 check_r5_compatibility()
48 {
49 	if (!__gR5Compatibility)
50 		return false;
51 
52 #ifndef __i386__
53 	return false;
54 #else
55 
56 	struct stack_frame {
57 		struct stack_frame*	previous;
58 		addr_t					return_address;
59 	};
60 
61 	stack_frame* frame = (stack_frame*)get_stack_frame();
62 	if (frame->return_address >= __gNetworkStart
63 		&& frame->return_address < __gNetworkEnd) {
64 		return false;
65 	}
66 
67 	return true;
68 #endif
69 }
70 
71 
72 #endif	// NET_R5_COMPATIBILITY_H
73