MCPcopy Create free account
hub / github.com/F-Stack/f-stack / debugnet_handle_rx_msg

Function debugnet_handle_rx_msg

freebsd/net/debugnet.c:354–404  ·  view source on GitHub ↗

* Just introspect the header enough to fire off a seqno ack and validate * length fits. */

Source from the content-addressed store, hash-verified

352 * length fits.
353 */
354static void
355debugnet_handle_rx_msg(struct debugnet_pcb *pcb, struct mbuf **mb)
356{
357 const struct debugnet_msg_hdr *dnh;
358 struct mbuf *m;
359 int error;
360
361 m = *mb;
362
363 if (m->m_pkthdr.len < sizeof(*dnh)) {
364 DNETDEBUG("ignoring small debugnet_msg packet\n");
365 return;
366 }
367
368 /* Get ND header. */
369 if (m->m_len < sizeof(*dnh)) {
370 m = m_pullup(m, sizeof(*dnh));
371 *mb = m;
372 if (m == NULL) {
373 DNETDEBUG("m_pullup failed\n");
374 return;
375 }
376 }
377 dnh = mtod(m, const void *);
378
379 if (ntohl(dnh->mh_len) + sizeof(*dnh) > m->m_pkthdr.len) {
380 DNETDEBUG("Dropping short packet.\n");
381 return;
382 }
383
384 /*
385 * If the issue is transient (ENOBUFS), sender should resend. If
386 * non-transient (like driver objecting to rx -> tx from the same
387 * thread), not much else we can do.
388 */
389 error = debugnet_ack_output(pcb, dnh->mh_seqno);
390 if (error != 0)
391 return;
392
393 if (ntohl(dnh->mh_type) == DEBUGNET_FINISHED) {
394 printf("Remote shut down the connection on us!\n");
395 pcb->dp_state = DN_STATE_REMOTE_CLOSED;
396
397 /*
398 * Continue through to the user handler so they are signalled
399 * not to wait for further rx.
400 */
401 }
402
403 pcb->dp_rx_handler(pcb, mb);
404}
405
406static void
407debugnet_handle_ack(struct debugnet_pcb *pcb, struct mbuf **mb, uint16_t sport)

Callers 1

debugnet_handle_udpFunction · 0.85

Calls 3

m_pullupFunction · 0.85
debugnet_ack_outputFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected