4 * $DragonFly: src/bin/cpdup/hclink.h,v 1.5 2008/04/14 05:40:51 dillon Exp $
11 struct HCHostDesc *next;
19 typedef struct HCTransaction {
20 struct HCTransaction *next;
22 u_int16_t id; /* assigned transaction id */
23 int windex; /* output buffer index */
24 enum { HCT_IDLE, HCT_SENT, HCT_REPLIED, HCT_DONE } state;
28 char rbuf[65536]; /* input buffer */
29 char wbuf[65536]; /* output buffer */
33 #define HCTHASH_SIZE 16
34 #define HCTHASH_MASK (HCTHASH_SIZE - 1)
38 char *host; /* [user@]host */
41 int error; /* permanent failure code */
43 int version; /* cpdup protocol version */
44 struct HCHostDesc *hostdescs;
46 pthread_mutex_t read_mutex;
47 hctransaction_t hct_hash[HCTHASH_SIZE];
49 struct HCTransaction trans;
54 int32_t magic; /* magic number / byte ordering */
55 int32_t bytes; /* size of packet */
56 int16_t cmd; /* command code */
57 u_int16_t id; /* transaction id */
58 int32_t error; /* error code (response) */
61 #define HCMAGIC 0x48435052 /* compatible byte ordering */
62 #define HCMAGIC_REV 0x52504348 /* reverse byte ordering */
63 #define HCC_ALIGN(bytes) (((bytes) + 7) & ~7)
67 int16_t reserved; /* reserved must be 0 */
71 #define HCF_REPLY 0x8000 /* reply */
73 #define LCF_TYPEMASK 0x0F00
74 #define LCF_INT32 0x0100 /* 4 byte integer */
75 #define LCF_INT64 0x0200 /* 8 byte integer */
76 #define LCF_STRING 0x0300 /* string, must be 0-terminated */
77 #define LCF_BINARY 0x0F00 /* binary data */
79 #define LCF_NESTED 0x8000
83 int (*func)(hctransaction_t, struct HCHead *);
87 * Item extraction macros
89 #define HCC_STRING(item) ((const char *)((item) + 1))
90 #define HCC_INT32(item) (*(int32_t *)((item) + 1))
91 #define HCC_INT64(item) (*(int64_t *)((item) + 1))
92 #define HCC_BINARYDATA(item) ((void *)((item) + 1))
97 int hcc_connect(struct HostConf *hc);
98 int hcc_slave(int fdin, int fdout, struct HCDesc *descs, int count);
100 hctransaction_t hcc_start_command(struct HostConf *hc, int16_t cmd);
101 struct HCHead *hcc_finish_command(hctransaction_t trans);
102 void hcc_leaf_string(hctransaction_t trans, int16_t leafid, const char *str);
103 void hcc_leaf_data(hctransaction_t trans, int16_t leafid, const void *ptr, int bytes);
104 void hcc_leaf_int32(hctransaction_t trans, int16_t leafid, int32_t value);
105 void hcc_leaf_int64(hctransaction_t trans, int16_t leafid, int64_t value);
107 int hcc_alloc_descriptor(struct HostConf *hc, void *ptr, int type);
108 void *hcc_get_descriptor(struct HostConf *hc, int desc, int type);
109 void hcc_set_descriptor(struct HostConf *hc, int desc, void *ptr, int type);
111 struct HCLeaf *hcc_firstitem(struct HCHead *head);
112 struct HCLeaf *hcc_nextitem(struct HCHead *head, struct HCLeaf *item);
114 void hcc_debug_dump(struct HCHead *head);
115 void hcc_free_trans(struct HostConf *hc);