Lines Matching full:pcb

73 #include <machine/pcb.h>
106 * Simple accessors for opaque PCB.
109 debugnet_get_gw_mac(const struct debugnet_pcb *pcb)
111 MPASS(g_debugnet_pcb_inuse && pcb == &g_dnet_pcb &&
112 pcb->dp_state >= DN_STATE_HAVE_GW_MAC);
113 return (pcb->dp_gw_mac.octet);
117 debugnet_get_server_addr(const struct debugnet_pcb *pcb)
119 MPASS(g_debugnet_pcb_inuse && pcb == &g_dnet_pcb &&
120 pcb->dp_state >= DN_STATE_GOT_HERALD_PORT);
121 return (&pcb->dp_server);
125 debugnet_get_server_port(const struct debugnet_pcb *pcb)
127 MPASS(g_debugnet_pcb_inuse && pcb == &g_dnet_pcb &&
128 pcb->dp_state >= DN_STATE_GOT_HERALD_PORT);
129 return (pcb->dp_server_port);
183 * pcb The debugnet context block
190 debugnet_udp_output(struct debugnet_pcb *pcb, struct mbuf *m)
194 MPASS(pcb->dp_state >= DN_STATE_HAVE_GW_MAC);
205 udp->uh_sport = htons(pcb->dp_client_port);
206 udp->uh_dport = htons(pcb->dp_server_port);
210 return (debugnet_ip_output(pcb, m));
214 debugnet_ack_output(struct debugnet_pcb *pcb, uint32_t seqno /* net endian */)
232 return (debugnet_udp_output(pcb, m));
259 debugnet_send(struct debugnet_pcb *pcb, uint32_t type, const void *data,
268 if (pcb->dp_state == DN_STATE_REMOTE_CLOSED)
272 pcb->dp_rcvd_acks = 0;
282 pktlen = min(pktlen, pcb->dp_ifp->if_mtu -
289 if ((pcb->dp_rcvd_acks & (1 << i)) != 0) {
307 dn_msg_hdr->mh_seqno = htonl(pcb->dp_seqno + i);
335 error = debugnet_udp_output(pcb, m);
353 while (pcb->dp_rcvd_acks != want_acks) {
360 debugnet_network_poll(pcb);
362 if (pcb->dp_state == DN_STATE_REMOTE_CLOSED)
365 pcb->dp_seqno += i;
378 debugnet_handle_rx_msg(struct debugnet_pcb *pcb, struct mbuf **mb)
413 pcb->dp_state = DN_STATE_REMOTE_CLOSED;
414 if (pcb->dp_finish_handler != NULL) {
415 pcb->dp_finish_handler();
431 error = pcb->dp_rx_handler(m);
438 error = debugnet_ack_output(pcb, seqno);
445 debugnet_handle_ack(struct debugnet_pcb *pcb, struct mbuf **mb, uint16_t sport)
470 if (pcb->dp_state < DN_STATE_GOT_HERALD_PORT) {
471 pcb->dp_server_port = sport;
472 pcb->dp_state = DN_STATE_GOT_HERALD_PORT;
474 if (rcv_ackno >= pcb->dp_seqno + DEBUGNET_MAX_IN_FLIGHT)
476 else if (rcv_ackno >= pcb->dp_seqno) {
478 pcb->dp_rcvd_acks |= 1 << (rcv_ackno - pcb->dp_seqno);
483 debugnet_handle_udp(struct debugnet_pcb *pcb, struct mbuf **mb)
509 if (ntohs(udp->uh_dport) != pcb->dp_client_port) {
527 debugnet_handle_ack(pcb, mb, sport);
531 if (pcb->dp_rx_handler == NULL) {
540 debugnet_handle_rx_msg(pcb, mb);
631 debugnet_network_poll(struct debugnet_pcb *pcb)
635 ifp = pcb->dp_ifp;
643 debugnet_free(struct debugnet_pcb *pcb)
647 MPASS(pcb == &g_dnet_pcb);
648 MPASS(pcb->dp_drv_input == NULL || g_debugnet_pcb_inuse);
650 ifp = pcb->dp_ifp;
652 if (pcb->dp_drv_input != NULL)
653 ifp->if_input = pcb->dp_drv_input;
654 if (pcb->dp_event_started)
668 struct debugnet_pcb *pcb;
677 pcb = &g_dnet_pcb;
678 *pcb = (struct debugnet_pcb) {
695 if (pcb->dp_client == INADDR_ANY || pcb->dp_gateway == INADDR_ANY ||
696 pcb->dp_ifp == NULL) {
705 .sin_addr.s_addr = pcb->dp_server,
734 if (pcb->dp_client == INADDR_ANY)
735 pcb->dp_client = local_sin->sin_addr.s_addr;
736 if (pcb->dp_gateway == INADDR_ANY && gw_sin != NULL)
737 pcb->dp_gateway = gw_sin->sin_addr.s_addr;
738 if (pcb->dp_ifp == NULL)
739 pcb->dp_ifp = rt_ifp;
742 ifp = pcb->dp_ifp;
747 inet_ntop(AF_INET, &pcb->dp_server, serbuf, sizeof(serbuf));
748 inet_ntop(AF_INET, &pcb->dp_client, clibuf, sizeof(clibuf));
749 if (pcb->dp_gateway != INADDR_ANY)
750 inet_ntop(AF_INET, &pcb->dp_gateway, gwbuf, sizeof(gwbuf));
752 serbuf, pcb->dp_server_port,
753 (pcb->dp_gateway == INADDR_ANY) ? "" : " via ",
754 (pcb->dp_gateway == INADDR_ANY) ? "" : gwbuf,
755 clibuf, pcb->dp_client_port, if_name(ifp));
773 pcb->dp_event_started = true;
783 pcb->dp_drv_input = ifp->if_input;
789 error = debugnet_arp_gw(pcb);
794 MPASS(pcb->dp_state == DN_STATE_HAVE_GW_MAC);
800 error = debugnet_send(pcb, DEBUGNET_HERALD, dcp->dc_herald_data,
807 *pcb_out = pcb;
811 debugnet_free(pcb);