Branch data Line data Source code
1 : : #ifndef __CR_SOCKETS_H__
2 : : #define __CR_SOCKETS_H__
3 : :
4 : : #include <stdbool.h>
5 : :
6 : : #include "asm/types.h"
7 : :
8 : : #include "protobuf.h"
9 : : #include "protobuf/sk-opts.pb-c.h"
10 : :
11 : : struct fdinfo_list_entry;
12 : : struct sk_opts_entry;
13 : : struct file_desc;
14 : : struct fd_parms;
15 : : struct cr_fdset;
16 : : struct nlmsghdr;
17 : :
18 : : struct socket_desc {
19 : : unsigned int family;
20 : : unsigned int ino;
21 : : struct socket_desc *next;
22 : : int already_dumped;
23 : : };
24 : :
25 : : extern int dump_socket(struct fd_parms *p, int lfd, const int fdinfo);
26 : : extern int dump_socket_opts(int sk, SkOptsEntry *soe);
27 : : extern int restore_socket_opts(int sk, SkOptsEntry *soe);
28 : : extern void release_skopts(SkOptsEntry *);
29 : : extern int restore_prepare_socket(int sk);
30 : :
31 : : extern bool socket_test_collect_bit(unsigned int family, unsigned int proto);
32 : :
33 : : extern int sk_collect_one(int ino, int family, struct socket_desc *d);
34 : : extern int collect_sockets(int pid);
35 : : extern int collect_inet_sockets(void);
36 : : extern struct collect_image_info unix_sk_cinfo;
37 : : extern int collect_unix_sockets(void);
38 : : extern int fix_external_unix_sockets(void);
39 : : extern int resolve_unix_peers(void);
40 : :
41 : : extern struct collect_image_info netlink_sk_cinfo;
42 : :
43 : : extern char *skfamily2s(u32 f);
44 : : extern char *sktype2s(u32 t);
45 : : extern char *skproto2s(u32 p);
46 : : extern char *skstate2s(u32 state);
47 : :
48 : : extern struct socket_desc *lookup_socket(int ino, int family, int proto);
49 : :
50 : : extern const struct fdtype_ops unix_dump_ops;
51 : : extern const struct fdtype_ops inet_dump_ops;
52 : : extern const struct fdtype_ops inet6_dump_ops;
53 : : extern const struct fdtype_ops netlink_dump_ops;
54 : : extern const struct fdtype_ops packet_dump_ops;
55 : :
56 : : extern int inet_collect_one(struct nlmsghdr *h, int family, int type);
57 : : extern int unix_receive_one(struct nlmsghdr *h, void *);
58 : : extern int netlink_receive_one(struct nlmsghdr *hdr, void *arg);
59 : :
60 : : extern int do_dump_opt(int sk, int level, int name, void *val, int len);
61 : : #define dump_opt(s, l, n, f) do_dump_opt(s, l, n, f, sizeof(*f))
62 : : extern int do_restore_opt(int sk, int level, int name, void *val, int len);
63 : : #define restore_opt(s, l, n, f) do_restore_opt(s, l, n, f, sizeof(*f))
64 : :
65 : : #define sk_encode_shutdown(img, mask) do { \
66 : : /* \
67 : : * protobuf SK_SHUTDOWN__ bits match those \
68 : : * reported by kernel \
69 : : */ \
70 : : (img)->shutdown = mask; \
71 : : if ((img)->shutdown != SK_SHUTDOWN__NONE) \
72 : : (img)->has_shutdown = true; \
73 : : } while (0)
74 : :
75 : : static inline int sk_decode_shutdown(int val)
76 : : {
77 : : static const int hows[] = {-1, SHUT_RD, SHUT_WR, SHUT_RDWR};
78 : 10 : return hows[val];
79 : : }
80 : :
81 : : #define USK_EXT_PARAM "ext-unix-sk"
82 : :
83 : : #endif /* __CR_SOCKETS_H__ */
|