]> git.ozlabs.org Git - ppp.git/commitdiff
Allow operation without an IP address for the peer
authorPaul Mackerras <paulus@samba.org>
Wed, 26 Mar 2008 11:34:23 +0000 (11:34 +0000)
committerPaul Mackerras <paulus@samba.org>
Wed, 26 Mar 2008 11:34:23 +0000 (11:34 +0000)
Under Linux, a point-to-point interface can operate without having
a destination IP address assigned to it, because routes can be
directed to the device rather than to a gateway IP address.  Some
peers expect us to operate in this manner and refuse to give us
an IP address for them, so this adds a new `noremoteip' option that
tells pppd not to ask for the peer's IP address if the peer doesn't
supply it.  There is also a `nosendip' option which tells pppd not
to supply its IP address -- mostly intended for testing.

Solaris requires a destination IP address, so the noremoteip option
is not included on Solaris.

pppd/ipcp.c
pppd/sys-linux.c

index dae639b0916d0124731410a2a4f9ad67c727cb0c..98a427c1137d259a64ac01e429ea93ddff61a59c 100644 (file)
@@ -40,7 +40,7 @@
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#define RCSID  "$Id: ipcp.c,v 1.71 2008/03/26 10:57:11 paulus Exp $"
+#define RCSID  "$Id: ipcp.c,v 1.72 2008/03/26 11:34:23 paulus Exp $"
 
 /*
  * TODO:
 
 /*
  * TODO:
@@ -72,6 +72,7 @@ ipcp_options ipcp_hisoptions[NUM_PPP];        /* Options that we ack'd */
 u_int32_t netmask = 0;         /* IP netmask to set on interface */
 
 bool   disable_defaultip = 0;  /* Don't use hostname for default IP adrs */
 u_int32_t netmask = 0;         /* IP netmask to set on interface */
 
 bool   disable_defaultip = 0;  /* Don't use hostname for default IP adrs */
+bool   noremoteip = 0;         /* Let him have no IP address */
 
 /* Hook for a plugin to know when IP protocol has come up */
 void (*ip_up_hook) __P((void)) = NULL;
 
 /* Hook for a plugin to know when IP protocol has come up */
 void (*ip_up_hook) __P((void)) = NULL;
@@ -218,6 +219,13 @@ static option_t ipcp_option_list[] = {
     { "ipcp-no-address", o_bool, &ipcp_wantoptions[0].neg_addr,
       "Disable IP-Address usage", OPT_A2CLR,
       &ipcp_allowoptions[0].neg_addr },
     { "ipcp-no-address", o_bool, &ipcp_wantoptions[0].neg_addr,
       "Disable IP-Address usage", OPT_A2CLR,
       &ipcp_allowoptions[0].neg_addr },
+#ifdef __linux__
+    { "noremoteip", o_bool, &noremoteip,
+      "Allow peer to have no IP address", 1 },
+#endif
+    { "nosendip", o_bool, &ipcp_wantoptions[0].neg_addr,
+      "Don't send our IP address to peer", OPT_A2CLR,
+      &ipcp_wantoptions[0].old_addrs},
 
     { "IP addresses", o_wild, (void *) &setipaddr,
       "set local and remote IP addresses",
 
     { "IP addresses", o_wild, (void *) &setipaddr,
       "set local and remote IP addresses",
@@ -1599,7 +1607,7 @@ endswitch:
      * option safely.
      */
     if (rc != CONFREJ && !ho->neg_addr && !ho->old_addrs &&
      * option safely.
      */
     if (rc != CONFREJ && !ho->neg_addr && !ho->old_addrs &&
-       wo->req_addr && !reject_if_disagree) {
+       wo->req_addr && !reject_if_disagree && !noremoteip) {
        if (rc == CONFACK) {
            rc = CONFNAK;
            ucp = inp;                  /* reset pointer */
        if (rc == CONFACK) {
            rc = CONFNAK;
            ucp = inp;                  /* reset pointer */
@@ -1659,7 +1667,7 @@ ip_demand_conf(u)
 {
     ipcp_options *wo = &ipcp_wantoptions[u];
 
 {
     ipcp_options *wo = &ipcp_wantoptions[u];
 
-    if (wo->hisaddr == 0) {
+    if (wo->hisaddr == 0 && !noremoteip) {
        /* make up an arbitrary address for the peer */
        wo->hisaddr = htonl(0x0a707070 + ifunit);
        wo->accept_remote = 1;
        /* make up an arbitrary address for the peer */
        wo->hisaddr = htonl(0x0a707070 + ifunit);
        wo->accept_remote = 1;
@@ -1685,7 +1693,8 @@ ip_demand_conf(u)
            proxy_arp_set[u] = 1;
 
     notice("local  IP address %I", wo->ouraddr);
            proxy_arp_set[u] = 1;
 
     notice("local  IP address %I", wo->ouraddr);
-    notice("remote IP address %I", wo->hisaddr);
+    if (wo->hisaddr)
+       notice("remote IP address %I", wo->hisaddr);
 
     return 1;
 }
 
     return 1;
 }
@@ -1724,13 +1733,14 @@ ipcp_up(f)
        ipcp_close(f->unit, "Could not determine local IP address");
        return;
     }
        ipcp_close(f->unit, "Could not determine local IP address");
        return;
     }
-    if (ho->hisaddr == 0) {
+    if (ho->hisaddr == 0 && !noremoteip) {
        ho->hisaddr = htonl(0x0a404040 + ifunit);
        warn("Could not determine remote IP address: defaulting to %I",
             ho->hisaddr);
     }
     script_setenv("IPLOCAL", ip_ntoa(go->ouraddr), 0);
        ho->hisaddr = htonl(0x0a404040 + ifunit);
        warn("Could not determine remote IP address: defaulting to %I",
             ho->hisaddr);
     }
     script_setenv("IPLOCAL", ip_ntoa(go->ouraddr), 0);
-    script_setenv("IPREMOTE", ip_ntoa(ho->hisaddr), 1);
+    if (ho->hisaddr != 0)
+       script_setenv("IPREMOTE", ip_ntoa(ho->hisaddr), 1);
 
     if (go->dnsaddr[0])
        script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]), 0);
 
     if (go->dnsaddr[0])
        script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]), 0);
@@ -1744,7 +1754,7 @@ ipcp_up(f)
     /*
      * Check that the peer is allowed to use the IP address it wants.
      */
     /*
      * Check that the peer is allowed to use the IP address it wants.
      */
-    if (!auth_ip_addr(f->unit, ho->hisaddr)) {
+    if (ho->hisaddr != 0 && !auth_ip_addr(f->unit, ho->hisaddr)) {
        error("Peer is not authorized to use remote address %I", ho->hisaddr);
        ipcp_close(f->unit, "Unauthorized remote IP address");
        return;
        error("Peer is not authorized to use remote address %I", ho->hisaddr);
        ipcp_close(f->unit, "Unauthorized remote IP address");
        return;
@@ -1767,7 +1777,7 @@ ipcp_up(f)
                wo->ouraddr = go->ouraddr;
            } else
                script_unsetenv("OLDIPLOCAL");
                wo->ouraddr = go->ouraddr;
            } else
                script_unsetenv("OLDIPLOCAL");
-           if (ho->hisaddr != wo->hisaddr) {
+           if (ho->hisaddr != wo->hisaddr && wo->hisaddr != 0) {
                warn("Remote IP address changed to %I", ho->hisaddr);
                script_setenv("OLDIPREMOTE", ip_ntoa(wo->hisaddr), 0);
                wo->hisaddr = ho->hisaddr;
                warn("Remote IP address changed to %I", ho->hisaddr);
                script_setenv("OLDIPREMOTE", ip_ntoa(wo->hisaddr), 0);
                wo->hisaddr = ho->hisaddr;
@@ -1789,7 +1799,7 @@ ipcp_up(f)
                    default_route_set[f->unit] = 1;
 
            /* Make a proxy ARP entry if requested. */
                    default_route_set[f->unit] = 1;
 
            /* Make a proxy ARP entry if requested. */
-           if (ipcp_wantoptions[f->unit].proxy_arp)
+           if (ho->hisaddr != 0 && ipcp_wantoptions[f->unit].proxy_arp)
                if (sifproxyarp(f->unit, ho->hisaddr))
                    proxy_arp_set[f->unit] = 1;
 
                if (sifproxyarp(f->unit, ho->hisaddr))
                    proxy_arp_set[f->unit] = 1;
 
@@ -1839,14 +1849,15 @@ ipcp_up(f)
                default_route_set[f->unit] = 1;
 
        /* Make a proxy ARP entry if requested. */
                default_route_set[f->unit] = 1;
 
        /* Make a proxy ARP entry if requested. */
-       if (ipcp_wantoptions[f->unit].proxy_arp)
+       if (ho->hisaddr != 0 && ipcp_wantoptions[f->unit].proxy_arp)
            if (sifproxyarp(f->unit, ho->hisaddr))
                proxy_arp_set[f->unit] = 1;
 
        ipcp_wantoptions[0].ouraddr = go->ouraddr;
 
        notice("local  IP address %I", go->ouraddr);
            if (sifproxyarp(f->unit, ho->hisaddr))
                proxy_arp_set[f->unit] = 1;
 
        ipcp_wantoptions[0].ouraddr = go->ouraddr;
 
        notice("local  IP address %I", go->ouraddr);
-       notice("remote IP address %I", ho->hisaddr);
+       if (ho->hisaddr != 0)
+           notice("remote IP address %I", ho->hisaddr);
        if (go->dnsaddr[0])
            notice("primary   DNS address %I", go->dnsaddr[0]);
        if (go->dnsaddr[1])
        if (go->dnsaddr[0])
            notice("primary   DNS address %I", go->dnsaddr[0]);
        if (go->dnsaddr[1])
index aba33d3b413e2a65d8839e82317bb5c065bbbc19..b091030d708f4eafb29fcb66e0b7913f7356953e 100644 (file)
@@ -2346,11 +2346,13 @@ int sifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr,
 /*
  *  Set the gateway address
  */
 /*
  *  Set the gateway address
  */
-    SIN_ADDR(ifr.ifr_dstaddr) = his_adr;
-    if (ioctl(sock_fd, SIOCSIFDSTADDR, (caddr_t) &ifr) < 0) {
-       if (! ok_error (errno))
-           error("ioctl(SIOCSIFDSTADDR): %m (line %d)", __LINE__);
-       return (0);
+    if (his_adr != 0) {
+       SIN_ADDR(ifr.ifr_dstaddr) = his_adr;
+       if (ioctl(sock_fd, SIOCSIFDSTADDR, (caddr_t) &ifr) < 0) {
+           if (! ok_error (errno))
+               error("ioctl(SIOCSIFDSTADDR): %m (line %d)", __LINE__);
+           return (0);
+       }
     }
 /*
  *  Set the netmask.
     }
 /*
  *  Set the netmask.