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

Function runtime_hello_response_decode

src/daemon/runtime.c:954–1007  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

952}
953
954static bool runtime_hello_response_decode(
955 const uint8_t payload[CBM_DAEMON_RENDEZVOUS_RESPONSE_SIZE],
956 cbm_daemon_runtime_connect_result_t *result) {
957 if (!payload || !result) {
958 return false;
959 }
960 memset(result, 0, sizeof(*result));
961 result->status = (cbm_daemon_runtime_connect_status_t)runtime_get_u32(
962 payload + RENDEZVOUS_RESPONSE_CONNECT_STATUS_OFFSET);
963 result->hello_status = (cbm_daemon_hello_status_t)runtime_get_u32(
964 payload + RENDEZVOUS_RESPONSE_HELLO_STATUS_OFFSET);
965 result->client_id = runtime_get_u64(payload + RENDEZVOUS_RESPONSE_CLIENT_ID_OFFSET);
966 result->authenticated_process_id =
967 runtime_get_u64(payload + RENDEZVOUS_RESPONSE_PROCESS_ID_OFFSET);
968 result->conflict.status = (cbm_daemon_hello_status_t)runtime_get_u32(
969 payload + RENDEZVOUS_RESPONSE_CONFLICT_STATUS_OFFSET);
970 if (!runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_ACTIVE_VERSION_OFFSET,
971 CBM_DAEMON_RENDEZVOUS_VERSION_TEXT_CAP,
972 result->conflict.active_version, true) ||
973 !runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_ACTIVE_BUILD_OFFSET,
974 CBM_DAEMON_RENDEZVOUS_BUILD_FINGERPRINT_CAP,
975 result->conflict.active_build_fingerprint, true) ||
976 !runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_REQUESTED_VERSION_OFFSET,
977 CBM_DAEMON_RENDEZVOUS_VERSION_TEXT_CAP,
978 result->conflict.requested_version, true) ||
979 !runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_REQUESTED_BUILD_OFFSET,
980 CBM_DAEMON_RENDEZVOUS_BUILD_FINGERPRINT_CAP,
981 result->conflict.requested_build_fingerprint, true) ||
982 !runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_MESSAGE_OFFSET,
983 CBM_DAEMON_RENDEZVOUS_MESSAGE_CAP, result->message, true)) {
984 return false;
985 }
986 if (result->status == CBM_DAEMON_RUNTIME_CONNECT_ACCEPTED) {
987 return result->hello_status == CBM_DAEMON_HELLO_COMPATIBLE &&
988 result->conflict.status == CBM_DAEMON_HELLO_COMPATIBLE &&
989 result->client_id != CBM_DAEMON_CLIENT_ID_INVALID &&
990 result->authenticated_process_id != 0;
991 }
992 if (result->status == CBM_DAEMON_RUNTIME_CONNECT_CONFLICT) {
993 char expected[CBM_DAEMON_RENDEZVOUS_MESSAGE_CAP];
994 return result->hello_status >= CBM_DAEMON_HELLO_VERSION_CONFLICT &&
995 result->hello_status <= CBM_DAEMON_HELLO_FEATURE_ABI_CONFLICT &&
996 result->conflict.status == result->hello_status &&
997 result->client_id == CBM_DAEMON_CLIENT_ID_INVALID &&
998 result->authenticated_process_id == 0 &&
999 cbm_daemon_conflict_format(&result->conflict, expected, sizeof(expected)) &&
1000 strcmp(result->message, expected) == 0;
1001 }
1002 return result->status == CBM_DAEMON_RUNTIME_CONNECT_REJECTED &&
1003 result->hello_status == CBM_DAEMON_HELLO_INVALID &&
1004 result->conflict.status == CBM_DAEMON_HELLO_INVALID &&
1005 result->client_id == CBM_DAEMON_CLIENT_ID_INVALID &&
1006 result->authenticated_process_id == 0;
1007}
1008
1009static bool runtime_send_hello_response(cbm_daemon_ipc_connection_t *connection,
1010 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