2012-07-17 07:00:18 +04:00
|
|
|
#ifndef PROTOBUF_H__
|
|
|
|
#define PROTOBUF_H__
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
#include "compiler.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
2012-08-07 02:00:39 +04:00
|
|
|
enum {
|
|
|
|
PB_INVENTORY,
|
|
|
|
PB_FDINFO,
|
|
|
|
PB_CORE,
|
|
|
|
PB_MM,
|
|
|
|
PB_VMAS,
|
|
|
|
PB_SIGACT,
|
|
|
|
PB_ITIMERS,
|
|
|
|
PB_CREDS,
|
|
|
|
PB_FS,
|
|
|
|
PB_UTSNS,
|
|
|
|
PB_IPCNS_VAR,
|
|
|
|
PB_IPCNS_SHM,
|
|
|
|
PB_IPCNS_MSG,
|
|
|
|
PB_IPCNS_MSG_ENT,
|
|
|
|
PB_IPCNS_SEM,
|
|
|
|
PB_MOUNTPOINTS,
|
|
|
|
PB_NETDEV,
|
|
|
|
PB_PSTREE,
|
|
|
|
PB_GHOST_FILE,
|
|
|
|
PB_TCP_STREAM,
|
|
|
|
PB_SK_QUEUES,
|
|
|
|
PB_REG_FILES,
|
|
|
|
PB_INETSK,
|
|
|
|
PB_UNIXSK,
|
2012-08-09 16:17:41 +04:00
|
|
|
PB_PACKETSK,
|
2012-08-07 02:00:39 +04:00
|
|
|
PB_PIPES,
|
|
|
|
PB_FIFO,
|
|
|
|
PB_PIPES_DATA,
|
|
|
|
PB_REMAP_FPATH,
|
|
|
|
PB_EVENTFD,
|
|
|
|
PB_EVENTPOLL,
|
|
|
|
PB_EVENTPOLL_TFD,
|
|
|
|
PB_SIGNALFD,
|
|
|
|
PB_INOTIFY,
|
|
|
|
PB_INOTIFY_WD,
|
|
|
|
|
|
|
|
PB_MAX
|
|
|
|
};
|
2012-07-17 07:00:18 +04:00
|
|
|
/*
|
|
|
|
* ATTENTION
|
|
|
|
*
|
|
|
|
* This typdefs represent "generic" prototypes for
|
|
|
|
* pack/unpack/getsize functions generated by PB
|
|
|
|
* engine, thus (!!!) if PB engine change arguments
|
|
|
|
* order or their number we may meet serious problems.
|
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
*
|
|
|
|
* Find a way to verify PB generated functions statemens
|
|
|
|
* to match this typedefs.
|
|
|
|
*/
|
|
|
|
|
2012-08-07 02:00:39 +04:00
|
|
|
void cr_pb_init(void);
|
|
|
|
|
2012-08-07 02:42:58 +04:00
|
|
|
extern int do_pb_read_one(int fd, void **objp, int type, bool eof);
|
2012-07-17 07:00:18 +04:00
|
|
|
|
2012-08-07 02:42:58 +04:00
|
|
|
#define pb_read_one(fd, objp, type) do_pb_read_one(fd, (void **)objp, type, false)
|
|
|
|
#define pb_read_one_eof(fd, objp, type) do_pb_read_one(fd, (void **)objp, type, true)
|
2012-07-17 07:00:18 +04:00
|
|
|
|
2012-08-07 02:26:50 +04:00
|
|
|
extern int pb_write_one(int fd, void *obj, int type);
|
2012-07-17 07:00:18 +04:00
|
|
|
|
|
|
|
#define pb_pksize(__obj, __proto_message_name) \
|
|
|
|
(__proto_message_name ##__get_packed_size(__obj) + sizeof(u32))
|
|
|
|
|
|
|
|
#define pb_repeated_size(__obj, __member) \
|
|
|
|
(sizeof(*(__obj)->__member) * (__obj)->n_ ##__member)
|
|
|
|
|
2012-08-09 13:16:46 +04:00
|
|
|
#define pb_msg(__base, __type) \
|
|
|
|
container_of(__base, __type, base)
|
|
|
|
|
2012-07-18 19:09:51 +04:00
|
|
|
#include <google/protobuf-c/protobuf-c.h>
|
|
|
|
|
2012-08-07 02:51:34 +04:00
|
|
|
extern void do_pb_show_plain(int fd, int type, int single_entry,
|
2012-07-26 12:43:00 +04:00
|
|
|
void (*payload_hadler)(int fd, void *obj, int flags),
|
2012-08-14 14:49:21 +04:00
|
|
|
int flags, const char *pretty_fmt);
|
2012-07-18 19:09:51 +04:00
|
|
|
|
2012-08-07 02:51:34 +04:00
|
|
|
#define pb_show_plain_payload(__fd, __type, payload_hadler, flags) \
|
2012-08-14 14:49:21 +04:00
|
|
|
do_pb_show_plain(__fd, __type, 0, payload_hadler, flags, NULL)
|
2012-08-07 02:51:34 +04:00
|
|
|
|
|
|
|
#define pb_show_plain(__fd, __type) \
|
|
|
|
pb_show_plain_payload(__fd, __type, NULL, 0)
|
|
|
|
|
|
|
|
#define pb_show_vertical(__fd, __type) \
|
2012-08-14 14:49:21 +04:00
|
|
|
do_pb_show_plain(__fd, __type, 1, NULL, 0, NULL)
|
2012-07-18 13:04:00 +04:00
|
|
|
|
2012-08-09 13:16:46 +04:00
|
|
|
int collect_image(int fd_t, int obj_t, unsigned size,
|
|
|
|
int (*collect)(void *obj, ProtobufCMessage *msg));
|
2012-07-17 07:00:18 +04:00
|
|
|
#endif /* PROTOBUF_H__ */
|