4 * $DragonFly: src/bin/cpdup/hclink.h,v 1.7 2008/05/24 17:21:36 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
;
30 char rbuf
[65536]; /* input buffer */
31 char wbuf
[65536]; /* output buffer */
35 #define HCTHASH_SIZE 16
36 #define HCTHASH_MASK (HCTHASH_SIZE - 1)
40 char *host
; /* [user@]host */
43 int error
; /* permanent failure code */
45 int version
; /* cpdup protocol version */
46 struct HCHostDesc
*hostdescs
;
48 pthread_mutex_t hct_mutex
[HCTHASH_SIZE
];
49 hctransaction_t hct_hash
[HCTHASH_SIZE
];
50 pthread_t reader_thread
;
52 struct HCTransaction trans
;
57 int32_t magic
; /* magic number / byte ordering */
58 int32_t bytes
; /* size of packet */
59 int16_t cmd
; /* command code */
60 u_int16_t id
; /* transaction id */
61 int32_t error
; /* error code (response) */
64 #define HCMAGIC 0x48435052 /* compatible byte ordering */
65 #define HCMAGIC_REV 0x52504348 /* reverse byte ordering */
66 #define HCC_ALIGN(bytes) (((bytes) + 7) & ~7)
70 int16_t reserved
; /* reserved must be 0 */
74 #define HCF_REPLY 0x8000 /* reply */
76 #define LCF_TYPEMASK 0x0F00
77 #define LCF_INT32 0x0100 /* 4 byte integer */
78 #define LCF_INT64 0x0200 /* 8 byte integer */
79 #define LCF_STRING 0x0300 /* string, must be 0-terminated */
80 #define LCF_BINARY 0x0F00 /* binary data */
82 #define LCF_NESTED 0x8000
86 int (*func
)(hctransaction_t
, struct HCHead
*);
90 * Item extraction macros
92 #define HCC_STRING(item) ((const char *)((item) + 1))
93 #define HCC_INT32(item) (*(int32_t *)((item) + 1))
94 #define HCC_INT64(item) (*(int64_t *)((item) + 1))
95 #define HCC_BINARYDATA(item) ((void *)((item) + 1))
100 int hcc_connect(struct HostConf
*hc
);
101 int hcc_slave(int fdin
, int fdout
, struct HCDesc
*descs
, int count
);
103 hctransaction_t
hcc_start_command(struct HostConf
*hc
, int16_t cmd
);
104 struct HCHead
*hcc_finish_command(hctransaction_t trans
);
105 void hcc_leaf_string(hctransaction_t trans
, int16_t leafid
, const char *str
);
106 void hcc_leaf_data(hctransaction_t trans
, int16_t leafid
, const void *ptr
, int bytes
);
107 void hcc_leaf_int32(hctransaction_t trans
, int16_t leafid
, int32_t value
);
108 void hcc_leaf_int64(hctransaction_t trans
, int16_t leafid
, int64_t value
);
110 int hcc_alloc_descriptor(struct HostConf
*hc
, void *ptr
, int type
);
111 void *hcc_get_descriptor(struct HostConf
*hc
, int desc
, int type
);
112 void hcc_set_descriptor(struct HostConf
*hc
, int desc
, void *ptr
, int type
);
114 struct HCLeaf
*hcc_firstitem(struct HCHead
*head
);
115 struct HCLeaf
*hcc_nextitem(struct HCHead
*head
, struct HCLeaf
*item
);
117 void hcc_debug_dump(struct HCHead
*head
);
118 void hcc_free_trans(struct HostConf
*hc
);