| 4352 | * ========================================================================= */ |
| 4353 | |
| 4354 | static int dist_write_snapshot_load_begin( |
| 4355 | int fd, |
| 4356 | const ds4_dist_snapshot_begin_fixed *begin, |
| 4357 | const int *tokens) { |
| 4358 | uint64_t token_bytes64 = (uint64_t)begin->token_count * sizeof(uint32_t); |
| 4359 | if (token_bytes64 > UINT32_MAX || |
| 4360 | begin->token_bytes != (uint32_t)token_bytes64 || |
| 4361 | begin->message_bytes != 0) |
| 4362 | return -1; |
| 4363 | uint64_t frame_bytes64 = sizeof(*begin) + token_bytes64; |
| 4364 | if (frame_bytes64 > UINT32_MAX) return -1; |
| 4365 | ds4_dist_snapshot_begin_fixed wire = *begin; |
| 4366 | dist_snapshot_begin_to_wire(&wire); |
| 4367 | if (dist_write_frame_header(fd, DS4_DIST_MSG_SNAPSHOT_LOAD_BEGIN, |
| 4368 | (uint32_t)frame_bytes64) != 0) |
| 4369 | return -1; |
| 4370 | if (dist_write_full(fd, &wire, sizeof(wire)) != 0) return -1; |
| 4371 | for (uint32_t i = 0; i < begin->token_count; i++) { |
| 4372 | uint32_t t = htonl((uint32_t)tokens[i]); |
| 4373 | if (dist_write_full(fd, &t, sizeof(t)) != 0) return -1; |
| 4374 | } |
| 4375 | return 1; |
| 4376 | } |
| 4377 | |
| 4378 | static int dist_read_snapshot_begin_frame( |
| 4379 | int fd, |
no test coverage detected