Catch PPP errors, restrict one PPP connection and MORE ... - PPP

This is a discussion on Catch PPP errors, restrict one PPP connection and MORE ... - PPP ; Hi, I am new to PPP and Linux, so excuse me if my questions sound ignorant. My client program starts the script that establishes PPP connection in background (I do not use the nodetach or updetach option) and continues forward ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Catch PPP errors, restrict one PPP connection and MORE ...

  1. Catch PPP errors, restrict one PPP connection and MORE ...

    Hi,

    I am new to PPP and Linux, so excuse me if my questions sound
    ignorant.

    My client program starts the script that establishes PPP connection in
    background (I do not use the nodetach or updetach option) and
    continues forward with its own processing. The intent is not to block
    the calling process. At some point, it calls connect on a non-blocking
    socket, and also selects the socket for completion of connection
    before writing. Now how would the program know that connection could
    not be established? Does select fail or does it still indicate
    writablilty if connection fails?

    I want the client program to know why connection could not be
    established. For eg, if the modem is not connected, if there is no
    carrier/dial tone etc, I want the application to be user friendly. How
    can I provide the calling program more information on why the
    connection failed? Is there a standard way to catch errors returned by
    PPPd. (PPPd is started in the background without the nodetach or
    updetach option)?

    How can I restrict my program to run only one PPP connection? One way
    is to search if ppp0.pid is running or not. But in this case the
    client program will have to make sure that it searches for the process
    only after chat has exhausted all connection attempts. I want the
    ability to know that chat is trying to connect, so I can hold off
    initiating another PPP connection until chat gives up.

    Should PPP process terminate on its own if connection drops? I haven't
    seen this happen, so could anyone tell me if there is a pppd option to
    do this.

    What is the pppd.tdb file for? This file doesn't go away when pppd
    terminates. Does this file need special handling such as periodical
    cleanup or can it just be ignored?

    Thanks,
    Ruchika

  2. Re: Catch PPP errors, restrict one PPP connection and MORE ...

    ruchika_khera@hotmail.com (Ruchika) writes:
    > My client program starts the script that establishes PPP connection in
    > background (I do not use the nodetach or updetach option) and
    > continues forward with its own processing. The intent is not to block
    > the calling process. At some point, it calls connect on a non-blocking
    > socket, and also selects the socket for completion of connection
    > before writing. Now how would the program know that connection could
    > not be established?


    The PPP connection? It won't.

    > Does select fail or does it still indicate
    > writablilty if connection fails?


    Yes; you'll get an error on the socket if it fails to connect. See
    W. Richard Stevens' "UNIX Network Programming" for some good examples
    of how to use non-blocking connects.

    Note, however, that there is *NO CONNECTION AT ALL* between the socket
    you create and the underlying links that may or may not exist.
    Failure of a link does *NOT* cause the failure of a socket-layer
    connection attempt.

    The reason for this is that TCP/IP is designed as a general service.
    The link layer portions provide general IP connectivity, they can come
    and go with time, and any packet can go over any available link.
    Thus, it's quite reasonable to say that if the PPP link fails either
    (a) it might come back, in which case terminating the sockets would be
    precipitous, or (b) there might be another link that is just as good.

    (The one wart to this is that POSIX requires that if, when the
    connection is *first* attempted, there is no local route to the
    destination, then the 'connect' call will fail synchronously rather
    than wait for a link to show up. I think that's a bug, and I don't
    know off-hand if Linux does that, but, oh well ...)

    > I want the client program to know why connection could not be
    > established. For eg, if the modem is not connected, if there is no
    > carrier/dial tone etc, I want the application to be user friendly. How
    > can I provide the calling program more information on why the
    > connection failed? Is there a standard way to catch errors returned by
    > PPPd. (PPPd is started in the background without the nodetach or
    > updetach option)?


    Sure. In your program, do fork(2) and then exec(2) pppd with the
    "nodetach" option. If you get SIGCHLD, then use wait(2) to collect
    the exit status from pppd, and this will tell you exactly how the PPP
    link fared. The exit status values of pppd are stable and are
    documented in the pppd man page.

    > How can I restrict my program to run only one PPP connection? One way
    > is to search if ppp0.pid is running or not. But in this case the
    > client program will have to make sure that it searches for the process
    > only after chat has exhausted all connection attempts. I want the
    > ability to know that chat is trying to connect, so I can hold off
    > initiating another PPP connection until chat gives up.


    That's what the above will do.

    > Should PPP process terminate on its own if connection drops? I haven't
    > seen this happen, so could anyone tell me if there is a pppd option to
    > do this.


    It does that by default. You have to specify "demand" (not the
    default) in order to get pppd to survive a connection drop.

    > What is the pppd.tdb file for? This file doesn't go away when pppd
    > terminates. Does this file need special handling such as periodical
    > cleanup or can it just be ignored?


    Just ignore it. It's used for Multilink PPP (RFC 1990) support.
    (There's a compilation option in the latest pppd to get rid of it on
    systems that don't use it ...)

    --
    James Carlson, Solaris Networking
    Sun Microsystems / 1 Network Drive 71.234W Vox +1 781 442 2084
    MS UBUR02-212 / Burlington MA 01803-2757 42.497N Fax +1 781 442 1677

  3. Re: Catch PPP errors, restrict one PPP connection and MORE ...

    ruchika_khera@hotmail.com (Ruchika) writes:

    ]Hi,

    ]I am new to PPP and Linux, so excuse me if my questions sound
    ]ignorant.

    ]My client program starts the script that establishes PPP connection in
    ]background (I do not use the nodetach or updetach option) and
    ]continues forward with its own processing. The intent is not to block
    ]the calling process. At some point, it calls connect on a non-blocking

    Why not?

    ]socket, and also selects the socket for completion of connection
    ]before writing. Now how would the program know that connection could
    ]not be established? Does select fail or does it still indicate
    ]writablilty if connection fails?

    ?? not sure what you are asking.
    It is hard even with the terminating return code from pppd to figure out why the connection
    did not work. Once you ahve detached, there is no way for the calling program
    to know anything. Read the debug output I guess, and see why, but you would need
    to write a sophisticated program to do it.


    ]I want the client program to know why connection could not be
    ]established. For eg, if the modem is not connected, if there is no
    ]carrier/dial tone etc, I want the application to be user friendly. How
    ]can I provide the calling program more information on why the
    ]connection failed? Is there a standard way to catch errors returned by
    ]PPPd. (PPPd is started in the background without the nodetach or
    ]updetach option)?

    One you have detached, you have detached. You cannot catch something you have
    thrown away. So why do you want to detach?

    ]How can I restrict my program to run only one PPP connection? One way

    Read the lock file. /var/lock/LCK..ttyS0 say.


    ]is to search if ppp0.pid is running or not. But in this case the

    Or look for pppd ( ps aux|grep -v grep|grep pppd)


    ]client program will have to make sure that it searches for the process
    ]only after chat has exhausted all connection attempts. I want the
    ??? What do you mean? pppd calls chat. pppd is running when chat is running.

    ]ability to know that chat is trying to connect, so I can hold off
    ]initiating another PPP connection until chat gives up.



    ]Should PPP process terminate on its own if connection drops? I haven't
    ]seen this happen, so could anyone tell me if there is a pppd option to
    ]do this.

    It usually does so. What do you mean? Have you had the far end hang up on you and
    pppd not stop? If so, there is something wrong with your modem (is this a modem
    connection?) Otherwise use the LCP Echo options.


    ]What is the pppd.tdb file for? This file doesn't go away when pppd
    ]terminates. Does this file need special handling such as periodical
    ]cleanup or can it just be ignored?

    I ignore it.


+ Reply to Thread