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

Function debugnet_ether_output

freebsd/net/debugnet.c:128–152  ·  view source on GitHub ↗

* Handles creation of the ethernet header, then places outgoing packets into * the tx buffer for the NIC * * Parameters: * m The mbuf containing the packet to be sent (will be freed by * this function or the NIC driver) * ifp The interface to send on * dst The destination ethernet address (source address will be looked * up using ifp) * etype The ETHERTYPE_* value for the protocol that

Source from the content-addressed store, hash-verified

126 * int see errno.h, 0 for success
127 */
128int
129debugnet_ether_output(struct mbuf *m, struct ifnet *ifp, struct ether_addr dst,
130 u_short etype)
131{
132 struct ether_header *eh;
133
134 if (((ifp->if_flags & (IFF_MONITOR | IFF_UP)) != IFF_UP) ||
135 (ifp->if_drv_flags & IFF_DRV_RUNNING) != IFF_DRV_RUNNING) {
136 if_printf(ifp, "%s: interface isn't up\n", __func__);
137 m_freem(m);
138 return (ENETDOWN);
139 }
140
141 /* Fill in the ethernet header. */
142 M_PREPEND(m, ETHER_HDR_LEN, M_NOWAIT);
143 if (m == NULL) {
144 printf("%s: out of mbufs\n", __func__);
145 return (ENOBUFS);
146 }
147 eh = mtod(m, struct ether_header *);
148 memcpy(eh->ether_shost, IF_LLADDR(ifp), ETHER_ADDR_LEN);
149 memcpy(eh->ether_dhost, dst.octet, ETHER_ADDR_LEN);
150 eh->ether_type = htons(etype);
151 return (ifp->if_debugnet_methods->dn_transmit(ifp, m));
152}
153
154/*
155 * Unreliable transmission of an mbuf chain to the debugnet server

Callers 3

debugnet_send_arpFunction · 0.85
debugnet_handle_arpFunction · 0.85
debugnet_ip_outputFunction · 0.85

Calls 4

if_printfFunction · 0.85
m_freemFunction · 0.50
printfFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected