2 utcp.c -- Userspace TCP
3 Copyright (C) 2014 Guus Sliepen <guus@tinc-vpn.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 #include <sys/socket.h>
33 #include "utcp_priv.h"
48 #define timersub(a, b, r) do {\
49 (r)->tv_sec = (a)->tv_sec - (b)->tv_sec;\
50 (r)->tv_usec = (a)->tv_usec - (b)->tv_usec;\
52 (r)->tv_sec--, (r)->tv_usec += 1000000;\
59 static void debug(const char *format, ...) {
62 vfprintf(stderr, format, ap);
66 static void print_packet(struct utcp *utcp, const char *dir, const void *pkt, size_t len) {
68 if(len < sizeof hdr) {
69 debug("%p %s: short packet (%zu bytes)\n", utcp, dir, len);
73 memcpy(&hdr, pkt, sizeof hdr);
74 fprintf (stderr, "%p %s: len=%zu, src=%u dst=%u seq=%u ack=%u wnd=%u ctl=", utcp, dir, len, hdr.src, hdr.dst, hdr.seq, hdr.ack, hdr.wnd);
84 if(len > sizeof hdr) {
86 for(int i = sizeof hdr; i < len; i++) {
87 const char *data = pkt;
88 debug("%c", data[i] >= 32 ? data[i] : '.');
96 #define print_packet(...)
99 static void set_state(struct utcp_connection *c, enum state state) {
101 if(state == ESTABLISHED)
102 timerclear(&c->conn_timeout);
103 debug("%p new state: %s\n", c->utcp, strstate[state]);
106 static bool fin_wanted(struct utcp_connection *c, uint32_t seq) {
107 if(seq != c->snd.last)
119 static inline void list_connections(struct utcp *utcp) {
120 debug("%p has %d connections:\n", utcp, utcp->nconnections);
121 for(int i = 0; i < utcp->nconnections; i++)
122 debug(" %u -> %u state %s\n", utcp->connections[i]->src, utcp->connections[i]->dst, strstate[utcp->connections[i]->state]);
125 static int32_t seqdiff(uint32_t a, uint32_t b) {
130 // TODO: convert to ringbuffers to avoid memmove() operations.
132 // Store data into the buffer
133 static ssize_t buffer_put(struct buffer *buf, const void *data, size_t len) {
134 if(buf->maxsize <= buf->used)
136 if(len > buf->maxsize - buf->used)
137 len = buf->maxsize - buf->used;
138 if(len > buf->size - buf->used) {
139 size_t newsize = buf->size;
142 } while(newsize < buf->used + len);
143 if(newsize > buf->maxsize)
144 newsize = buf->maxsize;
145 char *newdata = realloc(buf->data, newsize);
151 memcpy(buf->data + buf->used, data, len);
156 // Get data from the buffer. data can be NULL.
157 static ssize_t buffer_get(struct buffer *buf, void *data, size_t len) {
161 memcpy(data, buf->data, len);
163 memmove(buf->data, buf->data + len, buf->used - len);
168 // Copy data from the buffer without removing it.
169 static ssize_t buffer_copy(struct buffer *buf, void *data, size_t offset, size_t len) {
170 if(offset >= buf->used)
172 if(offset + len > buf->used)
173 len = buf->used - offset;
174 memcpy(data, buf->data + offset, len);
178 static bool buffer_init(struct buffer *buf, uint32_t len, uint32_t maxlen) {
179 memset(buf, 0, sizeof *buf);
180 buf->data = malloc(len);
184 buf->maxsize = maxlen;
188 static void buffer_exit(struct buffer *buf) {
190 memset(buf, 0, sizeof *buf);
193 static uint32_t buffer_free(const struct buffer *buf) {
194 return buf->maxsize - buf->used;
197 // Connections are stored in a sorted list.
198 // This gives O(log(N)) lookup time, O(N log(N)) insertion time and O(N) deletion time.
200 static int compare(const void *va, const void *vb) {
203 const struct utcp_connection *a = *(struct utcp_connection **)va;
204 const struct utcp_connection *b = *(struct utcp_connection **)vb;
207 assert(a->src && b->src);
209 int c = (int)a->src - (int)b->src;
212 c = (int)a->dst - (int)b->dst;
216 static struct utcp_connection *find_connection(const struct utcp *utcp, uint16_t src, uint16_t dst) {
217 if(!utcp->nconnections)
219 struct utcp_connection key = {
223 struct utcp_connection **match = bsearch(&keyp, utcp->connections, utcp->nconnections, sizeof *utcp->connections, compare);
224 return match ? *match : NULL;
227 static void free_connection(struct utcp_connection *c) {
228 struct utcp *utcp = c->utcp;
229 struct utcp_connection **cp = bsearch(&c, utcp->connections, utcp->nconnections, sizeof *utcp->connections, compare);
233 int i = cp - utcp->connections;
234 memmove(cp, cp + 1, (utcp->nconnections - i - 1) * sizeof *cp);
235 utcp->nconnections--;
237 buffer_exit(&c->sndbuf);
241 static struct utcp_connection *allocate_connection(struct utcp *utcp, uint16_t src, uint16_t dst) {
242 // Check whether this combination of src and dst is free
245 if(find_connection(utcp, src, dst)) {
249 } else { // If src == 0, generate a random port number with the high bit set
250 if(utcp->nconnections >= 32767) {
254 src = rand() | 0x8000;
255 while(find_connection(utcp, src, dst))
259 // Allocate memory for the new connection
261 if(utcp->nconnections >= utcp->nallocated) {
262 if(!utcp->nallocated)
263 utcp->nallocated = 4;
265 utcp->nallocated *= 2;
266 struct utcp_connection **new_array = realloc(utcp->connections, utcp->nallocated * sizeof *utcp->connections);
269 utcp->connections = new_array;
272 struct utcp_connection *c = calloc(1, sizeof *c);
276 if(!buffer_init(&c->sndbuf, DEFAULT_SNDBUFSIZE, DEFAULT_MAXSNDBUFSIZE)) {
281 // Fill in the details
291 c->snd.una = c->snd.iss;
292 c->snd.nxt = c->snd.iss + 1;
293 c->rcv.wnd = utcp->mtu;
294 c->snd.last = c->snd.nxt;
295 c->snd.cwnd = utcp->mtu;
298 // Add it to the sorted list of connections
300 utcp->connections[utcp->nconnections++] = c;
301 qsort(utcp->connections, utcp->nconnections, sizeof *utcp->connections, compare);
306 struct utcp_connection *utcp_connect(struct utcp *utcp, uint16_t dst, utcp_recv_t recv, void *priv) {
307 struct utcp_connection *c = allocate_connection(utcp, 0, dst);
318 hdr.seq = c->snd.iss;
320 hdr.wnd = c->rcv.wnd;
324 set_state(c, SYN_SENT);
326 print_packet(utcp, "send", &hdr, sizeof hdr);
327 utcp->send(utcp, &hdr, sizeof hdr);
329 gettimeofday(&c->conn_timeout, NULL);
330 c->conn_timeout.tv_sec += utcp->timeout;
335 void utcp_accept(struct utcp_connection *c, utcp_recv_t recv, void *priv) {
336 if(c->reapable || c->state != SYN_RECEIVED) {
337 debug("Error: accept() called on invalid connection %p in state %s\n", c, strstate[c->state]);
341 debug("%p accepted, %p %p\n", c, recv, priv);
344 set_state(c, ESTABLISHED);
347 static void ack(struct utcp_connection *c, bool sendatleastone) {
348 int32_t left = seqdiff(c->snd.last, c->snd.nxt);
349 int32_t cwndleft = c->snd.cwnd - seqdiff(c->snd.nxt, c->snd.una);
359 if(!left && !sendatleastone)
367 pkt = malloc(sizeof pkt->hdr + c->utcp->mtu);
371 pkt->hdr.src = c->src;
372 pkt->hdr.dst = c->dst;
373 pkt->hdr.ack = c->rcv.nxt;
374 pkt->hdr.wnd = c->snd.wnd;
379 uint32_t seglen = left > c->utcp->mtu ? c->utcp->mtu : left;
380 pkt->hdr.seq = c->snd.nxt;
382 buffer_copy(&c->sndbuf, pkt->data, seqdiff(c->snd.nxt, c->snd.una), seglen);
384 c->snd.nxt += seglen;
387 if(seglen && fin_wanted(c, c->snd.nxt)) {
392 print_packet(c->utcp, "send", pkt, sizeof pkt->hdr + seglen);
393 c->utcp->send(c->utcp, pkt, sizeof pkt->hdr + seglen);
399 ssize_t utcp_send(struct utcp_connection *c, const void *data, size_t len) {
401 debug("Error: send() called on closed connection %p\n", c);
411 debug("Error: send() called on unconnected connection %p\n", c);
422 debug("Error: send() called on closing connection %p\n", c);
427 // Add data to send buffer
437 len = buffer_put(&c->sndbuf, data, len);
448 static void swap_ports(struct hdr *hdr) {
449 uint16_t tmp = hdr->src;
454 static void retransmit(struct utcp_connection *c) {
455 if(c->state == CLOSED || c->snd.nxt == c->snd.una)
458 struct utcp *utcp = c->utcp;
465 pkt = malloc(sizeof pkt->hdr + c->utcp->mtu);
469 pkt->hdr.src = c->src;
470 pkt->hdr.dst = c->dst;
474 // Send our SYN again
475 pkt->hdr.seq = c->snd.iss;
477 pkt->hdr.wnd = c->rcv.wnd;
479 print_packet(c->utcp, "rtrx", pkt, sizeof pkt->hdr);
480 utcp->send(utcp, pkt, sizeof pkt->hdr);
485 pkt->hdr.seq = c->snd.nxt;
486 pkt->hdr.ack = c->rcv.nxt;
487 pkt->hdr.ctl = SYN | ACK;
488 print_packet(c->utcp, "rtrx", pkt, sizeof pkt->hdr);
489 utcp->send(utcp, pkt, sizeof pkt->hdr);
497 // Send unacked data again.
498 pkt->hdr.seq = c->snd.una;
499 pkt->hdr.ack = c->rcv.nxt;
501 uint32_t len = seqdiff(c->snd.last, c->snd.una);
504 if(fin_wanted(c, c->snd.una + len)) {
508 c->snd.nxt = c->snd.una + len;
509 buffer_copy(&c->sndbuf, pkt->data, 0, len);
510 print_packet(c->utcp, "rtrx", pkt, sizeof pkt->hdr + len);
511 utcp->send(utcp, pkt, sizeof pkt->hdr + len);
518 // We shouldn't need to retransmit anything in this state.
522 timerclear(&c->rtrx_timeout);
530 ssize_t utcp_recv(struct utcp *utcp, const void *data, size_t len) {
544 print_packet(utcp, "recv", data, len);
546 // Drop packets smaller than the header
549 if(len < sizeof hdr) {
554 // Make a copy from the potentially unaligned data to a struct hdr
556 memcpy(&hdr, data, sizeof hdr);
560 // Drop packets with an unknown CTL flag
562 if(hdr.ctl & ~(SYN | ACK | RST | FIN)) {
567 // Try to match the packet to an existing connection
569 struct utcp_connection *c = find_connection(utcp, hdr.dst, hdr.src);
571 // Is it for a new connection?
574 // Ignore RST packets
579 // Is it a SYN packet and are we LISTENing?
581 if(hdr.ctl & SYN && !(hdr.ctl & ACK) && utcp->accept) {
582 // If we don't want to accept it, send a RST back
583 if((utcp->pre_accept && !utcp->pre_accept(utcp, hdr.dst))) {
588 // Try to allocate memory, otherwise send a RST back
589 c = allocate_connection(utcp, hdr.dst, hdr.src);
595 // Return SYN+ACK, go to SYN_RECEIVED state
596 c->snd.wnd = hdr.wnd;
597 c->rcv.irs = hdr.seq;
598 c->rcv.nxt = c->rcv.irs + 1;
599 set_state(c, SYN_RECEIVED);
603 hdr.ack = c->rcv.irs + 1;
604 hdr.seq = c->snd.iss;
606 print_packet(c->utcp, "send", &hdr, sizeof hdr);
607 utcp->send(utcp, &hdr, sizeof hdr);
609 // No, we don't want your packets, send a RST back
617 debug("%p state %s\n", c->utcp, strstate[c->state]);
619 // In case this is for a CLOSED connection, ignore the packet.
620 // TODO: make it so incoming packets can never match a CLOSED connection.
622 if(c->state == CLOSED)
625 // It is for an existing connection.
627 uint32_t prevrcvnxt = c->rcv.nxt;
629 // 1. Drop invalid packets.
631 // 1a. Drop packets that should not happen in our current state.
651 // 1b. Drop packets with a sequence number not in our receive window.
655 if(c->state == SYN_SENT)
658 // TODO: handle packets overlapping c->rcv.nxt.
660 // Only use this when accepting out-of-order packets.
663 acceptable = hdr.seq == c->rcv.nxt;
665 acceptable = (seqdiff(hdr.seq, c->rcv.nxt) >= 0 && seqdiff(hdr.seq, c->rcv.nxt + c->rcv.wnd) < 0);
668 // We don't accept data when the receive window is zero.
671 // Both start and end of packet must be within the receive window
672 acceptable = (seqdiff(hdr.seq, c->rcv.nxt) >= 0 && seqdiff(hdr.seq, c->rcv.nxt + c->rcv.wnd) < 0)
673 || (seqdiff(hdr.seq + len + 1, c->rcv.nxt) >= 0 && seqdiff(hdr.seq + len - 1, c->rcv.nxt + c->rcv.wnd) < 0);
675 if(c->state != SYN_SENT)
676 acceptable = hdr.seq == c->rcv.nxt;
680 debug("Packet not acceptable, %u <= %u + %zu < %u\n", c->rcv.nxt, hdr.seq, len, c->rcv.nxt + c->rcv.wnd);
681 // Ignore unacceptable RST packets.
684 // Otherwise, send an ACK back in the hope things improve.
689 c->snd.wnd = hdr.wnd; // TODO: move below
691 // 1c. Drop packets with an invalid ACK.
692 // ackno should not roll back, and it should also not be bigger than snd.nxt.
694 if(hdr.ctl & ACK && (seqdiff(hdr.ack, c->snd.nxt) > 0 || seqdiff(hdr.ack, c->snd.una) < 0)) {
695 debug("Packet ack seqno out of range, %u %u %u\n", hdr.ack, c->snd.una, c->snd.nxt);
696 // Ignore unacceptable RST packets.
702 // 2. Handle RST packets
709 // The peer has refused our connection.
710 set_state(c, CLOSED);
711 errno = ECONNREFUSED;
718 // We haven't told the application about this connection yet. Silently delete.
727 // The peer has aborted our connection.
728 set_state(c, CLOSED);
738 // As far as the application is concerned, the connection has already been closed.
739 // If it has called utcp_close() already, we can immediately free this connection.
744 // Otherwise, immediately move to the CLOSED state.
745 set_state(c, CLOSED);
755 // 3. Advance snd.una
757 uint32_t advanced = seqdiff(hdr.ack, c->snd.una);
758 prevrcvnxt = c->rcv.nxt;
761 int32_t data_acked = advanced;
768 // TODO: handle FIN as well.
773 assert(data_acked >= 0);
775 int32_t bufused = seqdiff(c->snd.last, c->snd.una);
776 assert(data_acked <= bufused);
779 buffer_get(&c->sndbuf, NULL, data_acked);
781 c->snd.una = hdr.ack;
784 c->snd.cwnd += utcp->mtu;
785 if(c->snd.cwnd > c->sndbuf.maxsize)
786 c->snd.cwnd = c->sndbuf.maxsize;
788 // Check if we have sent a FIN that is now ACKed.
791 if(c->snd.una == c->snd.last)
792 set_state(c, FIN_WAIT_2);
795 if(c->snd.una == c->snd.last) {
796 gettimeofday(&c->conn_timeout, NULL);
797 c->conn_timeout.tv_sec += 60;
798 set_state(c, TIME_WAIT);
808 debug("Triplicate ACK\n");
809 //TODO: Resend one packet and go to fast recovery mode. See RFC 6582.
810 //We do a very simple variant here; reset the nxt pointer to the last acknowledged packet from the peer.
811 //This will cause us to start retransmitting, but at the same speed as the incoming ACKs arrive,
812 //thus preventing a drop in speed.
813 c->snd.nxt = c->snd.una;
821 timerclear(&c->conn_timeout); // It will be set anew in utcp_timeout() if c->snd.una != c->snd.nxt.
822 if(c->snd.una == c->snd.nxt)
823 timerclear(&c->rtrx_timeout);
826 // 5. Process SYN stuff
831 // This is a SYNACK. It should always have ACKed the SYN.
834 c->rcv.irs = hdr.seq;
835 c->rcv.nxt = hdr.seq;
836 set_state(c, ESTABLISHED);
837 // TODO: notify application of this somehow.
847 // Ehm, no. We should never receive a second SYN.
856 // SYN counts as one sequence number
860 // 6. Process new data
862 if(c->state == SYN_RECEIVED) {
863 // This is the ACK after the SYNACK. It should always have ACKed the SYNACK.
867 // Are we still LISTENing?
869 utcp->accept(c, c->src);
871 if(c->state != ESTABLISHED) {
872 set_state(c, CLOSED);
882 // This should never happen.
895 // Ehm no, We should never receive more data after a FIN.
907 rxd = c->recv(c, data, len);
909 // TODO: once we have a receive buffer, handle the application not accepting all data.
915 rxd = len; // Bad application, bad!
923 // 7. Process FIN stuff
929 // This should never happen.
935 set_state(c, CLOSE_WAIT);
938 set_state(c, CLOSING);
941 gettimeofday(&c->conn_timeout, NULL);
942 c->conn_timeout.tv_sec += 60;
943 set_state(c, TIME_WAIT);
949 // Ehm, no. We should never receive a second FIN.
958 // FIN counts as one sequence number
962 // Inform the application that the peer closed the connection.
969 // Now we send something back if:
970 // - we advanced rcv.nxt (ie, we got some data that needs to be ACKed)
971 // -> sendatleastone = true
972 // - or we got an ack, so we should maybe send a bit more data
973 // -> sendatleastone = false
976 ack(c, prevrcvnxt != c->rcv.nxt);
986 hdr.ack = hdr.seq + len;
990 print_packet(utcp, "send", &hdr, sizeof hdr);
991 utcp->send(utcp, &hdr, sizeof hdr);
996 int utcp_shutdown(struct utcp_connection *c, int dir) {
997 debug("%p shutdown %d at %u\n", c ? c->utcp : NULL, dir, c ? c->snd.last : 0);
1004 debug("Error: shutdown() called on closed connection %p\n", c);
1009 if(!(dir == UTCP_SHUT_RD || dir == UTCP_SHUT_WR || dir == UTCP_SHUT_RDWR)) {
1014 // TCP does not have a provision for stopping incoming packets.
1015 // The best we can do is to just ignore them.
1016 if(dir == UTCP_SHUT_RD || dir == UTCP_SHUT_RDWR)
1019 // The rest of the code deals with shutting down writes.
1020 if(dir == UTCP_SHUT_RD)
1030 set_state(c, CLOSED);
1035 set_state(c, FIN_WAIT_1);
1041 set_state(c, CLOSING);
1056 int utcp_close(struct utcp_connection *c) {
1057 if(utcp_shutdown(c, SHUT_RDWR))
1065 int utcp_abort(struct utcp_connection *c) {
1072 debug("Error: abort() called on closed connection %p\n", c);
1089 set_state(c, CLOSED);
1097 set_state(c, CLOSED);
1107 hdr.seq = c->snd.nxt;
1112 print_packet(c->utcp, "send", &hdr, sizeof hdr);
1113 c->utcp->send(c->utcp, &hdr, sizeof hdr);
1118 * One call to this function will loop through all connections,
1119 * checking if something needs to be resent or not.
1120 * The return value is the time to the next timeout in milliseconds,
1121 * or maybe a negative value if the timeout is infinite.
1123 struct timeval utcp_timeout(struct utcp *utcp) {
1125 gettimeofday(&now, NULL);
1126 struct timeval next = {now.tv_sec + 3600, now.tv_usec};
1128 for(int i = 0; i < utcp->nconnections; i++) {
1129 struct utcp_connection *c = utcp->connections[i];
1133 if(c->state == CLOSED) {
1135 debug("Reaping %p\n", c);
1142 if(timerisset(&c->conn_timeout) && timercmp(&c->conn_timeout, &now, <)) {
1146 c->recv(c, NULL, 0);
1150 if(timerisset(&c->rtrx_timeout) && timercmp(&c->rtrx_timeout, &now, <)) {
1154 if(c->poll && buffer_free(&c->sndbuf) && (c->state == ESTABLISHED || c->state == CLOSE_WAIT))
1155 c->poll(c, buffer_free(&c->sndbuf));
1157 if(timerisset(&c->conn_timeout) && timercmp(&c->conn_timeout, &next, <))
1158 next = c->conn_timeout;
1160 if(c->snd.nxt != c->snd.una) {
1161 c->rtrx_timeout = now;
1162 c->rtrx_timeout.tv_sec++;
1164 timerclear(&c->rtrx_timeout);
1167 if(timerisset(&c->rtrx_timeout) && timercmp(&c->rtrx_timeout, &next, <))
1168 next = c->rtrx_timeout;
1171 struct timeval diff;
1172 timersub(&next, &now, &diff);
1176 bool utcp_is_active(struct utcp *utcp) {
1180 for(int i = 0; i < utcp->nconnections; i++)
1181 if(utcp->connections[i]->state != CLOSED && utcp->connections[i]->state != TIME_WAIT)
1187 struct utcp *utcp_init(utcp_accept_t accept, utcp_pre_accept_t pre_accept, utcp_send_t send, void *priv) {
1188 struct utcp *utcp = calloc(1, sizeof *utcp);
1197 utcp->accept = accept;
1198 utcp->pre_accept = pre_accept;
1207 void utcp_exit(struct utcp *utcp) {
1210 for(int i = 0; i < utcp->nconnections; i++) {
1211 if(!utcp->connections[i]->reapable)
1212 debug("Warning, freeing unclosed connection %p\n", utcp->connections[i]);
1213 buffer_exit(&utcp->connections[i]->sndbuf);
1214 free(utcp->connections[i]);
1216 free(utcp->connections);
1220 uint16_t utcp_get_mtu(struct utcp *utcp) {
1221 return utcp ? utcp->mtu : 0;
1224 void utcp_set_mtu(struct utcp *utcp, uint16_t mtu) {
1225 // TODO: handle overhead of the header
1230 int utcp_get_user_timeout(struct utcp *u) {
1231 return u ? u->timeout : 0;
1234 void utcp_set_user_timeout(struct utcp *u, int timeout) {
1236 u->timeout = timeout;
1239 size_t utcp_get_sndbuf(struct utcp_connection *c) {
1240 return c ? c->sndbuf.maxsize : 0;
1243 size_t utcp_get_sndbuf_free(struct utcp_connection *c) {
1244 if(c && (c->state == ESTABLISHED || c->state == CLOSE_WAIT))
1245 return buffer_free(&c->sndbuf);
1250 void utcp_set_sndbuf(struct utcp_connection *c, size_t size) {
1253 c->sndbuf.maxsize = size;
1254 if(c->sndbuf.maxsize != size)
1255 c->sndbuf.maxsize = -1;
1258 bool utcp_get_nodelay(struct utcp_connection *c) {
1259 return c ? c->nodelay : false;
1262 void utcp_set_nodelay(struct utcp_connection *c, bool nodelay) {
1264 c->nodelay = nodelay;
1267 bool utcp_get_keepalive(struct utcp_connection *c) {
1268 return c ? c->keepalive : false;
1271 void utcp_set_keepalive(struct utcp_connection *c, bool keepalive) {
1273 c->keepalive = keepalive;
1276 size_t utcp_get_outq(struct utcp_connection *c) {
1277 return c ? seqdiff(c->snd.nxt, c->snd.una) : 0;
1280 void utcp_set_recv_cb(struct utcp_connection *c, utcp_recv_t recv) {
1285 void utcp_set_poll_cb(struct utcp_connection *c, utcp_poll_t poll) {
1290 void utcp_set_accept_cb(struct utcp *utcp, utcp_accept_t accept, utcp_pre_accept_t pre_accept) {
1292 utcp->accept = accept;
1293 utcp->pre_accept = pre_accept;