* 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
| 126 | * int see errno.h, 0 for success |
| 127 | */ |
| 128 | int |
| 129 | debugnet_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 |
no test coverage detected