Guys.... I think I fixed the above problem in l2tpd.
I've have tested it successfully on few systems
that always failed but I'd appreciate if someone
else could replicate it.

Basically I've modified pty.c to set the line to
N_HDLC like in David's rp-l2tp (I copied
most of the code so I can't take much credit
for it).

The added code might still be slightly ugly
(perhaps non portable to other platforms than
linux) so I'd appreciate if a coder could
look at it.
Talking about which, David it certainly looks
like you know your stuff when comes to C++.

When I will have mastered diff and patch
I'll release a patch unless someone does it
before me (that wouldn't be surprising)
but in the meantime I've attached the new pty.c 
and here is a copy of the new source.
============================================
/*
 * Layer Two Tunnelling Protocol Daemon
 * Copyright (C) 1998 Adtran, Inc.
 * Copyright (C) 2002 Jeff McAdams
 *
 * Mark Spencer
 *
 * This software is distributed under the terms
 * of the GPL, which you should have received
 * along with this source.
 *
 * Pseudo-pty allocation routines...  Concepts and code borrowed
 * from pty-redir by Magosanyi Arpad.
 *
 */

#include "l2tp.h"
#include <sys/ioctl.h>
#include <termios.h>
#include <fcntl.h>
#include <stdio.h>
#ifndef N_HDLC
#include <linux/termios.h>
#endif

#ifdef SOLARIS
#define PTY00 "/dev/ptyXX"
#define PTY10 "pqrstuvwxyz"
#define PTY01 "0123456789abcdef"
#endif

#ifdef LINUX
#define PTY00 "/dev/ptyXX"
#define PTY10 "pqrstuvwxyzabcde"
#define PTY01 "0123456789abcdef"
#endif

#ifdef FREEBSD
#define PTY00 "/dev/ptyXX"
#define PTY10 "p"
#define PTY01 "0123456789abcdefghijklmnopqrstuv"
#endif

int getPtyMaster (char *tty10, char *tty01)
{
    char *p10;
    char *p01;
    static char dev[] = PTY00;
    int fd;
    int disc = N_HDLC; /* added by dom */

    for (p10 = PTY10; *p10; p10++)
    {
        dev[8] = *p10;
        for (p01 = PTY01; *p01; p01++)
        {
            dev[9] = *p01;
            fd = open (dev, O_RDWR | O_NONBLOCK);
            if (fd >= 0)
            {
                disc = N_HDLC;  /* added by dom */
                *tty10 = *p10;
                *tty01 = *p01;
                /* added ifelse by dom */
                if (ioctl(fd, TIOCSETD, &disc) < 0)
                {
                    log (LOG_CRIT, "%s: Unable to set line discipline to N_HDLC\n", 
__FUNCTION__);
                    close(fd);
                    return -1;
                }
                else
                {
                return fd;
                }
            }
        }
    }
    log (LOG_CRIT, "%s: No more free pseudo-tty's\n", __FUNCTION__);
    return -1;
}
============================================

Dom <<pty.c>> 

Attachment: pty.c
Description: pty.c

Reply via email to