This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC 1877 (IPCP Extensions for DNS)


Attached patch allows the primary DNS address to be
learned as part of PPP negotiation.

In addition, it exposes a new function to allow the
application to get the negotiated addresses.

-- Matt


		
__________________________________ 
Yahoo! Mail Mobile 
Take Yahoo! Mail with you! Check email on your mobile phone. 
http://mobile.yahoo.com/learn/mail 
Index: ppp/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/ChangeLog,v
retrieving revision 1.11
diff -u -w -r1.11 ChangeLog
--- ppp/current/ChangeLog	27 Apr 2005 06:20:45 -0000	1.11
+++ ppp/current/ChangeLog	26 May 2005 18:03:36 -0000
@@ -1,3 +1,12 @@
+2005-05-26	Matt Jerdonek <maj1224@yahoo.com>
+
+	* src/ipcp.c:
+	* include/ipcp.h: Added code to support RFC 1877 (IPCP
+	  Extension for DNS) for client operation.
+	* src/sys-ecos.c:
+	* include/ppp.h: Added function for application to get
+	  the negotiated addresses from the PPP stack.
+
 2005-04-21	Matt Jerdonek <maj1224@yahoo.com>
 
 	* src/ipcp.c:
Index: ppp/current/include/ipcp.h
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/include/ipcp.h,v
retrieving revision 1.2
diff -u -w -r1.2 ipcp.h
--- ppp/current/include/ipcp.h	17 Apr 2004 03:13:06 -0000	1.2
+++ ppp/current/include/ipcp.h	26 May 2005 18:03:36 -0000
@@ -101,6 +101,10 @@
     int old_vj : 1;		/* use old (short) form of VJ option? */
     int accept_local : 1;	/* accept peer's value for ouraddr */
     int accept_remote : 1;	/* accept peer's value for hisaddr */
+    int neg_dns1 : 1;       /* Negotiate primary domain name server? */
+    int neg_wins1 : 1;      /* Negotiate primary WINS? */
+    int neg_dns2 : 1;       /* Negotiate secondary domain name server? */
+    int neg_wins2 : 1;      /* Negotiate secondary WINS? */
     u_short vj_protocol;	/* protocol value to use in VJ option */
     u_char maxslotindex, cflag;	/* values for RFC1332 VJ compression neg. */
     u_int32_t ouraddr, hisaddr;	/* Addresses in NETWORK BYTE ORDER */
Index: ppp/current/include/ppp.h
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/include/ppp.h,v
retrieving revision 1.4
diff -u -w -r1.4 ppp.h
--- ppp/current/include/ppp.h	7 Apr 2005 16:07:00 -0000	1.4
+++ ppp/current/include/ppp.h	26 May 2005 18:03:36 -0000
@@ -71,8 +71,7 @@
 typedef CYG_ADDRWORD cyg_ppp_handle_t;
 
 // -------------------------------------------------------------------------
-/* PPP statistics */
-
+/* PPP failure statistics */
 typedef struct {
 	int auth_failures;        /* PAP or CHAP failures */
 	int no_proto;             /* No network protocol running */
@@ -81,11 +80,19 @@
 	int loopback;             /* Loopback detected */
 	int no_response;          /* Peer not responding */
 } cyg_ppp_stats_t;
-
 extern cyg_ppp_stats_t cyg_ppp_stats; /* PPP statistics */
-
 // -------------------------------------------------------------------------
+// PPP negotiated addresses
+typedef struct {
+	u_int32_t local_ip;       /* Local ip address */
+	u_int32_t peer_ip;        /* Peer ip address */
+	u_int32_t pri_dns;        /* Primary DNS address */
+	u_int32_t alt_dns;        /* Alternate DNS address */
+	u_int32_t pri_wins;       /* Primary WINS address */
+	u_int32_t alt_wins;       /* Alternate WINS address */
+} cyg_ppp_neg_addrs_t;
 
+// -------------------------------------------------------------------------
 typedef struct
 {
     unsigned int
@@ -98,7 +105,6 @@
         refuse_chap     : 1,	        /* Don't wanna auth. ourselves with CHAP */
         neg_accm        : 1             /* Flag to enable ACCM negotiation */
         ;
-
     cyg_serial_baud_rate_t      baud;   /* serial line baud rate */
     
     int         conf_accm;              /* Configurable value of ACCM */
@@ -150,5 +156,6 @@
 
 
 // -------------------------------------------------------------------------
+externC u_int32_t cyg_ppp_get_neg_addrs(cyg_ppp_neg_addrs_t *addrs);
 #endif // CYGONCE_PPP_PPP_H multiple inclusion protection
 // EOF ppp.h
Index: ppp/current/src/ipcp.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/src/ipcp.c,v
retrieving revision 1.4
diff -u -w -r1.4 ipcp.c
--- ppp/current/src/ipcp.c	27 Apr 2005 06:20:50 -0000	1.4
+++ ppp/current/src/ipcp.c	26 May 2005 18:03:37 -0000
@@ -233,6 +233,7 @@
     wo->ouraddr     = ppp_tty.options->our_address;
     wo->hisaddr     = ppp_tty.options->his_address;
     wo->default_route = ppp_tty.options->default_route;
+    wo->neg_dns1 = 1;       
 
     /* max slots and slot-id compression are currently hardwired in */
     /* ppp_if.c to 16 and 1, this needs to be changed (among other */
@@ -383,7 +384,11 @@
     }
 
     return (LENCIADDR(go->neg_addr, go->old_addrs) +
-	    LENCIVJ(go->neg_vj, go->old_vj));
+	    LENCIVJ(go->neg_vj, go->old_vj) + 
+	    LENCIADDR(go->neg_dns1, 0) +
+	    LENCIADDR(go->neg_wins1, 0) +
+	    LENCIADDR(go->neg_dns2, 0) +
+	    LENCIADDR(go->neg_wins2, 0));
 }
 
 
@@ -439,6 +444,12 @@
     ADDCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj,
 	    go->maxslotindex, go->cflag);
 
+	ADDCIADDR(CI_MS_DNS1, go->neg_dns1, 0, go->dnsaddr[0], 0);
+	ADDCIADDR(CI_MS_WINS1, go->neg_wins1, 0, go->winsaddr[0], 0);
+	ADDCIADDR(CI_MS_DNS2, go->neg_dns2, 0, go->dnsaddr[1], 0);
+	ADDCIADDR(CI_MS_WINS2, go->neg_wins2, 0, go->winsaddr[1], 0);			
+	
+
     *lenp -= len;
 }
 
@@ -519,6 +530,11 @@
     ACKCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj,
 	    go->maxslotindex, go->cflag);
 
+	ACKCIADDR(CI_MS_DNS1, go->neg_dns1, 0, go->dnsaddr[0], 0);
+	ACKCIADDR(CI_MS_WINS1, go->neg_wins1, 0, go->winsaddr[0], 0);
+	ACKCIADDR(CI_MS_DNS2, go->neg_dns2, 0, go->dnsaddr[1], 0);
+	ACKCIADDR(CI_MS_WINS2, go->neg_wins2, 0, go->winsaddr[1], 0);			
+
     /*
      * If there are any remaining CIs, then this packet is bad.
      */
@@ -640,6 +656,14 @@
 	    );
 
     /*
+	 * Accept the peer's idea of the DNS and WINS addresses
+	 */
+	NAKCIADDR(CI_MS_DNS1, neg_dns1, 0, try.dnsaddr[0] = ciaddr1;);
+	NAKCIADDR(CI_MS_WINS1, neg_wins1, 0, try.winsaddr[0] = ciaddr1;);
+	NAKCIADDR(CI_MS_DNS2, neg_dns2, 0, try.dnsaddr[1] = ciaddr1;);
+	NAKCIADDR(CI_MS_WINS2, neg_wins2, 0, try.winsaddr[1] = ciaddr1;);			
+
+    /*
      * There may be remaining CIs, if the peer is requesting negotiation
      * on an option that we didn't include in our request packet.
      * If they want to negotiate about IP addresses, we comply.
@@ -720,6 +744,7 @@
 {
     ipcp_options *go = &ipcp_gotoptions[f->unit];
     u_char cimaxslotindex, ciflag, cilen;
+    u_char citype, *next;    
     u_short cishort;
     u_int32_t cilong;
     ipcp_options try;		/* options to request next time */
@@ -782,6 +807,36 @@
 	    go->maxslotindex, go->cflag);
 
     /*
+     * There may be remaining CIs, if the peer is unable to support
+     * DNS or WINS negotiation.  If so, just turn them off
+     *
+     */	    
+	    
+    while (len > CILEN_VOID) {
+	GETCHAR(citype, p);
+	GETCHAR(cilen, p);
+	if( (len -= cilen) < 0 )
+	    goto bad;
+	next = p + cilen - 2;
+
+	switch (citype) {
+	case CI_MS_DNS1:
+		try.neg_dns1 = 0;
+		break;
+	case CI_MS_WINS1:
+		try.neg_wins1 = 0;
+		break;
+	case CI_MS_DNS2:
+		try.neg_dns2 = 0;
+		break;
+	case CI_MS_WINS2:
+		try.neg_wins2 = 0;
+		break;
+	}
+	p = next;
+    }		
+
+    /*
      * If there are any remaining CIs, then this packet is bad.
      */
     if (len != 0)
Index: ppp/current/src/sys-ecos.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/src/sys-ecos.c,v
retrieving revision 1.7
diff -u -w -r1.7 sys-ecos.c
--- ppp/current/src/sys-ecos.c	27 Apr 2005 06:20:50 -0000	1.7
+++ ppp/current/src/sys-ecos.c	26 May 2005 18:03:37 -0000
@@ -1802,6 +1802,26 @@
     cyg_thread_delete( ppp_tty.pppd_thread );
 }
 
+// -------------------------------------------------------------------------
+
+externC u_int32_t cyg_ppp_get_neg_addrs(cyg_ppp_neg_addrs_t *addrs)
+{
+	if (phase == PHASE_NETWORK && ifaddrs[0] != 0)
+	{
+		addrs->local_ip = ipcp_gotoptions[0].ouraddr;
+		addrs->peer_ip = ipcp_hisoptions[0].hisaddr;
+		addrs->pri_dns = ipcp_gotoptions[0].dnsaddr[0];
+		addrs->alt_dns = ipcp_gotoptions[0].dnsaddr[1];
+		addrs->pri_wins = ipcp_gotoptions[0].winsaddr[0];
+		addrs->alt_wins = ipcp_gotoptions[0].winsaddr[1];
+		return(1);
+	}
+	else
+	{
+		return(0);
+	}
+}
+
 //=====================================================================
 // eCos extras
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]