The io_write() interceptor. * * This should be called once when the initiator is writing out its Act 1 * packet and once when the responder is writing out its Act 2 packet. */
| 28 | * This should be called once when the initiator is writing out its Act 1 |
| 29 | * packet and once when the responder is writing out its Act 2 packet. */ |
| 30 | static struct io_plan * |
| 31 | test_write(struct io_conn *conn, const void *data, size_t len, |
| 32 | struct io_plan *(*next)(struct io_conn *, struct handshake *), |
| 33 | struct handshake *h) |
| 34 | { |
| 35 | ++write_count; |
| 36 | if (write_count == 1) { |
| 37 | /* Initiator is sending the Act 1 packet. Save it for the |
| 38 | * responder and then error out. */ |
| 39 | assert(h->side == INITIATOR); |
| 40 | assert(len == sizeof(act_one)); |
| 41 | memcpy(act_one, data, sizeof(act_one)); |
| 42 | |
| 43 | return handshake_failed(conn, h); |
| 44 | } |
| 45 | if (write_count == 2) { |
| 46 | /* Responder is sending the Act 2 packet. Check that it is |
| 47 | * initialized and discard it. */ |
| 48 | assert(h->side == RESPONDER); |
| 49 | assert(len == ACT_TWO_SIZE); |
| 50 | memcheck(data, len); |
| 51 | |
| 52 | return next(conn, h); |
| 53 | } |
| 54 | assert(false && "too many calls to io_write()"); |
| 55 | } |
| 56 | |
| 57 | /* The io_read() interceptor. |
| 58 | * |