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

Function runtime_hello_response_decode

src/daemon/runtime.c:915–968  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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