Ejemplo n.º 1
0
/*
 * XXX the mbuf must be consumed
 * this is NM_SEND_UP which builds a batch of packets and then
 * sends them up on the last call with a NULL data.
 * XXX at the moment packets are copied from the netmap buffer into mbufs
 * and then again into NDIS packets. We could save one allocation and one
 * copy, eventually.
 */
void *
nm_os_send_up(struct ifnet *ifp, struct mbuf *m, struct mbuf *prev)
{
	void *head = NULL;
	if (ndis_hooks.injectPacket != NULL) {
		//DbgPrint("send_up_to_stack!");
		if (m != NULL) {
			head = ndis_hooks.injectPacket(ifp->pfilter, m->pkt, m->m_len, FALSE, prev);
			m_freem(m);
		} else {
			ndis_hooks.injectPacket(ifp->pfilter, NULL, 0, FALSE, prev);
		}
	} else { /* we should not get here */
		if (m != NULL)
			m_freem(m);
	}
	return head;
}
Ejemplo n.º 2
0
/*
 * Transmit routine used by generic_netmap_txsync(). Returns 0 on success
 * and <> 0 on error (which may be packet drops or other errors).
*/
int
nm_os_generic_xmit_frame(struct nm_os_gen_arg *a)
{
	void *cur;
	PVOID toSend = (a->addr == NULL) ? a->head : a->tail;
	if (ndis_hooks.injectPacket == NULL) { /* silently drop ? */
		return 0;
	}
	cur = ndis_hooks.injectPacket(a->ifp->pfilter, a->addr, a->len, TRUE, toSend);
	if (cur) {
		a->tail = cur;
		if (a->head == NULL)
			a->head = cur;
	}
	return  0;
}