Example #1
0
/*
 * grab a reference to the device, and all pointers
 * we need to operate on it.
 */
struct net_device *
ifunit_ref(const char* name)
{
    int			deviceIfIndex = -1;
    struct net_device *	ifp = NULL;

    if (strlen(name) < 4 || _strnicmp(name, "eth", 3) != 0) {
	D("not a NIC");
	return NULL;
    }
	if (ndis_hooks.ndis_regif == NULL)
	return NULL; /* function not available yet */

    deviceIfIndex = getDeviceIfIndex(name+3);
    if (deviceIfIndex < 0)
	return NULL;
    ifp = malloc(sizeof(struct net_device), M_DEVBUF, M_NOWAIT | M_ZERO);
    if (ifp == NULL)
	return NULL;

    win32_init_lookaside_buffers(ifp);

    RtlCopyMemory(ifp->if_xname, name, IFNAMSIZ);
    ifp->ifIndex = deviceIfIndex;

	win32_init_lookaside_buffers(ifp);

	if (ndis_hooks.ndis_regif(ifp) != STATUS_SUCCESS) {
	free(ifp, M_DEVBUF);
	win32_clear_lookaside_buffers(ifp);
	return NULL; /* not found */
    }
    return ifp;
}
Example #2
0
void
if_rele(struct net_device *ifp)
{
	if (ndis_hooks.ndis_rele != NULL)
	{
		ndis_hooks.ndis_rele(ifp);
	}
}
Example #3
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;
}
Example #4
0
void
if_rele(struct net_device *ifp)
{
	win32_clear_lookaside_buffers(ifp);

	if (ndis_hooks.ndis_rele != NULL)
	{
		ndis_hooks.ndis_rele(ifp);
	}
}
Example #5
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;
}