summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/compat/ndis/kern_ndis.c63
-rw-r--r--sys/compat/ndis/subr_ndis.c9
-rw-r--r--sys/dev/if_ndis/if_ndis.c90
-rw-r--r--usr.sbin/ndiscvt/inf-parse.y30
-rw-r--r--usr.sbin/ndiscvt/inf-token.l30
-rw-r--r--usr.sbin/ndiscvt/inf.c30
-rw-r--r--usr.sbin/ndiscvt/ndiscvt.89
-rw-r--r--usr.sbin/ndiscvt/ndiscvt.c24
8 files changed, 218 insertions, 67 deletions
diff --git a/sys/compat/ndis/kern_ndis.c b/sys/compat/ndis/kern_ndis.c
index 53bfa77..3ab391a 100644
--- a/sys/compat/ndis/kern_ndis.c
+++ b/sys/compat/ndis/kern_ndis.c
@@ -52,6 +52,8 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/rman.h>
+#include <vm/uma.h>
+
#include <net/if.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
@@ -82,6 +84,8 @@ __stdcall static void ndis_setdone_func(ndis_handle, ndis_status);
__stdcall static void ndis_getdone_func(ndis_handle, ndis_status);
__stdcall static void ndis_resetdone_func(ndis_handle, ndis_status, uint8_t);
+static uma_zone_t ndis_packet_zone, ndis_buffer_zone;
+
/*
* This allows us to export our symbols to other modules.
* Note that we call ourselves 'ndisapi' to avoid a namespace
@@ -91,7 +95,28 @@ __stdcall static void ndis_resetdone_func(ndis_handle, ndis_status, uint8_t);
static int
ndis_modevent(module_t mod, int cmd, void *arg)
{
- return(0);
+ int error = 0;
+
+ switch (cmd) {
+ case MOD_LOAD:
+ ndis_packet_zone = uma_zcreate("NDIS packet",
+ sizeof(ndis_packet), NULL, NULL, NULL,
+ NULL, UMA_ALIGN_PTR, 0);
+ ndis_buffer_zone = uma_zcreate("NDIS buffer",
+ sizeof(ndis_buffer), NULL, NULL, NULL,
+ NULL, UMA_ALIGN_PTR, 0);
+ break;
+ case MOD_UNLOAD:
+ case MOD_SHUTDOWN:
+ uma_zdestroy(ndis_packet_zone);
+ uma_zdestroy(ndis_buffer_zone);
+ break;
+ default:
+ error = EINVAL;
+ break;
+ }
+
+ return(error);
}
DEV_MODULE(ndisapi, ndis_modevent, NULL);
MODULE_VERSION(ndisapi, 1);
@@ -104,7 +129,10 @@ ndis_status_func(adapter, status, sbuf, slen)
void *sbuf;
uint32_t slen;
{
- printf ("status: %x\n", status);
+ ndis_miniport_block *block;
+ block = adapter;
+
+ device_printf (block->nmb_dev, "status: %x\n", status);
return;
}
@@ -112,7 +140,10 @@ __stdcall static void
ndis_statusdone_func(adapter)
ndis_handle adapter;
{
- printf ("status complete\n");
+ ndis_miniport_block *block;
+ block = adapter;
+
+ device_printf (block->nmb_dev, "status complete\n");
return;
}
@@ -148,7 +179,10 @@ ndis_resetdone_func(adapter, status, addressingreset)
ndis_status status;
uint8_t addressingreset;
{
- printf ("reset done...\n");
+ ndis_miniport_block *block;
+ block = adapter;
+
+ device_printf (block->nmb_dev, "reset done...\n");
return;
}
@@ -170,8 +204,8 @@ ndis_alloc_amem(arg)
&rid, 0UL, ~0UL, 0x1000, RF_ACTIVE);
if (sc->ndis_res_am == NULL) {
- printf("ndis%d: failed to allocate attribute memory\n",
- sc->ndis_unit);
+ device_printf(sc->ndis_dev,
+ "failed to allocate attribute memory\n");
return(ENXIO);
}
@@ -179,8 +213,8 @@ ndis_alloc_amem(arg)
sc->ndis_dev, rid, 0, NULL);
if (error) {
- printf("ndis%d: CARD_SET_MEMORY_OFFSET() returned 0x%x\n",
- sc->ndis_unit, error);
+ device_printf(sc->ndis_dev,
+ "CARD_SET_MEMORY_OFFSET() returned 0x%x\n", error);
return(error);
}
@@ -188,8 +222,8 @@ ndis_alloc_amem(arg)
sc->ndis_dev, SYS_RES_MEMORY, rid, PCCARD_A_MEM_ATTR);
if (error) {
- printf("ndis%d: CARD_SET_RES_FLAGS() returned 0x%x\n",
- sc->ndis_unit, error);
+ device_printf(sc->ndis_dev,
+ "CARD_SET_RES_FLAGS() returned 0x%x\n", error);
return(error);
}
@@ -369,7 +403,7 @@ ndis_free_bufs(b0)
while(b0 != NULL) {
next = b0->nb_next;
- free (b0, M_DEVBUF);
+ uma_zfree (ndis_buffer_zone, b0);
b0 = next;
}
@@ -384,7 +418,7 @@ ndis_free_packet(p)
return;
ndis_free_bufs(p->np_private.npp_head);
- free(p, M_DEVBUF);
+ uma_zfree(ndis_packet_zone, p);
return;
}
@@ -538,7 +572,7 @@ ndis_mtop(m0, p)
/* If caller didn't supply a packet, make one. */
if (*p == NULL) {
- *p = malloc(sizeof(ndis_packet), M_DEVBUF, M_NOWAIT|M_ZERO);
+ *p = uma_zalloc(ndis_packet_zone, M_NOWAIT|M_ZERO);
if (*p == NULL)
return(ENOMEM);
@@ -551,7 +585,7 @@ ndis_mtop(m0, p)
for (m = m0; m != NULL; m = m->m_next) {
if (m->m_len == 0)
continue;
- buf = malloc(sizeof(ndis_buffer), M_DEVBUF, M_NOWAIT|M_ZERO);
+ buf = uma_zalloc(ndis_buffer_zone, M_NOWAIT | M_ZERO);
if (buf == NULL) {
ndis_free_packet(*p);
*p = NULL;
@@ -567,6 +601,7 @@ ndis_mtop(m0, p)
}
priv->npp_tail = buf;
+ priv->npp_totlen = m0->m_pkthdr.len;
return(0);
}
diff --git a/sys/compat/ndis/subr_ndis.c b/sys/compat/ndis/subr_ndis.c
index d93822e..975e6ee 100644
--- a/sys/compat/ndis/subr_ndis.c
+++ b/sys/compat/ndis/subr_ndis.c
@@ -769,12 +769,13 @@ ndis_syslog(ndis_handle adapter, ndis_error_code code,
block = (ndis_miniport_block *)adapter;
- printf ("NDIS ERROR: %x\n", code);
- printf ("NDIS NUMERRORS: %x\n", numerrors);
+ device_printf (block->nmb_dev, "NDIS ERROR: %x\n", code);
+ device_printf (block->nmb_dev, "NDIS NUMERRORS: %x\n", numerrors);
va_start(ap, numerrors);
for (i = 0; i < numerrors; i++)
- printf ("argptr: %p\n", va_arg(ap, void *));
+ device_printf (block->nmb_dev, "argptr: %p\n",
+ va_arg(ap, void *));
va_end(ap);
return;
@@ -1829,7 +1830,7 @@ ndis_assign_pcirsrc(adapter, slot, list)
block = (ndis_miniport_block *)adapter;
*list = block->nmb_rlist;
- printf ("assign PCI resources...\n");
+ device_printf (block->nmb_dev, "assign PCI resources...\n");
return (NDIS_STATUS_SUCCESS);
}
diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c
index be89d35..e2f8c88 100644
--- a/sys/dev/if_ndis/if_ndis.c
+++ b/sys/dev/if_ndis/if_ndis.c
@@ -141,15 +141,28 @@ static device_method_t ndis_methods[] = {
};
static driver_t ndis_driver = {
+#ifdef NDIS_DEVNAME
+ NDIS_DEVNAME,
+#else
"ndis",
+#endif
ndis_methods,
sizeof(struct ndis_softc)
};
static devclass_t ndis_devclass;
+#ifdef NDIS_MODNAME
+#define NDIS_MODNAME_OVERRIDE_PCI(x) \
+ DRIVER_MODULE(x, pci, ndis_driver, ndis_devclass, 0, 0)
+#define NDIS_MODNAME_OVERRIDE_CARDBUS(x) \
+ DRIVER_MODULE(x, cardbus, ndis_driver, ndis_devclass, 0, 0)
+NDIS_MODNAME_OVERRIDE_PCI(NDIS_MODNAME);
+NDIS_MODNAME_OVERRIDE_CARDBUS(NDIS_MODNAME);
+#else
DRIVER_MODULE(ndis, pci, ndis_driver, ndis_devclass, 0, 0);
DRIVER_MODULE(ndis, cardbus, ndis_driver, ndis_devclass, 0, 0);
+#endif
/*
* Program the 64-bit multicast hash filter.
@@ -240,8 +253,8 @@ ndis_attach(dev)
SYS_RES_IOPORT, &sc->ndis_io_rid,
0, ~0, 1, RF_ACTIVE);
if (sc->ndis_res_io == NULL) {
- printf("ndis%d: couldn't map "
- "iospace\n", unit);
+ device_printf(dev,
+ "couldn't map iospace");
error = ENXIO;
goto fail;
}
@@ -249,8 +262,8 @@ ndis_attach(dev)
case SYS_RES_MEMORY:
if (sc->ndis_res_altmem != NULL &&
sc->ndis_res_mem != NULL) {
- printf ("ndis%d: too many memory "
- "resources", sc->ndis_unit);
+ device_printf(dev,
+ "too many memory resources");
error = ENXIO;
goto fail;
}
@@ -262,8 +275,8 @@ ndis_attach(dev)
&sc->ndis_altmem_rid,
0, ~0, 1, RF_ACTIVE);
if (sc->ndis_res_altmem == NULL) {
- printf("ndis%d: couldn't map "
- "alt memory\n", unit);
+ device_printf(dev,
+ "couldn't map alt memory");
error = ENXIO;
goto fail;
}
@@ -275,8 +288,8 @@ ndis_attach(dev)
&sc->ndis_mem_rid,
0, ~0, 1, RF_ACTIVE);
if (sc->ndis_res_mem == NULL) {
- printf("ndis%d: couldn't map "
- "memory\n", unit);
+ device_printf(dev,
+ "couldn't map memory");
error = ENXIO;
goto fail;
}
@@ -288,8 +301,8 @@ ndis_attach(dev)
SYS_RES_IRQ, &rid, 0, ~0, 1,
RF_SHAREABLE | RF_ACTIVE);
if (sc->ndis_irq == NULL) {
- printf("ndis%d: couldn't map "
- "interrupt\n", unit);
+ device_printf(dev,
+ "couldn't map interrupt");
error = ENXIO;
goto fail;
}
@@ -310,7 +323,7 @@ ndis_attach(dev)
ndis_intr, sc, &sc->ndis_intrhand);
if (error) {
- printf("ndis%d: couldn't set up irq\n", unit);
+ device_printf(dev, "couldn't set up irq\n");
goto fail;
}
@@ -377,7 +390,7 @@ ndis_attach(dev)
/* Call driver's init routine. */
if (ndis_init_nic(sc)) {
- printf ("ndis%d: init handler failed\n", sc->ndis_unit);
+ device_printf (dev, "init handler failed\n");
error = ENXIO;
goto fail;
}
@@ -436,11 +449,8 @@ ndis_attach(dev)
/*
* An NDIS device was detected. Inform the world.
*/
- if (sc->ndis_80211)
- printf("ndis%d: 802.11 address: %6D\n", unit, eaddr, ":");
- else
- printf("ndis%d: Ethernet address: %6D\n", unit, eaddr, ":");
-
+ device_printf(dev, "%s address: %6D\n",
+ sc->ndis_80211 ? "802.11" : "Ethernet", eaddr, ":");
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
@@ -477,7 +487,7 @@ ndis_attach(dev)
r = ndis_get_info(sc, OID_802_11_SUPPORTED_RATES,
(void *)rates, &len);
if (r)
- printf ("get rates failed: 0x%x\n", r);
+ device_printf (dev, "get rates failed: 0x%x\n", r);
/*
* We need a way to distinguish between 802.11b cards
* and 802.11g cards. Unfortunately, Microsoft doesn't
@@ -685,7 +695,7 @@ ndis_rxeof(adapter, packets, pktcnt)
/* Stash the softc here so ptom can use it. */
p->np_softc = sc;
if (ndis_ptom(&m0, p)) {
- printf ("ndis%d: ptom failed\n", sc->ndis_unit);
+ device_printf (sc->ndis_dev, "ptom failed\n");
if (p->np_oob.npo_status == NDIS_STATUS_SUCCESS)
ndis_return_packet(sc, p);
} else {
@@ -786,14 +796,14 @@ ndis_linksts_done(adapter)
switch (block->nmb_getstat) {
case NDIS_STATUS_MEDIA_CONNECT:
sc->ndis_link = 1;
- printf("ndis%d: link up\n", sc->ndis_unit);
+ device_printf(sc->ndis_dev, "link up\n");
if (sc->ndis_80211)
ndis_getstate_80211(sc);
if (ifp->if_snd.ifq_head != NULL)
ndis_start(ifp);
break;
case NDIS_STATUS_MEDIA_DISCONNECT:
- printf("ndis%d: link down\n", sc->ndis_unit);
+ device_printf(sc->ndis_dev, "link down\n");
if (sc->ndis_80211)
ndis_getstate_80211(sc);
sc->ndis_link = 0;
@@ -1050,7 +1060,7 @@ ndis_init(xsc)
sc->ndis_filter = ndis_filter;
if (error)
- printf ("set filter failed: %d\n", error);
+ device_printf (sc->ndis_dev, "set filter failed: %d\n", error);
sc->ndis_txidx = 0;
sc->ndis_txpending = sc->ndis_maxpkts;
@@ -1131,8 +1141,7 @@ ndis_ifmedia_sts(ifp, ifmr)
ifmr->ifm_active |= IFM_1000_T;
break;
default:
- printf("ndis%d: unknown speed: %d\n",
- sc->ndis_unit, media_info);
+ device_printf(sc->ndis_dev, "unknown speed: %d\n", media_info);
break;
}
@@ -1161,7 +1170,7 @@ ndis_setstate_80211(sc)
rval = ndis_set_info(sc, OID_802_11_AUTHENTICATION_MODE, &arg, &len);
if (rval)
- printf ("ndis%d: set auth failed: %d\n", sc->ndis_unit, rval);
+ device_printf (sc->ndis_dev, "set auth failed: %d\n", rval);
/* Set network infrastructure mode. */
@@ -1174,7 +1183,7 @@ ndis_setstate_80211(sc)
rval = ndis_set_info(sc, OID_802_11_INFRASTRUCTURE_MODE, &arg, &len);
if (rval)
- printf ("ndis%d: set infra failed: %d\n", sc->ndis_unit, rval);
+ device_printf (sc->ndis_dev, "set infra failed: %d\n", rval);
/* Set WEP */
@@ -1202,17 +1211,16 @@ ndis_setstate_80211(sc)
rval = ndis_set_info(sc,
OID_802_11_ADD_WEP, &wep, &len);
if (rval)
- printf("ndis%d: set wepkey "
- "failed: %d\n", sc->ndis_unit,
- rval);
+ device_printf(sc->ndis_dev,
+ "set wepkey failed: %d\n", rval);
}
}
arg = NDIS_80211_WEPSTAT_ENABLED;
len = sizeof(arg);
rval = ndis_set_info(sc, OID_802_11_WEP_STATUS, &arg, &len);
if (rval)
- printf("ndis%d: enable WEP failed: %d\n",
- sc->ndis_unit, rval);
+ device_printf(sc->ndis_dev,
+ "enable WEP failed: %d\n", rval);
} else {
arg = NDIS_80211_WEPSTAT_DISABLED;
len = sizeof(arg);
@@ -1232,7 +1240,7 @@ ndis_setstate_80211(sc)
rval = ndis_set_info(sc, OID_802_11_SSID, &ssid, &len);
if (rval)
- printf ("ndis%d: set ssid failed: %d\n", sc->ndis_unit, rval);
+ device_printf (sc->ndis_dev, "set ssid failed: %d\n", rval);
return;
}
@@ -1262,7 +1270,7 @@ ndis_getstate_80211(sc)
rval = ndis_get_info(sc, OID_802_11_INFRASTRUCTURE_MODE, &arg, &len);
if (rval)
- printf ("ndis%d: get infra failed: %d\n", sc->ndis_unit, rval);
+ device_printf (sc->ndis_dev, "get infra failed: %d\n", rval);
switch(arg) {
case NDIS_80211_NET_INFRA_IBSS:
@@ -1280,7 +1288,7 @@ ndis_getstate_80211(sc)
rval = ndis_get_info(sc, OID_802_11_SSID, &ssid, &len);
if (rval)
- printf ("ndis%d: get ssid failed: %d\n", sc->ndis_unit, rval);
+ device_printf (sc->ndis_dev, "get ssid failed: %d\n", rval);
bcopy(ssid.ns_ssid, ic->ic_bss->ni_essid, ssid.ns_ssidlen);
ic->ic_bss->ni_esslen = ssid.ns_ssidlen;
@@ -1307,8 +1315,8 @@ ndis_getstate_80211(sc)
}
if (i == ic->ic_bss->ni_rates.rs_nrates)
- printf ("ndis%d: no matching rate for: %d\n",
- sc->ndis_unit, (arg / 10000) * 2);
+ device_printf (sc->ndis_dev, "no matching rate for: %d\n",
+ (arg / 10000) * 2);
else
ic->ic_bss->ni_txrate = i;
@@ -1316,8 +1324,8 @@ ndis_getstate_80211(sc)
rval = ndis_get_info(sc, OID_802_11_POWER_MODE, &arg, &len);
if (rval)
- printf ("ndis%d: get power mode failed: %d\n",
- sc->ndis_unit, rval);
+ device_printf (sc->ndis_dev,
+ "get power mode failed: %d\n", rval);
if (arg == NDIS_80211_POWERMODE_CAM)
ic->ic_flags &= ~IEEE80211_F_PMGTON;
else
@@ -1328,8 +1336,8 @@ ndis_getstate_80211(sc)
rval = ndis_get_info(sc, OID_802_11_WEP_STATUS, &arg, &len);
if (rval)
- printf ("ndis%d: get wep status failed: %d\n",
- sc->ndis_unit, rval);
+ device_printf (sc->ndis_dev,
+ "get wep status failed: %d\n", rval);
if (arg == NDIS_80211_WEPSTAT_ENABLED)
ic->ic_flags |= IEEE80211_F_WEPON;
@@ -1423,7 +1431,7 @@ ndis_watchdog(ifp)
NDIS_LOCK(sc);
ifp->if_oerrors++;
- printf("ndis%d: watchdog timeout\n", sc->ndis_unit);
+ device_printf(sc->ndis_dev, "watchdog timeout\n");
ndis_reset(sc);
diff --git a/usr.sbin/ndiscvt/inf-parse.y b/usr.sbin/ndiscvt/inf-parse.y
index 05be126..8a84956 100644
--- a/usr.sbin/ndiscvt/inf-parse.y
+++ b/usr.sbin/ndiscvt/inf-parse.y
@@ -1,6 +1,34 @@
%{
/*
- * $Id: inf-parse.y,v 1.3 2003/11/30 21:58:16 winter Exp $
+ * Copyright (c) 2003
+ * Bill Paul <wpaul@windriver.com>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Bill Paul.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
diff --git a/usr.sbin/ndiscvt/inf-token.l b/usr.sbin/ndiscvt/inf-token.l
index 4f192c5..c6c08b9 100644
--- a/usr.sbin/ndiscvt/inf-token.l
+++ b/usr.sbin/ndiscvt/inf-token.l
@@ -1,6 +1,34 @@
%{
/*
- * $Id: inf-token.l,v 1.2 2003/11/30 20:41:06 winter Exp $
+ * Copyright (c) 2003
+ * Bill Paul <wpaul@windriver.com>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Bill Paul.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
diff --git a/usr.sbin/ndiscvt/inf.c b/usr.sbin/ndiscvt/inf.c
index 8a9d234..115d626 100644
--- a/usr.sbin/ndiscvt/inf.c
+++ b/usr.sbin/ndiscvt/inf.c
@@ -1,5 +1,33 @@
/*
- * $Id: inf.c,v 1.3 2003/11/30 21:58:16 winter Exp $
+ * Copyright (c) 2003
+ * Bill Paul <wpaul@windriver.com>. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Bill Paul.
+ * 4. Neither the name of the author nor the names of any co-contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
diff --git a/usr.sbin/ndiscvt/ndiscvt.8 b/usr.sbin/ndiscvt/ndiscvt.8
index caaa99c..7d6fb9cc1c 100644
--- a/usr.sbin/ndiscvt/ndiscvt.8
+++ b/usr.sbin/ndiscvt/ndiscvt.8
@@ -40,6 +40,7 @@
.Nm
.Op Fl i Ar <inffile>
.Fl s Ar <sysfile>
+.Op Fl n Ar devname
.Op Fl o Ar <outfile>
.Sh DESCRIPTION
The
@@ -93,6 +94,14 @@ a Windows(r) driver image. The
utility will perform some manipulation of the sections within the
executable file to make runtime linking within the kernel a little
easier and then convert the image into a data array.
+.It Op Fl n Ar devname
+Specify an alternate name for the network device/interface which will
+be created when the driver is instantiated. If you need to load more
+than one NDIS driver into your system (i.e. if you have two different
+network cards in your system which require NDIS driver support), each
+module you create must have a unique name. Device can not be larger
+than IFNAMSIZ. If no name is specified, the driver will use the
+default a default name (``ndis'').
.It Op Fl o Ar <outfile>
Specify the output file in which to place the resulting data. This
can be any file pathname. If
diff --git a/usr.sbin/ndiscvt/ndiscvt.c b/usr.sbin/ndiscvt/ndiscvt.c
index 6e34fae..1fde290 100644
--- a/usr.sbin/ndiscvt/ndiscvt.c
+++ b/usr.sbin/ndiscvt/ndiscvt.c
@@ -35,6 +35,8 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/socket.h>
+#include <net/if.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
@@ -156,7 +158,7 @@ static void
usage(void)
{
fprintf(stderr, "Usage: %s [-i <inffile>] -s <sysfile> "
- "[-o outfile]\n", __progname);
+ "[-d devname] [-o outfile]\n", __progname);
exit(1);
}
@@ -169,9 +171,10 @@ main(int argc, char *argv[])
unsigned char *ptr;
int i;
char *inffile = NULL, *sysfile = NULL, *outfile = NULL;
+ char *dname = NULL;
int ch;
- while((ch = getopt(argc, argv, "i:s:o:")) != -1) {
+ while((ch = getopt(argc, argv, "i:s:o:n:")) != -1) {
switch(ch) {
case 'i':
inffile = optarg;
@@ -182,6 +185,9 @@ main(int argc, char *argv[])
case 'o':
outfile = optarg;
break;
+ case 'n':
+ dname = optarg;
+ break;
default:
usage();
break;
@@ -218,12 +224,20 @@ main(int argc, char *argv[])
fprintf(outfp, "\n/*\n");
fprintf(outfp, " * Generated from %s and %s (%d bytes)\n",
- inffile, sysfile, fsize);
+ inffile == NULL ? "<notused>" : inffile, sysfile, fsize);
fprintf(outfp, " */\n\n");
- if (fp == NULL) {
+ if (dname != NULL) {
+ if (strlen(dname) > IFNAMSIZ)
+ err(1, "selected device name '%s' is "
+ "too long (max chars: %d)", dname, IFNAMSIZ);
+ fprintf (outfp, "#define NDIS_DEVNAME \"%s\"\n", dname);
+ fprintf (outfp, "#define NDIS_MODNAME %s\n", dname);
+ }
+
+ if (inffile == NULL) {
fprintf (outfp, "ndis_cfg ndis_regvals[] = {\n");
- fprintf (outfp, "\t{ NULL, NULL, ndis_parm_int, { 0 } }\n");
+ fprintf (outfp, "\t{ NULL, NULL, { 0 }, 0 }\n");
fprintf (outfp, "};\n\n");
} else {
OpenPOWER on IntegriCloud