diff options
author | brian <brian@FreeBSD.org> | 2002-01-23 23:36:35 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2002-01-23 23:36:35 +0000 |
commit | 2cd83c2da45676a63ee49731a450f4f196631abf (patch) | |
tree | 2705b9bf44520830bbf427a6e4e7f8dae78a4e29 /usr.sbin | |
parent | bc49a98043866af4ed5359a0c739566031c2ef95 (diff) | |
download | FreeBSD-src-2cd83c2da45676a63ee49731a450f4f196631abf.zip FreeBSD-src-2cd83c2da45676a63ee49731a450f4f196631abf.tar.gz |
Detect if a udp socket on STDIN_FILENO is connected by calling
getpeername() and don't set PASSIVE mode if it's is.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ppp/udp.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/usr.sbin/ppp/udp.c b/usr.sbin/ppp/udp.c index 8307a4a..7ffa708 100644 --- a/usr.sbin/ppp/udp.c +++ b/usr.sbin/ppp/udp.c @@ -293,21 +293,30 @@ udp_Create(struct physical *p) } if (sz == sizeof type && type == SOCK_DGRAM) { + struct sockaddr_in sock; + struct sockaddr *sockp = (struct sockaddr *)&sock; + if ((dev = malloc(sizeof *dev)) == NULL) { log_Printf(LogWARN, "%s: Cannot allocate a udp device: %s\n", p->link.name, strerror(errno)); return NULL; } - /* We can't getpeername().... */ - dev->connected = UDP_MAYBEUNCONNECTED; + if (getpeername(p->fd, sockp, &sz) == 0) { + log_Printf(LogPHASE, "%s: Link is a connected udp socket\n", + p->link.name); + dev->connected = UDP_CONNECTED; + } else { + log_Printf(LogPHASE, "%s: Link is a disconnected udp socket\n", + p->link.name); - log_Printf(LogPHASE, "%s: Link is a udp socket\n", p->link.name); + dev->connected = UDP_MAYBEUNCONNECTED; - if (p->link.lcp.cfg.openmode != OPEN_PASSIVE) { - log_Printf(LogPHASE, "%s: Changing openmode to PASSIVE\n", - p->link.name); - p->link.lcp.cfg.openmode = OPEN_PASSIVE; + if (p->link.lcp.cfg.openmode != OPEN_PASSIVE) { + log_Printf(LogPHASE, "%s: Changing openmode to PASSIVE\n", + p->link.name); + p->link.lcp.cfg.openmode = OPEN_PASSIVE; + } } } } |