No subject


Sun Jul 8 18:14:56 CDT 2012


      netmask n
              Set the interface netmask to n, a 32 bit netmask in
              "decimal  dot"  notation  (e.g. 255.255.255.0).  If
              this option is given, the value specified  is  ORed
              with  the  default netmask.  The default netmask is
              chosen based on the negotiated remote  IP  address;
              it is the appropriate network mask for the class of
              the remote IP address, ORed with the  netmasks  for
              any  non  point-to-point  network interfaces in the
              system which are on the same network.

I think it is this OR operation that is either flawed, or we just don't
understand what it's doing properly.  It would seem that pppd is trying to be
smart about the netmask setting, but something's not right.

Brian

Here's the source code for setnetmask() in options.c from pppd (versions 2.3.5
thru 2.3.7-2):

/*
 * setnetmask - set the netmask to be used on the interface.
 */
static int
setnetmask(argv)
    char **argv;
{
    u_int32_t mask, b;
    int n, ok;
    char *p, *endp;

    /*
     * Unfortunately, if we use inet_addr, we can't tell whether
     * a result of all 1s is an error or a valid 255.255.255.255.
     */
    p = *argv;
    ok = 0;
    mask = 0;
    for (n = 3;; --n) {
 b = strtoul(p, &endp, 0);
 if (endp == p)
     break;
 if (b < 0 || b > 255) {
     if (n == 3) {
  /* accept e.g. 0xffffff00 */
  p = endp;
  mask = b;
     }
     break;
 }
 mask |= b << (n * 8);
 p = endp;
 if (*p != '.' || n == 0)
     break;
 ++p;
    }

    mask = htonl(mask);

    if (*p != 0 || (netmask & ~mask) != 0) {
 option_error("invalid netmask value '%s'", *argv);
 return 0;
    }

    netmask = mask;
    return (1);
}









More information about the pptp-server mailing list