Changeset View
Changeset View
Standalone View
Standalone View
sys/net/debugnet.c
Show First 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | debugnet_udp_output(struct debugnet_pcb *pcb, struct mbuf *m) | ||||
udp->uh_sport = htons(pcb->dp_client_port); | udp->uh_sport = htons(pcb->dp_client_port); | ||||
udp->uh_dport = htons(pcb->dp_server_port); | udp->uh_dport = htons(pcb->dp_server_port); | ||||
/* Computed later (protocol-dependent). */ | /* Computed later (protocol-dependent). */ | ||||
udp->uh_sum = 0; | udp->uh_sum = 0; | ||||
return (debugnet_ip_output(pcb, m)); | return (debugnet_ip_output(pcb, m)); | ||||
} | } | ||||
static int | int | ||||
debugnet_ack_output(struct debugnet_pcb *pcb, uint32_t seqno /* net endian */) | debugnet_ack_output(struct debugnet_pcb *pcb, uint32_t seqno /* net endian */) | ||||
{ | { | ||||
struct debugnet_ack *dn_ack; | struct debugnet_ack *dn_ack; | ||||
struct mbuf *m; | struct mbuf *m; | ||||
DNETDEBUG("Acking with seqno %u\n", ntohl(seqno)); | DNETDEBUG("Acking with seqno %u\n", ntohl(seqno)); | ||||
m = m_gethdr(M_NOWAIT, MT_DATA); | m = m_gethdr(M_NOWAIT, MT_DATA); | ||||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | retransmit: | ||||
polls = 0; | polls = 0; | ||||
while (pcb->dp_rcvd_acks != want_acks) { | while (pcb->dp_rcvd_acks != want_acks) { | ||||
if (polls++ > debugnet_npolls) { | if (polls++ > debugnet_npolls) { | ||||
if (retries++ > debugnet_nretries) | if (retries++ > debugnet_nretries) | ||||
return (ETIMEDOUT); | return (ETIMEDOUT); | ||||
printf(". "); | printf(". "); | ||||
goto retransmit; | goto retransmit; | ||||
} | } | ||||
debugnet_network_poll(pcb->dp_ifp); | debugnet_network_poll(pcb); | ||||
DELAY(500); | DELAY(500); | ||||
if (pcb->dp_state == DN_STATE_REMOTE_CLOSED) | if (pcb->dp_state == DN_STATE_REMOTE_CLOSED) | ||||
return (ECONNRESET); | return (ECONNRESET); | ||||
} | } | ||||
pcb->dp_seqno += i; | pcb->dp_seqno += i; | ||||
return (0); | return (0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 230 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Network polling primitive. | * Network polling primitive. | ||||
* | * | ||||
* Instead of assuming that most of the network stack is sane, we just poll the | * Instead of assuming that most of the network stack is sane, we just poll the | ||||
* driver directly for packets. | * driver directly for packets. | ||||
*/ | */ | ||||
void | void | ||||
debugnet_network_poll(struct ifnet *ifp) | debugnet_network_poll(struct debugnet_pcb *pcb) | ||||
{ | { | ||||
struct ifnet *ifp; | |||||
ifp = pcb->dp_ifp; | |||||
ifp->if_debugnet_methods->dn_poll(ifp, 1000); | ifp->if_debugnet_methods->dn_poll(ifp, 1000); | ||||
emaste: if you're so inclined feel free to commit with my reviewed-by these bits, `static` keyword… | |||||
Done Inline ActionsThe debugnet changes aren't in tree yet, so there's no urgency on most of those changes. Really the only similar thing that could go in by itself is the sys/kdb.h change in this revision. cem: The debugnet changes aren't in tree yet, so there's no urgency on most of those changes. | |||||
} | } | ||||
/* | /* | ||||
* Start of consumer API surface. | * Start of consumer API surface. | ||||
*/ | */ | ||||
void | void | ||||
debugnet_free(struct debugnet_pcb *pcb) | debugnet_free(struct debugnet_pcb *pcb) | ||||
{ | { | ||||
Show All 14 Lines | debugnet_free(struct debugnet_pcb *pcb) | ||||
g_debugnet_pcb_inuse = false; | g_debugnet_pcb_inuse = false; | ||||
memset(&g_dnet_pcb, 0xfd, sizeof(g_dnet_pcb)); | memset(&g_dnet_pcb, 0xfd, sizeof(g_dnet_pcb)); | ||||
} | } | ||||
int | int | ||||
debugnet_connect(const struct debugnet_conn_params *dcp, | debugnet_connect(const struct debugnet_conn_params *dcp, | ||||
struct debugnet_pcb **pcb_out) | struct debugnet_pcb **pcb_out) | ||||
{ | { | ||||
struct debugnet_proto_aux herald_auxdata; | |||||
struct debugnet_pcb *pcb; | struct debugnet_pcb *pcb; | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
int error; | int error; | ||||
if (g_debugnet_pcb_inuse) { | if (g_debugnet_pcb_inuse) { | ||||
printf("%s: Only one connection at a time.\n", __func__); | printf("%s: Only one connection at a time.\n", __func__); | ||||
return (EBUSY); | return (EBUSY); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | debugnet_connect(const struct debugnet_conn_params *dcp, | ||||
error = debugnet_arp_gw(pcb); | error = debugnet_arp_gw(pcb); | ||||
if (error != 0) { | if (error != 0) { | ||||
printf("%s: failed to locate MAC address\n", __func__); | printf("%s: failed to locate MAC address\n", __func__); | ||||
goto cleanup; | goto cleanup; | ||||
} | } | ||||
MPASS(pcb->dp_state == DN_STATE_HAVE_GW_MAC); | MPASS(pcb->dp_state == DN_STATE_HAVE_GW_MAC); | ||||
herald_auxdata = (struct debugnet_proto_aux) { | |||||
.dp_offset_start = dcp->dc_herald_offset, | |||||
.dp_aux2 = dcp->dc_herald_aux2, | |||||
}; | |||||
error = debugnet_send(pcb, DEBUGNET_HERALD, dcp->dc_herald_data, | error = debugnet_send(pcb, DEBUGNET_HERALD, dcp->dc_herald_data, | ||||
dcp->dc_herald_datalen, NULL); | dcp->dc_herald_datalen, &herald_auxdata); | ||||
if (error != 0) { | if (error != 0) { | ||||
printf("%s: failed to herald debugnet server\n", __func__); | printf("%s: failed to herald debugnet server\n", __func__); | ||||
goto cleanup; | goto cleanup; | ||||
} | } | ||||
*pcb_out = pcb; | *pcb_out = pcb; | ||||
return (0); | return (0); | ||||
▲ Show 20 Lines • Show All 303 Lines • Show Last 20 Lines |
if you're so inclined feel free to commit with my reviewed-by these bits, static keyword changes etc. independently now while waiting on review of the rest. I've looked over all but the main part of the change, the addition of netgdb.c