Packets from bottom of TCP/IP stack direct to application bypassing stack

Discussion in 'Linux Networking' started by Cameron Kerr, Jun 8, 2004.

  1. Cameron Kerr

    Cameron Kerr Guest

    Are you writing a driver for said modem? If so, are you wanting to write
    the driver in user-space or kernel-space?

    You may like to check out the speedtouch.sf.net website and see how they
    have gone about it, as they have two driver versions, on is user-space,
    the other kernel-space. The user-space version also runs on FreeBSD,
    IIRC.
    You mean packets, not packages.
    So you're dealing with PPPoE (PPP over Ethernet)???
    Assuming you want to do this the user-space way (not as a kernel
    driver), then the following ought to do. This will give your application
    the full frame, as is recieved at the datalink layer.

    It sounds like you want to be using Raw sockets (previously, PF_PACKET
    sockets were used for this, though I believe that is now deprecated
    under Linux). That would recieve all packets, so you would probably also
    want a BPF packet filter attached to select only the packets you are
    interested in.

    Naturally, the program would require root permissions to create such
    sockets.
    No problem, though I don't know how to go about using BPF packet filters
    attached to sockets.

    Perhaps if you give a much more detailed overview of what you are trying
    to achieve, I could help you more.
     
    Cameron Kerr, Jun 8, 2004
    #1
    1. Advertisements

  2. Cameron Kerr

    Andreas Guest

    Hello Everyone

    I am working on a ADSL modem and have the following situation that I
    would like to have some advice on.

    I need to filter out some packages in the lower level of the network
    stack. There are 2 types of packages: [eth | ppp | ip | udp] and [eth
    | ip | udp], the data in these packages are the same and they can be
    identified with the first 16 bits in the UDP data.

    I have manage to catch these packages in the /net/core/dev.c file and
    function netif_rx(...) with the 16 bit ID so I have the packages.

    Now for my question: How do I in an easy way get these packages
    directly to my application without using the network stack. I need
    BOTH of these packages to reach there and if I use socket the one with
    PPP get thrown away somewhere and that is not so good.

    I know this is not a very specific question and a little vague but
    some advice and pointers would be appreciated.

    Regards
    Andreas
     
    Andreas, Jun 8, 2004
    #2
    1. Advertisements

  3. Cameron Kerr

    Andreas Guest

    Hello Cameron

    Yes I am dealing with PPPoE and PPPoA.

    Yes, packets and not packages:)

    My product is an ADSL modem(embedded with 1 MB flash and slow CPU:)
    and want have a control application running on the modem. This
    application will at request send status and configuration to the host
    application running on Windows or MAC which monitors and displays
    current settings. This communication is done by IP/UDP socket which
    are broadcasted from the host and unicasted back.

    When the modem is in router mode and PPPoE/A it all works fine since
    the modem itself packets the data into a PPP frame before pushing it
    out on the WAN side i.e all data between host and modem are IP and
    UDP/TCP based. However when setting the modem in bridge mode the user
    will need a PPPoE client on the host(MAC or PC) to connect to the ISP.
    Now a windows machine will send out 2 packages when the host
    application does a request for modem status:

    1) eth | ppp | ip | udp (unicast, to the ISP) PPP client does this.
    2) eth | ip | udp (broadcast) as before when in route mode.

    These packages are identical execpt for the ppp frame and
    broadcast/unicast. My control application will only pick up one which
    is 2) since it uses a IP/UDP socket and this is no problem.

    But when running the host application on a MAC its a different story,
    it will only send out 1 packet:
    1) eth | ppp | ip | udp (unicast, to the ISP) PPP client does this.
    and this will not be received by the control application since it uses
    a IP/UDP socket and dont accept any PPP stuff.

    Now both of these packets are received somewhere in in the
    stack/drivers and I can get both 1 and 2 of them in
    int netif_rx(struct sk_buff *skb) in /net/core/dev.c
    Now I want to get them directly up to my application and by passing
    the stack.

    I have looked at some packet filters like libpcap used in TCPDUMP and
    it works fine. However I feel that there is to much overhead using
    these filters, what they do is use RAW socket and process the packets
    according to rules provided to them. I can just do that myself with:
    sk = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL));
    and I have it all and can just throw away what I do not need. However
    all the work is already beeing done in the stack anyway and I dont
    want to do any redundant work. I have the packages in:
    int netif_rx(struct sk_buff *skb) in /net/core/dev.c
    Now I just want them into my application without to much hazzle. Maybe
    export a structure/linked list to my application from the kernel or
    something. I am not really sure how to do this and if its the right
    approach.

    Once again:
    I know this is not a very specific question and a little vague but
    some advice and pointers would be appreciated.

    Regards
    Andreas
     
    Andreas, Jun 9, 2004
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.