Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Sample protocol LSM access and/or documentation : (2 Items)
   
Sample protocol LSM access and/or documentation  
We are working on an implementation where in a specific ether type packet 0x88DC (WSMP) needs to be handled on both 
transmit and receive path of network. These packets are delivered/originate directly from an application bypassing IP 
stack.

In order to do this we are looking into developing a protocol LSM (loadable shared module - a proto.so) and an 
associated resource manager. This protocol will link directly in to Ethernet layer of the stack. 

We need help with sample LSM code and/or any documentation on writing LSM. Access to  nraw sample source specified in 
source guide would be helpful. When I tried to access source using following link, it is failing with permission denied 
error. Please let me know how to proceed on this.

http://community.qnx.com/sf/scm/do/listRepositories/projects.networking/scm

Thanks
Girish
Re: Sample protocol LSM access and/or documentation  
Hi Girish,
The complete networking source code is not available, but if you contact your sales representative they should be able 
to give you access to the lsm-nraw.so source code. Also note that one alternative would be to use the BPF api.

Unfortunately we don't have too much documentation available for writing lsms, it is on our list of things to improve.

In your lsm you can use pfil to receive Ethernet frames. The init would be something like:
{
     struct pfil_head *ether_pfil_hook;

     ether_pfil_hook = pfil_head_get(PFIL_TYPE_IFT, IFT_ETHER);
     if (ether_pfil_hook == NULL) {
         return ENOENT;
     } 
    rc = pfil_add_hook(your_input_fn, your_input_arg, PFIL_IN, ether_pfil_hook);
    return rc;
}

Now this will get called on every Ethernet packet received.
int your_input_fn (void *your_input_arg, struct mbuf **mp, struct ifnet
*ifp, int dir)
{
    struct mbuf        *m;

    m = *mp;
    if (packet of interest) {
            handle_it();
        m_freem(m);
        *mp = NULL;
        return 1;
    } else {
        /* Let io-pkt handle it */
        return 0;
    }
}

For transmit you can also do:
ifp->if_output(ifp, m, &edst, 0);

This has an mbuf in m and edst is a struct sockaddr with
edst.sa_family = AF_UNSPEC;
edst.sa_data = struct ether_header data

m should just be the data in the frame, no header.