I want to write a program which will "lock" a computer to a user determined wireless network.
It should automatically establish and maintain the connection with the specified network
Other networks should be hidden and/or inaccessible while the program is running
Should be compatible with Windows XP - 8
Should work for all wireless cards
Could I create an NDIS filter driver or NDIS intermediate driver for this? Which one is a better option? Also, the MSDN documentation I linked does not seem to provide good information about how to actually write the driver, where can I find that?
Related
I am currently working on some preliminaries for the integration of Apple CarPlay on an infotainment unit (IU) based on Linux. One requirement of Apple is a USB role reversal, where the IU starts as USB host and becomes a USB device. The Apple device is in the end the USB Host.
The Apple specification requires, that the IU must present a configuration with three different interfaces, an iAP2 interface, a USB NCM control interface and a USB NCM data interface. An example configuration is given in the specification. It defines things like Class, Subclass, Protocol, Attributes, Endpoints, etc. This required configuration seems to be covered by the Device descriptor, configuration descriptor, interface descriptor and endpoint descriptor which is supplied by the device upon connection to a host.
For the NCM support, I activated the USB Gadget support and set Network Control Model (NCM) Support under USB Gadget precomposed configurations. For the USB interface, we use the DWC3 driver. As soon as I set the driver into the device mode, this NCM gadget driver is loaded and a new NIC appears.
How can I configure the USB descriptors of the USB device (the linux based IU) which are sent to the USB host (the Apple device)? As said above, two NCM interfaces and one iAP2 interface must be offered.
I have found some hints that this might be done with libcomposite through /sys/kernel/config/usb_gadget/ once the configfs is enabled (e.g. https://unix.stackexchange.com/questions/631138/unable-to-set-usb-gadget-device-class-and-protocol). Is this somewhere documented? Shall different endpoints have subfolders like they have under /sys/bus/usb/devices?
Afaik each interface can have a separate driver. Does this apply for both sides, Host and devicen side?
How are the driver and the defined interfaces in the descriptors linked? I assume the USB device driver must have some sort of configuration of the descriptors as well as the associated drivers for each interface?
The two NCM interfaces shall be handled by the NCM driver and the iAP2 interface by the iAP2 driver.
As I figured it out now, I would like to answer my own questions and provide some details to this topic.
USB Descriptors of the USB device can be configured through the configfs. Therefore CONFIG_USB_CONFIGFS needs to be enabled in buildroot and the corresponding gadget (Network Control Model (CDC NCM) in my case) needs to be selected (<*>).
You then need to mount the configfs, create a new folder for the gadget and will find several files in place, where you can customize some of the USB descriptors. This procedure is described in detail in the kernel configuration docu for the Linux USB gadget configurable through configfs. They list an example directory structure which tells you what descriptors are modifyable
./strings/0x409/serialnumber
./strings/0x409/product
./strings/0x409/manufacturer
./configs/c.1/bmAttributes
./configs/c.1/MaxPower
./bcdUSB
./bcdDevice
./idProduct
./idVendor
./bMaxPacketSize0
./bDeviceProtocol
./bDeviceSubClass
./bDeviceClass
The Gadget function itself can also offer configuration through the configfs, however this depends on the used gadget. In case of the NCM, the MAC Addresses, the interface name and queue length multiplier for high and super speed can be configured
./functions/ncm.usb0/ifname
./functions/ncm.usb0/qmult
./functions/ncm.usb0/host_addr
./functions/ncm.usb0/dev_addr
What is called interface on the USB host side is a function on the USB device side. When you create/associate a new function (like NCM) to the gadget, this will appear as interface on the USB host side (Some functions like NCM will create multiple interfaces). You can assign multiple functions to the gadget (mass storage, MIDI, NCM, ...) and the host will see multiple interfaces. The configuration of those functions/interfaces e.g. regarding endpoints is limited to the files available in the configfs. Endpoints, Packet size, etc regarding NCM is not configurable as this is more or less hardcoded in the source code which also defines the remaining descriptors, not configurable through the configfs and the behavior of the function itself.
If a configuration beyond the offered files in the configfs is required, the source code of the function needs to be changed. But one then needs to take care, that this still reflects the capabilities of the interface!
Does exist a standard protocol for network printers? Some network printers require the installation of drivers to be used... Is there some network printer that can be used without installing additional drivers? After all, when we connect the network cable from the laptop to the router, we do not need to install drivers (any operating system already includes the driver).
Are there any open source projects related to protocols for communication with a network printer?
The standard protocols are the LPD or IPP protocols.
If you need to talk to a printer over the network, you can either attach it to a device that translates packets into USB/LPT commands, or attach it to a linux/windows PC and print through an LPD service running on that OS.
IPP Everywhere tries to be what you are asking for.
A PWG standard that allows personal computers and mobile devices to find and print to networked and USB printers without using vendor-specific software.
Have a single PCI device which contains three NICs, courtesy of Altera Ethernet cores. Must implement for WinXPe thus NDIS 5.1. MVPs have suggested implementing a WDM driver for each core, then a single NDIS driver that talks to the individual WDM drivers, which I do not understand, given that a single NDIS driver does not appear to have any concept of multiple ports or channels.
What if at DriverEntry the NDIS driver called NdisMInitializeWrapper once for each ethernet core? It would need to call each time with the same DriverObject, but would presumably get back a different NdisWrapperHandle with each call. That unique NdisWrapperHandle could be used as a context specifier for calls to all other NDIS driver functions.
That won't work; NdisMInitializeWrapper can only be called once per driver.
The rule is: you need to have one device node per network interface. Therefore, if you want 3 Ethernet interfaces, you'll need 3 device nodes in the system. There are a couple ways to get there:
The PCI bus will create a device node for each PCI function number. If your PCI device exposes 3 functions to the bus, then Windows will enumerate 3 miniport device objects. This makes the driver super simple. But, obviously, you have to be able to rejigger the hardware to do this.
Alternatively, if you are stuck with only one PCI device with one PCI function, then you need to multiplex the PCI-enumerated device node yourself. This means you should create your own Virtual Bus Driver (VBD). The PCI bus enumerates one device node, which is associated with the driver for your VBD. Then your VBD turns around and enumerates 3 child nodes, each of which is associated with a miniport.
This approach takes considerably more work, since now you need to write two drivers. Fortunately, WDF makes writing a bus driver possible for mere mortals. Your VBD needs to implement code to share resources (interrupts, config space) among the child network miniports.
The big-name vendors are split on whether they chose option #1 or option #2, so both can work. From your description, it sounds like you've already been given advice to implement a VBD.
I'm using Delphi to develop real-time control software and over the last couple of years I have done some work running older Windows installations under Microsoft's VirtualPC and it works fine for 'pure software' development (i.e no or limited access to the outside world). Such tools seem able to work with network connections but I have to maintain software which performs I/O via the parallel port (via a device driver). We also use USB I/O. In the past I've liked Microsoft's virtual tools because it takes time to install a new operating system and then (in my case) install Delphi and a load of libraries and components to provide development support. In these circumstances I've not been too bothered by my lack of access to the low-level I/O ports.
I want to up my game and I'm happy to pay for a good virtualisation tool IF I can have access from it to the outside world, i.e I want to be able to configure it to allow access to my machine's parallel port and com ports in the same way as if it was running natively. This access has to be able to expose the parallel port in register terms, i.e to 'see' the port at address $03f8 for example and to support I/O operations of those registers (via the appropriate kernel access) as my Windows 7 64-bit installation is able to do.
I see that there are a number of virtualisation solution out there now but it's quite hard to acertain the capability of each at such a low level. Does anyone have any experience or knowledge in this area?
The VMware products would be suited best for this. You can add virtual serial and parallel ports and forward them to a physical port on the host, or even to a file or a named pipe.
You can also connect any USB device that is connected to the host machine.
This works with VMware Workstation, but might even work with the free VMware player too.
I am very enthusiastic in writing device drivers for a microcontroller(like PIC, Atmel etc).
Since I am a newbie in this controller-coding-area I just want to know whether writing device drivers for controller is same as we write for linux( or any other OS) ?
Also can anyone suggest some online device driver building tutorial for the same ..?
Thanks,
If you are thinking about developing the device drivers to interface your device with a host computer (probably using USB), then most of the microcontrollers nowadays implement default classes that rely on native drivers.
A concrete example:
If you use a PIC18F4555, you can use the regular HID (human interface device) windows driver to communicate with your microcontroller (given you implemented it correctly). No need to develop any driver.
Writing a device driver for an MCU is a pretty far cry from writing it for a OS. Most MCUs won't have an OS running on them at all. You'll generally end up writing some low level Interrupt Service Routines (ISRs) and filling up buffers, that your application software will end up emptying. You don't have to fit into any device driver paradigm that an O/S has defined. You basically have to read the datasheet for the device you are wanting to interface with and read and write to its memory over whatever interface it might use (e.g. SPI, I2C, UART, etc.). Ultimately the device driver ought to provide intuitive function calls to the application software.
If you are using AVR MCU like atmega then you can use vusb (https://www.obdev.at/products/vusb/index.html) for those MCU that don't have any HID and handles the interrupts by connecting D+ and D- pins of the USB to digital I/O ports of the MCU.
The atmegaU2 packages have their own USB communication ports and HID.