2012-12-24 15:36:14 +04:00
|
|
|
#ifndef __CR_SOCKETS_H__
|
|
|
|
#define __CR_SOCKETS_H__
|
2011-12-27 14:24:47 +04:00
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2013-01-09 17:02:47 +04:00
|
|
|
#include "asm/types.h"
|
2011-12-27 14:24:47 +04:00
|
|
|
|
2012-07-19 09:23:50 +04:00
|
|
|
#include "protobuf.h"
|
2013-02-15 17:33:06 +04:00
|
|
|
#include "protobuf/sk-opts.pb-c.h"
|
2012-07-19 09:23:50 +04:00
|
|
|
|
2012-04-05 12:45:30 +04:00
|
|
|
struct fdinfo_list_entry;
|
2012-05-12 19:47:00 +04:00
|
|
|
struct sk_opts_entry;
|
|
|
|
struct file_desc;
|
|
|
|
struct fd_parms;
|
|
|
|
struct cr_fdset;
|
|
|
|
struct nlmsghdr;
|
2012-04-26 14:30:42 +04:00
|
|
|
|
|
|
|
struct socket_desc {
|
|
|
|
unsigned int family;
|
|
|
|
unsigned int ino;
|
|
|
|
struct socket_desc *next;
|
|
|
|
int already_dumped;
|
|
|
|
};
|
|
|
|
|
2013-01-11 13:22:41 +04:00
|
|
|
extern int dump_socket(struct fd_parms *p, int lfd, const int fdinfo);
|
2012-07-19 09:44:20 +04:00
|
|
|
extern int dump_socket_opts(int sk, SkOptsEntry *soe);
|
|
|
|
extern int restore_socket_opts(int sk, SkOptsEntry *soe);
|
2012-11-01 17:53:57 +03:00
|
|
|
extern void release_skopts(SkOptsEntry *);
|
2012-11-02 13:40:54 +04:00
|
|
|
extern int restore_prepare_socket(int sk);
|
2012-07-19 09:23:50 +04:00
|
|
|
|
2013-03-27 23:51:03 +04:00
|
|
|
extern bool socket_test_collect_bit(unsigned int family, unsigned int proto);
|
|
|
|
|
2012-05-12 19:47:00 +04:00
|
|
|
extern int sk_collect_one(int ino, int family, struct socket_desc *d);
|
2012-08-11 13:12:43 +04:00
|
|
|
extern int collect_sockets(int pid);
|
2012-05-12 19:47:00 +04:00
|
|
|
extern int collect_inet_sockets(void);
|
2013-08-21 03:52:18 +04:00
|
|
|
extern struct collect_image_info unix_sk_cinfo;
|
2012-05-12 19:47:00 +04:00
|
|
|
extern int collect_unix_sockets(void);
|
|
|
|
extern int fix_external_unix_sockets(void);
|
|
|
|
extern int resolve_unix_peers(void);
|
|
|
|
|
2013-08-21 03:52:18 +04:00
|
|
|
extern struct collect_image_info netlink_sk_cinfo;
|
2013-03-25 19:28:48 +04:00
|
|
|
|
2012-05-12 19:47:00 +04:00
|
|
|
extern char *skfamily2s(u32 f);
|
|
|
|
extern char *sktype2s(u32 t);
|
|
|
|
extern char *skproto2s(u32 p);
|
|
|
|
extern char *skstate2s(u32 state);
|
|
|
|
|
2013-03-27 23:51:03 +04:00
|
|
|
extern struct socket_desc *lookup_socket(int ino, int family, int proto);
|
2012-05-12 19:47:00 +04:00
|
|
|
|
2013-06-14 00:11:08 +04:00
|
|
|
extern const struct fdtype_ops unix_dump_ops;
|
|
|
|
extern const struct fdtype_ops inet_dump_ops;
|
|
|
|
extern const struct fdtype_ops inet6_dump_ops;
|
|
|
|
extern const struct fdtype_ops netlink_dump_ops;
|
|
|
|
extern const struct fdtype_ops packet_dump_ops;
|
2012-05-12 19:47:00 +04:00
|
|
|
|
2013-03-28 16:24:45 +04:00
|
|
|
extern int inet_collect_one(struct nlmsghdr *h, int family, int type);
|
2012-08-02 07:28:45 +04:00
|
|
|
extern int unix_receive_one(struct nlmsghdr *h, void *);
|
2013-03-25 19:28:46 +04:00
|
|
|
extern int netlink_receive_one(struct nlmsghdr *hdr, void *arg);
|
2012-05-12 19:47:00 +04:00
|
|
|
|
2012-08-09 17:25:11 +04:00
|
|
|
extern int do_dump_opt(int sk, int level, int name, void *val, int len);
|
|
|
|
#define dump_opt(s, l, n, f) do_dump_opt(s, l, n, f, sizeof(*f))
|
|
|
|
extern int do_restore_opt(int sk, int level, int name, void *val, int len);
|
|
|
|
#define restore_opt(s, l, n, f) do_restore_opt(s, l, n, f, sizeof(*f))
|
|
|
|
|
2012-10-24 18:31:42 +04:00
|
|
|
#define sk_encode_shutdown(img, mask) do { \
|
2013-12-11 14:03:12 -08:00
|
|
|
/* \
|
2012-10-24 18:31:42 +04:00
|
|
|
* protobuf SK_SHUTDOWN__ bits match those \
|
|
|
|
* reported by kernel \
|
2013-12-11 14:03:12 -08:00
|
|
|
*/ \
|
2012-10-24 18:31:42 +04:00
|
|
|
(img)->shutdown = mask; \
|
|
|
|
if ((img)->shutdown != SK_SHUTDOWN__NONE) \
|
|
|
|
(img)->has_shutdown = true; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
static inline int sk_decode_shutdown(int val)
|
|
|
|
{
|
|
|
|
static const int hows[] = {-1, SHUT_RD, SHUT_WR, SHUT_RDWR};
|
|
|
|
return hows[val];
|
|
|
|
}
|
2012-07-01 14:42:42 +04:00
|
|
|
|
2013-03-26 19:32:53 +04:00
|
|
|
#define USK_EXT_PARAM "ext-unix-sk"
|
|
|
|
|
2012-12-25 22:40:24 +04:00
|
|
|
#endif /* __CR_SOCKETS_H__ */
|