MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / runtime_hello_response_decode

Function runtime_hello_response_decode

src/daemon/runtime.c:923–976  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

921}
922
923static bool runtime_hello_response_decode(
924 const uint8_t payload[CBM_DAEMON_RENDEZVOUS_RESPONSE_SIZE],
925 cbm_daemon_runtime_connect_result_t *result) {
926 if (!payload || !result) {
927 return false;
928 }
929 memset(result, 0, sizeof(*result));
930 result->status = (cbm_daemon_runtime_connect_status_t)runtime_get_u32(
931 payload + RENDEZVOUS_RESPONSE_CONNECT_STATUS_OFFSET);
932 result->hello_status = (cbm_daemon_hello_status_t)runtime_get_u32(
933 payload + RENDEZVOUS_RESPONSE_HELLO_STATUS_OFFSET);
934 result->client_id = runtime_get_u64(payload + RENDEZVOUS_RESPONSE_CLIENT_ID_OFFSET);
935 result->authenticated_process_id =
936 runtime_get_u64(payload + RENDEZVOUS_RESPONSE_PROCESS_ID_OFFSET);
937 result->conflict.status = (cbm_daemon_hello_status_t)runtime_get_u32(
938 payload + RENDEZVOUS_RESPONSE_CONFLICT_STATUS_OFFSET);
939 if (!runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_ACTIVE_VERSION_OFFSET,
940 CBM_DAEMON_RENDEZVOUS_VERSION_TEXT_CAP,
941 result->conflict.active_version, true) ||
942 !runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_ACTIVE_BUILD_OFFSET,
943 CBM_DAEMON_RENDEZVOUS_BUILD_FINGERPRINT_CAP,
944 result->conflict.active_build_fingerprint, true) ||
945 !runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_REQUESTED_VERSION_OFFSET,
946 CBM_DAEMON_RENDEZVOUS_VERSION_TEXT_CAP,
947 result->conflict.requested_version, true) ||
948 !runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_REQUESTED_BUILD_OFFSET,
949 CBM_DAEMON_RENDEZVOUS_BUILD_FINGERPRINT_CAP,
950 result->conflict.requested_build_fingerprint, true) ||
951 !runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_MESSAGE_OFFSET,
952 CBM_DAEMON_RENDEZVOUS_MESSAGE_CAP, result->message, true)) {
953 return false;
954 }
955 if (result->status == CBM_DAEMON_RUNTIME_CONNECT_ACCEPTED) {
956 return result->hello_status == CBM_DAEMON_HELLO_COMPATIBLE &&
957 result->conflict.status == CBM_DAEMON_HELLO_COMPATIBLE &&
958 result->client_id != CBM_DAEMON_CLIENT_ID_INVALID &&
959 result->authenticated_process_id != 0;
960 }
961 if (result->status == CBM_DAEMON_RUNTIME_CONNECT_CONFLICT) {
962 char expected[CBM_DAEMON_RENDEZVOUS_MESSAGE_CAP];
963 return result->hello_status >= CBM_DAEMON_HELLO_VERSION_CONFLICT &&
964 result->hello_status <= CBM_DAEMON_HELLO_FEATURE_ABI_CONFLICT &&
965 result->conflict.status == result->hello_status &&
966 result->client_id == CBM_DAEMON_CLIENT_ID_INVALID &&
967 result->authenticated_process_id == 0 &&
968 cbm_daemon_conflict_format(&result->conflict, expected, sizeof(expected)) &&
969 strcmp(result->message, expected) == 0;
970 }
971 return result->status == CBM_DAEMON_RUNTIME_CONNECT_REJECTED &&
972 result->hello_status == CBM_DAEMON_HELLO_INVALID &&
973 result->conflict.status == CBM_DAEMON_HELLO_INVALID &&
974 result->client_id == CBM_DAEMON_CLIENT_ID_INVALID &&
975 result->authenticated_process_id == 0;
976}
977
978static bool runtime_send_hello_response(cbm_daemon_ipc_connection_t *connection,
979 const cbm_daemon_runtime_connect_result_t *result) {

Callers 1

Calls 4

runtime_get_u32Function · 0.85
runtime_get_u64Function · 0.85

Tested by

no test coverage detected