Chapter 4. Network Redirector

It's about who controls the information. What we see and hear, how we work, what we think; it's all about the information!

?Cosmo, Sneakers

The first three chapters described how you can use a Pocket PC device to communicate over the Internet, and how the TCP/IP stack is implemented in the Windows CE operating system. We looked at developing applications using both the low-level socket interface, as well as writing robust HTTP and FTP protocol-based software using the WinInet API. This chapter examines the final topic to cover regarding network programming on a Pocket PC device?the Common Internet File System (CIFS) network redirector.

The Pocket PC network redirector is a subset of the desktop-based WNet API. On desktop platforms such as Windows XP, the WNet APIs are a set of network-independent functions that enable you to use shared network resources without having to focus on the specifics of a provider or the actual network infrastructure. Because the Pocket PC contains a limited implementation of WNet, the Microsoft Windows Network protocol (using the Windows NT LM 0.12 dialect) is the only supported network. By using the WNet APIs, an application can communicate with a variety of network resources, including remote file systems, network shares, and printers. Figure 4.1 shows a Pocket PC browsing some of the available network resources.

Figure 4.1. Viewing available network resources


As mentioned previously, the Pocket PC's network redirector is based on the Common Internet File System protocol. The primary responsibility of CIFS is the management of network connections and the processing of remote file system requests in a way that is compatible with accessing local resources. Once a request is made, CIFS packages and transmits this request to the remote host for processing, and waits for the results to be returned to the device. What this means is that functions designed to work on the Pocket PC object store, such as CopyFile(), can be used on a remote resource once a network connection has been established.

As you might have already guessed by its name, CIFS is implemented on top of TCP/IP, and is situated across the presentation and session layers of the TCP/IP OSI model (see Figure 4.2).

Figure 4.2. Pocket PC network redirector and the TCP/IP OSI model


Since the introduction of Pocket PC 2002, most devices now ship with the network redirector as part of the system's ROM. To ensure that the redirector is installed, both the redir.dll and netbios.dll libraries should be located in the \Windows folder. If they are not present, your application will receive an ERROR_NO_NETWORK result when using any of the WNet API functions.

To use the WNet network redirector functions with your application, you need to include the header winnetwk.h, and link with the coredll.lib library in your project.