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

Function runtime_hello_response_decode

src/daemon/runtime.c:1139–1192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1137}
1138
1139static bool runtime_hello_response_decode(
1140 const uint8_t payload[CBM_DAEMON_RENDEZVOUS_RESPONSE_SIZE],
1141 cbm_daemon_runtime_connect_result_t *result) {
1142 if (!payload || !result) {
1143 return false;
1144 }
1145 memset(result, 0, sizeof(*result));
1146 result->status = (cbm_daemon_runtime_connect_status_t)runtime_get_u32(
1147 payload + RENDEZVOUS_RESPONSE_CONNECT_STATUS_OFFSET);
1148 result->hello_status = (cbm_daemon_hello_status_t)runtime_get_u32(
1149 payload + RENDEZVOUS_RESPONSE_HELLO_STATUS_OFFSET);
1150 result->client_id = runtime_get_u64(payload + RENDEZVOUS_RESPONSE_CLIENT_ID_OFFSET);
1151 result->authenticated_process_id =
1152 runtime_get_u64(payload + RENDEZVOUS_RESPONSE_PROCESS_ID_OFFSET);
1153 result->conflict.status = (cbm_daemon_hello_status_t)runtime_get_u32(
1154 payload + RENDEZVOUS_RESPONSE_CONFLICT_STATUS_OFFSET);
1155 if (!runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_ACTIVE_VERSION_OFFSET,
1156 CBM_DAEMON_RENDEZVOUS_VERSION_TEXT_CAP,
1157 result->conflict.active_version, true) ||
1158 !runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_ACTIVE_BUILD_OFFSET,
1159 CBM_DAEMON_RENDEZVOUS_BUILD_FINGERPRINT_CAP,
1160 result->conflict.active_build_fingerprint, true) ||
1161 !runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_REQUESTED_VERSION_OFFSET,
1162 CBM_DAEMON_RENDEZVOUS_VERSION_TEXT_CAP,
1163 result->conflict.requested_version, true) ||
1164 !runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_REQUESTED_BUILD_OFFSET,
1165 CBM_DAEMON_RENDEZVOUS_BUILD_FINGERPRINT_CAP,
1166 result->conflict.requested_build_fingerprint, true) ||
1167 !runtime_wire_string_decode(payload + RENDEZVOUS_RESPONSE_MESSAGE_OFFSET,
1168 CBM_DAEMON_RENDEZVOUS_MESSAGE_CAP, result->message, true)) {
1169 return false;
1170 }
1171 if (result->status == CBM_DAEMON_RUNTIME_CONNECT_ACCEPTED) {
1172 return result->hello_status == CBM_DAEMON_HELLO_COMPATIBLE &&
1173 result->conflict.status == CBM_DAEMON_HELLO_COMPATIBLE &&
1174 result->client_id != CBM_DAEMON_CLIENT_ID_INVALID &&
1175 result->authenticated_process_id != 0;
1176 }
1177 if (result->status == CBM_DAEMON_RUNTIME_CONNECT_CONFLICT) {
1178 char expected[CBM_DAEMON_RENDEZVOUS_MESSAGE_CAP];
1179 return result->hello_status >= CBM_DAEMON_HELLO_VERSION_CONFLICT &&
1180 result->hello_status <= CBM_DAEMON_HELLO_FEATURE_ABI_CONFLICT &&
1181 result->conflict.status == result->hello_status &&
1182 result->client_id == CBM_DAEMON_CLIENT_ID_INVALID &&
1183 result->authenticated_process_id == 0 &&
1184 cbm_daemon_conflict_format(&result->conflict, expected, sizeof(expected)) &&
1185 strcmp(result->message, expected) == 0;
1186 }
1187 return result->status == CBM_DAEMON_RUNTIME_CONNECT_REJECTED &&
1188 result->hello_status == CBM_DAEMON_HELLO_INVALID &&
1189 result->conflict.status == CBM_DAEMON_HELLO_INVALID &&
1190 result->client_id == CBM_DAEMON_CLIENT_ID_INVALID &&
1191 result->authenticated_process_id == 0;
1192}
1193
1194static bool runtime_send_hello_response(cbm_daemon_ipc_connection_t *connection,
1195 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