Mercurial > ecos
changeset 1995:3910c29d7639
* 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.
* cdl/ppp.cdl: Added option to enable name server negotiation
and to automatically configure the DNS resolver with the
negotiated address
| author | asl |
|---|---|
| date | Mon, 20 Jun 2005 18:41:00 +0000 |
| parents | 399891b72ea8 |
| children | 2c3a824f07b9 |
| files | packages/net/ppp/current/ChangeLog packages/net/ppp/current/cdl/ppp.cdl packages/net/ppp/current/include/ipcp.h packages/net/ppp/current/include/ppp.h packages/net/ppp/current/src/ipcp.c packages/net/ppp/current/src/sys-ecos.c |
| diffstat | 6 files changed, 163 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/net/ppp/current/ChangeLog +++ b/packages/net/ppp/current/ChangeLog @@ -1,3 +1,15 @@ +2005-06-07 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. + * cdl/ppp.cdl: Added option to enable name server negotiation + and to automatically configure the DNS resolver with the + negotiated address + 2005-04-21 Matt Jerdonek <maj1224@yahoo.com> * src/ipcp.c:
--- a/packages/net/ppp/current/cdl/ppp.cdl +++ b/packages/net/ppp/current/cdl/ppp.cdl @@ -248,6 +248,31 @@ cdl_package CYGPKG_PPP { } } + cdl_component CYGPKG_PPP_NEGOTIATE_OPTIONS { + display "PPP negotiation options" + flavor none + no_define + + cdl_option CYGOPT_PPP_NS_NEGOTIATE { + display "Name server support" + default_value CYGINT_ISO_DNS + flavor bool + description " + This option allows negotiation of the domain + name server IPCP extensions as defined in + RFC 1877" + } + cdl_option CYGOPT_PPP_DNS_CONFIGURE { + display "Allow the PPP code to configure the resolver" + default_value 1 + description " + The PPP code can negotionate with the peer what the + recommended DNS server is. This option causes the PPP + code to then configure the DNS resolver with the address + of the discovered server." + } + } + cdl_component CYGPKG_PPP_OPTIONS { display "PPP build options" flavor none
--- a/packages/net/ppp/current/include/ipcp.h +++ b/packages/net/ppp/current/include/ipcp.h @@ -101,6 +101,12 @@ typedef struct ipcp_options { 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 */ +#ifdef CYGOPT_PPP_NS_NEGOTIATE + 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? */ +#endif 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 */
--- a/packages/net/ppp/current/include/ppp.h +++ b/packages/net/ppp/current/include/ppp.h @@ -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 @@ typedef struct { 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 @@ typedef struct 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,9 @@ externC cyg_int32 cyg_ppp_chat( const ch // ------------------------------------------------------------------------- +#ifdef CYGOPT_PPP_NS_NEGOTIATE +externC u_int32_t cyg_ppp_get_neg_addrs(cyg_ppp_neg_addrs_t *addrs); +#endif +// ------------------------------------------------------------------------- #endif // CYGONCE_PPP_PPP_H multiple inclusion protection // EOF ppp.h
--- a/packages/net/ppp/current/src/ipcp.c +++ b/packages/net/ppp/current/src/ipcp.c @@ -83,12 +83,17 @@ #include <sys/socket.h> #include <netinet/in.h> +#include <pkgconf/system.h> #include <pkgconf/ppp.h> #include "cyg/ppp/pppd.h" #include "cyg/ppp/fsm.h" #include "cyg/ppp/ipcp.h" #include "cyg/ppp/ppp_io.h" +#ifdef CYGPKG_NS_DNS +#include <cyg/ns/dns/dns.h> +#endif + #define option_error(msg) db_printf("Option error: %s\n", msg ) /* global vars */ @@ -234,6 +239,10 @@ ipcp_init(unit) wo->hisaddr = ppp_tty.options->his_address; wo->default_route = ppp_tty.options->default_route; +#ifdef CYGOPT_PPP_NS_NEGOTIATE + wo->neg_dns1 = 1; +#endif + /* max slots and slot-id compression are currently hardwired in */ /* ppp_if.c to 16 and 1, this needs to be changed (among other */ /* things) gmc */ @@ -352,6 +361,7 @@ ipcp_cilen(f) ipcp_options *go = &ipcp_gotoptions[f->unit]; ipcp_options *wo = &ipcp_wantoptions[f->unit]; ipcp_options *ho = &ipcp_hisoptions[f->unit]; + int len; #define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0) #define LENCIADDR(neg, old) (neg ? (old? CILEN_ADDRS : CILEN_ADDR) : 0) @@ -382,8 +392,16 @@ ipcp_cilen(f) } } - return (LENCIADDR(go->neg_addr, go->old_addrs) + - LENCIVJ(go->neg_vj, go->old_vj)); + len = LENCIADDR(go->neg_addr, go->old_addrs) + + LENCIVJ(go->neg_vj, go->old_vj); + +#ifdef CYGOPT_PPP_NS_NEGOTIATE + len += LENCIADDR(go->neg_dns1, 0) + + LENCIADDR(go->neg_wins1, 0) + + LENCIADDR(go->neg_dns2, 0) + + LENCIADDR(go->neg_wins2, 0); +#endif + return (len); } @@ -439,6 +457,13 @@ ipcp_addci(f, ucp, lenp) ADDCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, go->maxslotindex, go->cflag); +#ifdef CYGOPT_PPP_NS_NEGOTIATE + 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); +#endif + *lenp -= len; } @@ -519,6 +544,13 @@ ipcp_ackci(f, p, len) ACKCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, go->maxslotindex, go->cflag); +#ifdef CYGOPT_PPP_NS_NEGOTIATE + 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); +#endif + /* * If there are any remaining CIs, then this packet is bad. */ @@ -639,6 +671,22 @@ ipcp_nakci(f, p, len) } ); +#ifdef CYGOPT_PPP_NS_NEGOTIATE + /* + * 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;); +#ifdef CYGOPT_PPP_DNS_CONFIGURE + if (try.dnsaddr[0] != 0 ) + { + cyg_dns_res_init((struct in_addr *)&try.dnsaddr[0]); + } +#endif +#endif + /* * There may be remaining CIs, if the peer is requesting negotiation * on an option that we didn't include in our request packet. @@ -723,6 +771,9 @@ ipcp_rejci(f, p, len) u_short cishort; u_int32_t cilong; ipcp_options try; /* options to request next time */ +#ifdef CYGOPT_PPP_NS_NEGOTIATE + u_char citype, *next; +#endif try = *go; /* @@ -781,6 +832,38 @@ ipcp_rejci(f, p, len) REJCIVJ(CI_COMPRESSTYPE, neg_vj, go->vj_protocol, go->old_vj, go->maxslotindex, go->cflag); +#ifdef CYGOPT_PPP_NS_NEGOTIATE +/* + * 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; + } +#endif + /* * If there are any remaining CIs, then this packet is bad. */
--- a/packages/net/ppp/current/src/sys-ecos.c +++ b/packages/net/ppp/current/src/sys-ecos.c @@ -1802,6 +1802,26 @@ externC void cyg_ppp_wait_down( cyg_ppp_ cyg_thread_delete( ppp_tty.pppd_thread ); } +// ------------------------------------------------------------------------- +#ifdef CYGOPT_PPP_NS_NEGOTIATE +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); + } +} +#endif //===================================================================== // eCos extras
