Willy Tarreau | 1b90511 | 2015-04-07 21:00:08 +0200 | [diff] [blame] | 1 | #ifndef _NAMESPACE_H |
| 2 | #define _NAMESPACE_H |
KOVACS Krisztian | b3e54fe | 2014-11-17 15:11:45 +0100 | [diff] [blame] | 3 | |
| 4 | #include <stdlib.h> |
| 5 | #include <ebistree.h> |
| 6 | |
Willy Tarreau | e573323 | 2019-05-22 19:24:06 +0200 | [diff] [blame] | 7 | #ifdef USE_NS |
KOVACS Krisztian | b3e54fe | 2014-11-17 15:11:45 +0100 | [diff] [blame] | 8 | |
| 9 | struct netns_entry |
| 10 | { |
| 11 | struct ebpt_node node; |
| 12 | size_t name_len; |
| 13 | int fd; |
| 14 | }; |
| 15 | |
Willy Tarreau | 7520e4f | 2018-11-11 14:38:09 +0100 | [diff] [blame] | 16 | int my_socketat(const struct netns_entry *ns, int domain, int type, int protocol); |
KOVACS Krisztian | b3e54fe | 2014-11-17 15:11:45 +0100 | [diff] [blame] | 17 | struct netns_entry* netns_store_insert(const char *ns_name); |
| 18 | const struct netns_entry* netns_store_lookup(const char *ns_name, size_t ns_name_len); |
| 19 | |
| 20 | int netns_init(void); |
Willy Tarreau | 7520e4f | 2018-11-11 14:38:09 +0100 | [diff] [blame] | 21 | |
| 22 | #else /* no namespace support */ |
| 23 | |
| 24 | struct netns_entry; |
| 25 | |
| 26 | static inline int my_socketat(const struct netns_entry *ns, int domain, int type, int protocol) |
| 27 | { |
| 28 | return socket(domain, type, protocol); |
| 29 | } |
| 30 | |
Willy Tarreau | e573323 | 2019-05-22 19:24:06 +0200 | [diff] [blame] | 31 | #endif /* USE_NS */ |
KOVACS Krisztian | b3e54fe | 2014-11-17 15:11:45 +0100 | [diff] [blame] | 32 | |
Willy Tarreau | 1b90511 | 2015-04-07 21:00:08 +0200 | [diff] [blame] | 33 | #endif /* _NAMESPACE_H */ |