Hi Andrew, On Sun, Nov 23, 2008 at 5:37 PM, Andrew Lunn <[EMAIL PROTECTED]> wrote: > On Sun, Nov 23, 2008 at 01:00:47PM +0800, James wrote: >> Hi all, >> >> I'm new to eCos/Linux and please bare with my novice questions. >> >> I'm working on a new protocol stack for a device and wish to >> incorporate it into the Socket Layer API interface. This protocol >> stack is operates similarly to TCP/IP stack and must be running with >> the lifetime of the system. i.e., providing a common service to >> multiple applications at the same time. >> >> A search on Google reveals that there are similar concept in Linux >> where the CAN protocol stack and Bluetooth protocol stack are >> incorporated into the standard Socket Layer Interface call so that >> programmers who are familiar with Socket Programming can utilize it >> easily. ie., can_hdr = socket(PF_CAN, ...) to create a application >> handler to access the CAN devices. >> >> My questions are >> >> 1) Is it possible to implement the same concept into eCos? So that I >> can just call the support socket interface calls for the application. > > Sure. > >> 2) Where should I start to include the addition code to the relevant >> section of the eCos source files to support the new protocol stack? is >> it in /net/?? I've the necessary protocol libraries ready and need to >> know where the binding to the Socket API and device drivers are.. > > There is two ways to do this. > > You are adding a new domain. Take a look at the code at the beginning > of net/bsd_tcpip/current/src/sys/netinet/in_proto.c. You can see how > IP is registered to the generic socket interface.
I'm a bit confused with the definition of "new domain" here. What can be an example of adding a new "domain"? For example, is the addition of CAN protocol (PF_CAN) to the Socket API layer used in Linux consider as "adding a new domain" ? > > Or you can implemented a whole new protocol stack. The socket() call > in io/fileio/current/src/socket.cxx has a list of network stacks in > cyg_nstab. When you open a socket it will walk the list calling the > socket() function in each of these network stacks until one returns > success. > Before the socket() call can walk the list calling the socket() function in each of these network stack, where does the individual network stack start its initialization and registration/add itself into the cyg_nstab[] table before the cyg_nstab_init() is run? >> 3) Is there any guide that can help me or describe the working of the >> eCos Socket API in details >> > > Not the internals. You just need to read the code. Once you get passed > the eCos wrapper into the FreeBSD stack there is documentation > available, eg the books by Stevens on the implementation of TCP/IP. > > Andrew > Of the two ways above, my intention is more incline to work on a method to utilize the advantage of the networking stack just like the intention for the PF_CAN. (Using a standard networking stack and socket philosophy so that multitasking is made possible with it) My device protocol is quite similar to the Seq_Packet and is a stateful protocol. Andrew, with your experience, which path should I try out that will allows testing of the codes with output directed to a hyperterminal or serial port (to 'see' the communication packet with the device)? and that I can uses the existing TCP/UDP codes as references/templates on the internal flow mechanism. What are the difference between taking either of the two ways you mentioned? -- Regards, James -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
