www.usr.com/support/gpl/USR9107_release.1.4.tar.gz
[bcm963xx.git] / userapps / opensource / ppp / pppoe / ipcp.c
index 9924e5e..8f42577 100755 (executable)
@@ -113,7 +113,9 @@ static int setvjslots __P((char **));
 static int setdnsaddr __P((char **));
 static int setwinsaddr __P((char **));
 static int setnetmask __P((char **));
-static int setipaddr __P((char *, char **, int));
+// brcm
+int setipaddr __P((char *, char **, int));
+// brcm
 static void printipaddr __P((option_t *, void (*)(void *, char *,...),void *));
 
 static option_t ipcp_option_list[] = {
@@ -381,7 +383,7 @@ setwinsaddr(argv)
  * If doit is 0, the call is to check whether this option is
  * potentially an IP address specification.
  */
-static int
+int
 setipaddr(arg, argv, doit)
     char *arg;
     char **argv;
@@ -422,7 +424,7 @@ setipaddr(arg, argv, doit)
        *colon = ':';
        prio_local = option_priority;
     }
-  
     /*
      * If colon last character, then no remote addr.
      */
@@ -444,6 +446,9 @@ setipaddr(arg, argv, doit)
            wo->hisaddr = remote;
        prio_remote = option_priority;
     }
+    // brcm
+    ask_for_local = wo->ouraddr != 0 || !disable_defaultip;
+    // brcm
 
     return 1;
 }
@@ -535,6 +540,7 @@ static void
 ipcp_init(unit)
     int unit;
 {
+    IPCPDEBUG(("IPCP: Init"));
     fsm *f = &ipcp_fsm[unit];
     ipcp_options *wo = &ipcp_wantoptions[unit];
     ipcp_options *ao = &ipcp_allowoptions[unit];
@@ -723,6 +729,7 @@ ipcp_addci(f, ucp, lenp)
 {
     ipcp_options *go = &ipcp_gotoptions[f->unit];
     int len = *lenp;
+    IPCPDEBUG(("IPCP: Add CI"));
 
 #define ADDCIVJ(opt, neg, val, old, maxslotindex, cflag) \
     if (neg) { \
@@ -803,7 +810,8 @@ ipcp_ackci(f, p, len)
     u_short cilen, citype, cishort;
     u_int32_t cilong;
     u_char cimaxslotindex, cicflag;
-
+    
+    IPCPDEBUG(("IPCP: Acknowledge CI"));
     /*
      * CIs must be in exactly the same order that we sent...
      * Check packet length and CI length at each step.
@@ -916,7 +924,8 @@ ipcp_nakci(f, p, len)
     u_int32_t ciaddr1, ciaddr2, l, cidnsaddr;
     ipcp_options no;           /* options we've seen Naks for */
     ipcp_options try;          /* options to request next time */
-
+    IPCPDEBUG(("IPCP: NAK CI"));
     BZERO(&no, sizeof(no));
     try = *go;
 
@@ -1102,6 +1111,7 @@ ipcp_rejci(f, p, len)
     u_int32_t cilong;
     ipcp_options try;          /* options to request next time */
 
+    IPCPDEBUG(("IPCP: Reject CI"));
     try = *go;
     /*
      * Any Rejected CIs must be in exactly the same order that we sent.
@@ -1129,6 +1139,8 @@ ipcp_rejci(f, p, len)
                goto bad; \
        } \
        try.neg = 0; \
+        /* USR9108 fail connection if IP if is regected */ \
+        try.ouraddr = 0; \     
     }
 
 #define REJCIVJ(opt, neg, val, old, maxslot, cflag) \
@@ -1233,7 +1245,7 @@ ipcp_reqci(f, inp, len, reject_if_disagree)
      * Reset all his options.
      */
     BZERO(ho, sizeof(*ho));
-    
+    IPCPDEBUG(("IPCP: Request CI"));    
     /*
      * Process all his options.
      */
@@ -1533,6 +1545,7 @@ static int
 ip_demand_conf(u)
     int u;
 {
+    IPCPDEBUG(("IPCP: Demand config"));
     ipcp_options *wo = &ipcp_wantoptions[u];
 
     if (wo->hisaddr == 0) {
@@ -1574,7 +1587,6 @@ ip_demand_conf(u)
 static int file_save(char * path, char * content, int check)
 {
     FILE *f;
-    char cmd[128]="";
 
     // brcm
     if (check) {
@@ -1605,10 +1617,9 @@ static int file_save(char * path, char * content, int check)
 // brcm
 static void config_save()
 {
-    FILE *f;
     char path[128]="";
-    static wan_config_router_check=1;
-    static wan_config_dns_check=1;
+    static int wan_config_router_check=1;
+    static int wan_config_dns_check=1;
     char cmd[64]="";
     
     if (strlen(session_path) > 0)