Write message from data (tal_count(data) gives length). */
| 140 | |
| 141 | /* Write message from data (tal_count(data) gives length). */ |
| 142 | struct io_plan *io_write_wire_(struct io_conn *conn, |
| 143 | const u8 *data, |
| 144 | struct io_plan *(*next)(struct io_conn *, void *), |
| 145 | void *next_arg) |
| 146 | { |
| 147 | struct io_plan_arg *arg = io_plan_arg(conn, IO_OUT); |
| 148 | |
| 149 | if (tal_bytelen(data) >= INSIDE_HEADER_BIT) { |
| 150 | errno = E2BIG; |
| 151 | return io_close(conn); |
| 152 | } |
| 153 | |
| 154 | arg->u1.const_vp = tal_dup_talarr(conn, u8, |
| 155 | memcheck(data, tal_bytelen(data))); |
| 156 | |
| 157 | /* We use u2 to store the length we've written. */ |
| 158 | arg->u2.s = INSIDE_HEADER_BIT; |
| 159 | return io_set_plan(conn, IO_OUT, do_write_wire, next, next_arg); |
| 160 | } |