Document some variables which were added with Andreas Hauser's rc.firewall
[dragonfly/vkernel-mp.git] / bin / cpdup / hclink.h
blob6f767202595fdff2558fe7669ba0ed28bd12d354
1 /*
2 * HCLINK.H
4 * $DragonFly: src/bin/cpdup/hclink.h,v 1.1 2006/08/13 22:51:40 dillon Exp $
5 */
7 #ifndef _HCLINK_H_
8 #define _HCLINK_H_
10 struct HCHostDesc {
11 struct HCHostDesc *next;
12 int desc;
13 int type;
14 void *data;
17 struct HostConf {
18 char *host; /* [user@]host */
19 int fdin; /* pipe */
20 int fdout; /* pipe */
21 int error; /* permanent failure code */
22 pid_t pid;
23 int windex; /* output buffer index */
24 struct HCHostDesc *hostdescs;
25 char rbuf[65536]; /* output buffer */
26 char wbuf[65536]; /* output buffer */
29 struct HCHead {
30 int32_t magic; /* magic number / byte ordering */
31 int32_t bytes; /* size of packet */
32 int16_t cmd; /* command code */
33 int16_t id; /* transaction id */
34 int32_t error; /* error code (response) */
37 #define HCMAGIC 0x48435052 /* compatible byte ordering */
38 #define HCMAGIC_REV 0x52504348 /* reverse byte ordering */
39 #define HCC_ALIGN(bytes) (((bytes) + 7) & ~7)
41 struct HCLeaf {
42 int16_t leafid;
43 int16_t reserved; /* reserved must be 0 */
44 int32_t bytes;
47 #define HCF_REPLY 0x8000 /* reply */
49 #define LCF_TYPEMASK 0x0F00
50 #define LCF_INT32 0x0100 /* 4 byte integer */
51 #define LCF_INT64 0x0200 /* 8 byte integer */
52 #define LCF_STRING 0x0300 /* string, must be 0-terminated */
53 #define LCF_BINARY 0x0F00 /* binary data */
55 #define LCF_NESTED 0x8000
57 struct HCDesc {
58 int16_t cmd;
59 int (*func)(struct HostConf *, struct HCHead *);
63 * Item extraction macros
65 #define HCC_STRING(item) ((const char *)((item) + 1))
66 #define HCC_INT32(item) (*(int32_t *)((item) + 1))
67 #define HCC_INT64(item) (*(int64_t *)((item) + 1))
68 #define HCC_BINARYDATA(item) ((void *)((item) + 1))
71 * Prototypes
73 int hcc_connect(struct HostConf *hc);
74 int hcc_slave(int fdin, int fdout, struct HCDesc *descs, int count);
76 void hcc_start_command(struct HostConf *hc, int16_t cmd);
77 struct HCHead *hcc_finish_command(struct HostConf *hc);
78 void hcc_leaf_string(struct HostConf *hc, int16_t leafid, const char *str);
79 void hcc_leaf_data(struct HostConf *hc, int16_t leafid, const void *ptr, int bytes);
80 void hcc_leaf_int32(struct HostConf *hc, int16_t leafid, int32_t value);
81 void hcc_leaf_int64(struct HostConf *hc, int16_t leafid, int64_t value);
83 int hcc_alloc_descriptor(struct HostConf *hc, void *ptr, int type);
84 void *hcc_get_descriptor(struct HostConf *hc, int desc, int type);
85 void hcc_set_descriptor(struct HostConf *hc, int desc, void *ptr, int type);
87 struct HCLeaf *hcc_firstitem(struct HCHead *head);
88 struct HCLeaf *hcc_nextitem(struct HCHead *head, struct HCLeaf *item);
90 void hcc_debug_dump(struct HCHead *head);
92 #endif