Lines Matching refs:pcb
78 recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p,
116 buf->port = pcb->protocol;
144 recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
154 LWIP_UNUSED_ARG(pcb); /* only used for asserts... */
155 LWIP_ASSERT("recv_udp must have a pcb argument", pcb != NULL);
158 LWIP_ASSERT("recv_udp: recv for wrong pcb!", conn->pcb.udp == pcb);
216 recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
221 LWIP_UNUSED_ARG(pcb);
222 LWIP_ASSERT("recv_tcp must have a pcb argument", pcb != NULL);
225 LWIP_ASSERT("recv_tcp: recv for wrong pcb!", conn->pcb.tcp == pcb);
233 tcp_recved(pcb, p->tot_len);
277 poll_tcp(void *arg, struct tcp_pcb *pcb)
281 LWIP_UNUSED_ARG(pcb);
294 let select mark this pcb as writable again. */
295 if ((conn->pcb.tcp != NULL) && (tcp_sndbuf(conn->pcb.tcp) > TCP_SNDLOWAT) &&
296 (tcp_sndqueuelen(conn->pcb.tcp) < TCP_SNDQUEUELOWAT)) {
313 sent_tcp(void *arg, struct tcp_pcb *pcb, u16_t len)
317 LWIP_UNUSED_ARG(pcb);
328 let select mark this pcb as writable again. */
329 if ((conn->pcb.tcp != NULL) && (tcp_sndbuf(conn->pcb.tcp) > TCP_SNDLOWAT) &&
330 (tcp_sndqueuelen(conn->pcb.tcp) < TCP_SNDQUEUELOWAT)) {
356 conn->pcb.tcp = NULL;
389 since the pcb has already been deleted! */
415 struct tcp_pcb *pcb;
417 pcb = conn->pcb.tcp;
418 tcp_arg(pcb, conn);
419 tcp_recv(pcb, recv_tcp);
420 tcp_sent(pcb, sent_tcp);
421 tcp_poll(pcb, poll_tcp, 4);
422 tcp_err(pcb, err_tcp);
450 newconn->pcb.tcp = newpcb;
452 /* no protection: when creating the pcb, the netconn is not yet known
457 /* When returning != ERR_OK, the pcb is aborted in tcp_process(),
459 /* remove all references to this netconn from the pcb */
460 struct tcp_pcb* pcb = newconn->pcb.tcp;
461 tcp_arg(pcb, NULL);
462 tcp_recv(pcb, NULL);
463 tcp_sent(pcb, NULL);
464 tcp_poll(pcb, NULL, 4);
465 tcp_err(pcb, NULL);
466 /* remove reference from to the pcb from this netconn */
467 newconn->pcb.tcp = NULL;
483 * Create a new pcb of a specific type.
492 LWIP_ASSERT("pcb_new: pcb already allocated", msg->conn->pcb.tcp == NULL);
498 msg->conn->pcb.raw = raw_new(msg->msg.n.proto);
499 if(msg->conn->pcb.raw == NULL) {
503 raw_recv(msg->conn->pcb.raw, recv_raw, msg->conn);
508 msg->conn->pcb.udp = udp_new();
509 if(msg->conn->pcb.udp == NULL) {
515 udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE);
519 udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM);
521 udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
526 msg->conn->pcb.tcp = tcp_new();
527 if(msg->conn->pcb.tcp == NULL) {
542 * Create a new pcb of a specific type inside a netconn.
551 if(msg->conn->pcb.tcp == NULL) {
563 * The corresponding pcb is NOT created!
584 conn->pcb.tcp = NULL;
652 * The pcb is NOT freed (since we might not be in the right thread context do this).
659 LWIP_ASSERT("PCB must be deallocated outside this function", conn->pcb.tcp == NULL);
698 /* pcb might be set to NULL already by err_tcp() */
699 if (conn->pcb.tcp != NULL) {
700 tcp_recved(conn->pcb.tcp, p->tot_len);
720 /* pcb might be set to NULL already by err_tcp() */
721 if (conn->pcb.tcp != NULL) {
722 tcp_accepted(conn->pcb.tcp);
726 if (newconn->pcb.tcp != NULL) {
727 tcp_abort(newconn->pcb.tcp);
728 newconn->pcb.tcp = NULL;
755 LWIP_ASSERT("pcb already closed", (conn->pcb.tcp != NULL));
766 tcp_arg(conn->pcb.tcp, NULL);
768 if (conn->pcb.tcp->state == LISTEN) {
769 tcp_accept(conn->pcb.tcp, NULL);
773 tcp_recv(conn->pcb.tcp, NULL);
774 tcp_accept(conn->pcb.tcp, NULL);
777 tcp_sent(conn->pcb.tcp, NULL);
780 tcp_poll(conn->pcb.tcp, NULL, 4);
781 tcp_err(conn->pcb.tcp, NULL);
786 err = tcp_close(conn->pcb.tcp);
788 err = tcp_shutdown(conn->pcb.tcp, shut_rx, shut_tx);
797 conn->pcb.tcp = NULL;
812 /* Closing of listen pcb will never fail! */
813 LWIP_ASSERT("Closing a listen pcb may not fail!", (conn->pcb.tcp->state != LISTEN));
814 tcp_sent(conn->pcb.tcp, sent_tcp);
815 tcp_poll(conn->pcb.tcp, poll_tcp, 4);
816 tcp_err(conn->pcb.tcp, err_tcp);
817 tcp_arg(conn->pcb.tcp, conn);
826 * Delete the pcb inside a netconn.
847 if (msg->conn->pcb.tcp != NULL) {
852 raw_remove(msg->conn->pcb.raw);
857 msg->conn->pcb.udp->recv_arg = NULL;
858 udp_remove(msg->conn->pcb.udp);
876 msg->conn->pcb.tcp = NULL;
891 * Bind a pcb contained in a netconn
904 if (msg->conn->pcb.tcp != NULL) {
908 msg->err = raw_bind(msg->conn->pcb.raw, msg->msg.bc.ipaddr);
913 msg->err = udp_bind(msg->conn->pcb.udp, msg->msg.bc.ipaddr, msg->msg.bc.port);
918 msg->err = tcp_bind(msg->conn->pcb.tcp, msg->msg.bc.ipaddr, msg->msg.bc.port);
937 do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
942 LWIP_UNUSED_ARG(pcb);
977 * Connect a pcb contained inside a netconn
986 if (msg->conn->pcb.tcp == NULL) {
993 msg->err = raw_connect(msg->conn->pcb.raw, msg->msg.bc.ipaddr);
998 msg->err = udp_connect(msg->conn->pcb.udp, msg->msg.bc.ipaddr, msg->msg.bc.port);
1008 msg->err = tcp_connect(msg->conn->pcb.tcp, msg->msg.bc.ipaddr,
1035 * Connect a pcb contained inside a netconn
1046 udp_disconnect(msg->conn->pcb.udp);
1058 * Set a TCP pcb contained in a netconn into listen mode
1070 if (msg->conn->pcb.tcp != NULL) {
1074 struct tcp_pcb* lpcb = tcp_listen_with_backlog(msg->conn->pcb.tcp, msg->msg.lb.backlog);
1076 struct tcp_pcb* lpcb = tcp_listen(msg->conn->pcb.tcp);
1079 /* in this case, the old pcb is still allocated */
1094 msg->conn->pcb.tcp = lpcb;
1095 tcp_arg(msg->conn->pcb.tcp, msg->conn);
1096 tcp_accept(msg->conn->pcb.tcp, accept_function);
1098 /* since the old pcb is already deallocated, free lpcb now */
1100 msg->conn->pcb.tcp = NULL;
1114 * Send some data on a RAW or UDP pcb contained in a netconn
1126 if (msg->conn->pcb.tcp != NULL) {
1131 msg->err = raw_send(msg->conn->pcb.raw, msg->msg.b->p);
1133 msg->err = raw_sendto(msg->conn->pcb.raw, msg->msg.b->p, &msg->msg.b->addr);
1141 msg->err = udp_send_chksum(msg->conn->pcb.udp, msg->msg.b->p,
1144 msg->err = udp_sendto_chksum(msg->conn->pcb.udp, msg->msg.b->p,
1150 msg->err = udp_send(msg->conn->pcb.udp, msg->msg.b->p);
1152 msg->err = udp_sendto(msg->conn->pcb.udp, msg->msg.b->p, &msg->msg.b->addr, msg->msg.b->port);
1167 * Indicate data has been received from a TCP pcb contained in a netconn
1176 if (msg->conn->pcb.tcp != NULL) {
1179 if (msg->conn->pcb.tcp->state == LISTEN) {
1180 tcp_accepted(msg->conn->pcb.tcp);
1187 tcp_recved(msg->conn->pcb.tcp, recved);
1222 LWIP_ASSERT("conn->pcb.tcp != NULL", conn->pcb.tcp != NULL);
1253 available = tcp_sndbuf(conn->pcb.tcp);
1270 err = tcp_write(conn->pcb.tcp, dataptr, len, apiflags);
1275 /* non-blocking write did not write everything: mark the pcb non-writable
1276 and let poll_tcp check writable space to mark the pcb writable again */
1279 } else if ((tcp_sndbuf(conn->pcb.tcp) <= TCP_SNDLOWAT) ||
1280 (tcp_sndqueuelen(conn->pcb.tcp) >= TCP_SNDQUEUELOWAT)) {
1282 let select mark this pcb as non-writable. */
1296 tcp_output(conn->pcb.tcp);
1303 tcp_output(conn->pcb.tcp);
1337 * Send some data on a TCP pcb contained in a netconn
1353 } else if (msg->conn->pcb.tcp != NULL) {
1400 if (msg->conn->pcb.ip != NULL) {
1401 *(msg->msg.ad.ipaddr) = (msg->msg.ad.local ? msg->conn->pcb.ip->local_ip :
1402 msg->conn->pcb.ip->remote_ip);
1409 *(msg->msg.ad.port) = msg->conn->pcb.raw->protocol;
1419 *(msg->msg.ad.port) = msg->conn->pcb.udp->local_port;
1421 if ((msg->conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0) {
1424 *(msg->msg.ad.port) = msg->conn->pcb.udp->remote_port;
1431 *(msg->msg.ad.port) = (msg->msg.ad.local?msg->conn->pcb.tcp->local_port:msg->conn->pcb.tcp->remote_port);
1445 * Close a TCP pcb contained in a netconn
1459 } else if ((msg->conn->pcb.tcp != NULL) && (msg->conn->type == NETCONN_TCP)) {
1497 if (msg->conn->pcb.tcp != NULL) {