#if !defined(_REQUEST_H_) #define _REQUEST_H_ 1 #include #include #include #include #include "netio.h" #include "typemap.h" #include "utils.h" #include "xce/types.h" typedef struct { int wait; } reqbar_t; typedef int (*xce_check_fn_t)(void*); extern int xce_encode(xce_request_t*, io_packet_t*); extern int xce_decode(io_packet_t*, xce_request_t*); extern int xce_reply(endpoint_t*, xce_peerinfo_t*, xce_reply_t*); extern int xce_hello_req(endpoint_t*, char*); extern int xce_nop_req(endpoint_t*); extern int xce_shutdown_req(endpoint_t*); extern void init_reply_by_req(xce_reply_t*, xce_request_t*); extern int xce_join_req(endpoint_t*, int, hostattrs_t*); extern int xce_pushconfig_req(endpoint_t*, xce_peerinfo_t*, xce_configdata_t*); extern int xce_push_data_req(endpoint_t*, xce_peerinfo_t*, xce_data_t*, xce_check_fn_t, void*, int); extern int xce_workerlist_req(endpoint_t*, xce_peerinfo_t*); extern int xce_reply_workerlist(endpoint_t*, uint64_t, int, xce_peerinfo_t*, xce_workerlist_t*); extern int xce_jobdispatch_req(endpoint_t*, xce_job_dispatch_t*); extern int xce_jobsubmit_req(endpoint_t*, xce_job_submit_t*); extern int xce_reply_jobdispatch(endpoint_t*, uint64_t, int32_t, xce_peerinfo_t*); extern int xce_reply_jobid(endpoint_t*, int, uint64_t, uint64_t, xce_peerinfo_t*); extern int xce_joblist_req(endpoint_t*, xce_peerinfo_t*); extern int xce_reply_joblist(endpoint_t*, uint64_t, int, xce_peerinfo_t*, xce_job_list_t*); extern int xce_startjob_req(endpoint_t*, xce_job_exec_t*); extern int xce_clusterconf_req(endpoint_t*); extern int xce_reply_clusterconf(endpoint_t*, uint64_t, int, xce_peerinfo_t*, xce_clusterconf_t*); extern int xce_get_req(endpoint_t*, xce_get_t*); extern int xce_reply_get(endpoint_t*, xce_peerinfo_t*, xce_reply_t*, xce_check_fn_t, void*, int); extern int xce_notify_req(endpoint_t*, xce_notify_data_t*); extern int extract_data(dataset_t*, xce_data_t*); extern int xce_update_req(endpoint_t*, xce_update_data_t*); extern int xce_jobctrl_req(endpoint_t*, xce_jobctrl_t*); extern int xce_queuectrl_req(endpoint_t*, xce_queuectrl_t*); extern int xce_hostctrl_req(endpoint_t*, xce_hostctrl_t*); extern int xce_runtask_req(endpoint_t*, xce_taskrun_t*); extern int xce_set_pend_reason_req(endpoint_t*, xce_preason_set_t*); extern int xce_clear_reason_req(endpoint_t*, xce_clear_reason_t*); /* * xce_replconfigpush_req_raw: send OP_replConfigPush carrying raw byte arrays. * Bypasses the encode_ReplConfigPushRequest_ptr path (which maps sha256/bytes * through xce_data_t — wrong type for raw bytes) by constructing the capnp * message directly via capn_new_list8 + capn_setv8 + write_Request. */ extern int xce_replconfigpush_req_raw(endpoint_t *ep, xce_peerinfo_t *from, uint64_t version_tag, const uint8_t *sha256, size_t sha256_len, const uint8_t *config_bytes, size_t config_len); /* * xce_replconfig_reply_raw: primary sends an OP_replConfig reply with * actual config bytes via endpoint (iomgr queued). Bypasses * encode_ReplConfigReply_ptr (which maps sha256/bytes through xce_data_t). */ extern int xce_replconfig_reply_raw(endpoint_t *ep, xce_peerinfo_t *from, uint64_t seq, uint64_t tag, const uint8_t *sha256, size_t sha256_len, const uint8_t *config, size_t config_len); /* * xce_replconfig_req_ssl: standby sends OP_replConfig over a raw SSL * socket (no iomgr). Wire framing: uint64_t size + capnp payload * (matches netio.c io_fsm_perform). */ extern int xce_replconfig_req_ssl(SSL *ssl, uint64_t version_tag); /* * xce_replconfig_reply_ssl_decode: standby reads + parses an * OP_replConfig reply from a raw SSL socket. Output buffers are * malloc'd and owned by the caller. Both *out_sha256 and *out_bytes * may be NULL on the up_to_date == 1 fast path. */ extern int xce_replconfig_reply_ssl_decode(SSL *ssl, int *out_up_to_date, uint64_t *out_tag, uint8_t **out_sha256, uint8_t **out_bytes, size_t *out_len); /* * xce_upgrade_config_req_extract: extract bytes from a decoded * OP_upgradeConfig request. Returns -ENOTSUP — see request.c * for the architectural finding. Use xce_upgrade_config_req_extract_raw * with the raw packet buffer instead. */ extern int xce_upgrade_config_req_extract(const xce_request_t *req, uint8_t **out_bytes, size_t *out_len, uint8_t **out_sha256); /* * xce_upgrade_config_req_extract_raw: parse OP_upgradeConfig request * bytes from a raw on-wire packet buffer. Output buffers (*out_bytes, * *out_sha256) are malloc'd and owned by the caller. */ extern int xce_upgrade_config_req_extract_raw(const uint8_t *pkt_data, size_t pkt_sz, uint8_t **out_bytes, size_t *out_len, uint8_t **out_sha256); #endif