Re: netgraph(3) NGM_KSOCKET_BIND

From: Crist J. Clark (cristjc_at_comcast.net)
Date: 11/20/03

  • Next message: Benjamin Lauzière: "Simple Routing"
    Date: Wed, 19 Nov 2003 18:42:32 -0800
    To: John Polstra <jdp@polstra.com>
    
    

    On Wed, Nov 19, 2003 at 01:14:21PM -0800, John Polstra wrote:
    > On 19-Nov-2003 Crist J. Clark wrote:
    > > OK, an easy one. I am trying to do some netgraph(3) coding in
    > > userland. From how I read the documentation, this should work. Before
    > > I go learn all of the netraph(4) kernel code to understand the error
    > > message, could someone tell me how this is supposed to look? I'm sure
    > > it's something obvious that I have missed.
    > >
    > > The attached test program returns,
    > >
    > > # ./ngtest
    > > ngtest: failed to bind ksocket: Invalid argument
    > [...]
    > > bzero(&laddr, sizeof laddr);
    > > laddr.sin_family = AF_INET;
    > > laddr.sin_addr.s_addr = INADDR_ANY;
    > > laddr.sin_port = htons(DEFAULT_PORT);
    > > if (NgSendMsg(cs, OUR_HOOK_CTL, NGM_KSOCKET_COOKIE, NGM_KSOCKET_BIND,
    > > &laddr, sizeof laddr) == -1)
    > > err(errno, "failed to bind ksocket");
    >
    > I think the problem might be that you forgot to set the "sin_len"
    > member of the sockaddr_in struct. I don't see anything else
    > glaringly wrong.

    Duh. That was it. Thanks.

    I didn't think I had messed up the sockaddr_in because I stuck a plain
    ol' bind(2) call in there as a test, and it worked. It didn't seem to
    care I forgot to set sin_len.

    -- 
    Crist J. Clark                     |     cjclark@alum.mit.edu
                                       |     cjclark@jhu.edu
    http://people.freebsd.org/~cjc/    |     cjc@freebsd.org
    _______________________________________________
    freebsd-net@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-net
    To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"
    

  • Next message: Benjamin Lauzière: "Simple Routing"

    Relevant Pages

    • netgraph(3) NGM_KSOCKET_BIND
      ... I am trying to do some netgraphcoding in ... userland. ... From how I read the documentation, ... The attached test program returns, ...
      (freebsd-net)
    • Re: Security issue - just getting started
      ... Userland is the rich toolset, the configuration mechanisms, ... the man pages and documentation. ...
      (freebsd-newbies)
    • WSARecvMsg
      ... struggling to understand the documentation, and in spite of errors in the ... copy of my test program in my web site; ... That program is my test program and is also not the ...
      (microsoft.public.win32.programmer.networks)
    • Re: Pointer to vector element
      ... > Does a pointer to an element of a vector remain valid after calling ... You cannot 'prove' this sort of proposition with a test program. ... There is no substitute for reading the documentation. ...
      (comp.lang.cpp)
    • Building a User-Land
      ... Can someone tell me where I can find documentation or a site on ... building a "Userland" for an embedded system? ... I cant seem to find out ...
      (comp.os.linux.embedded)