better cluster master collision resolution
[l2tpns.git] / ppp.c
diff --git a/ppp.c b/ppp.c
index 3b8839d..c69c603 100644 (file)
--- a/ppp.c
+++ b/ppp.c
@@ -1,6 +1,6 @@
 // L2TPNS PPP Stuff
 
 // L2TPNS PPP Stuff
 
-char const *cvs_id_ppp = "$Id: ppp.c,v 1.34 2004-11-30 00:50:03 bodea Exp $";
+char const *cvs_id_ppp = "$Id: ppp.c,v 1.38 2004-11-30 19:34:57 bodea Exp $";
 
 #include <stdio.h>
 #include <string.h>
 
 #include <stdio.h>
 #include <string.h>
@@ -401,7 +401,7 @@ void processlcp(tunnelidt t, sessionidt s, u8 *p, u16 l)
                                        *q++ = 6;
                                        memset(q, 0, 4); // asyncmap 0
                                        q += 4;
                                        *q++ = 6;
                                        memset(q, 0, 4); // asyncmap 0
                                        q += 4;
-                                       *((u16 *) (response + 2)) = q - response; // LCP header length
+                                       *((u16 *) (response + 2)) = htons(q - response); // LCP header length
                                        break;
 
                                case 3: // Authentication-Protocol
                                        break;
 
                                case 3: // Authentication-Protocol
@@ -438,7 +438,7 @@ void processlcp(tunnelidt t, sessionidt s, u8 *p, u16 l)
                                                memcpy(q, o, length);
                                                *(u16 *)(q += 2) = htons(PPPPAP); // NAK -> Use PAP instead
                                                q += length;
                                                memcpy(q, o, length);
                                                *(u16 *)(q += 2) = htons(PPPPAP); // NAK -> Use PAP instead
                                                q += length;
-                                               *((u16 *) (response + 2)) = q - response;
+                                               *((u16 *) (response + 2)) = htons(q - response);
                                        }
                                        break;
 
                                        }
                                        break;
 
@@ -469,7 +469,7 @@ void processlcp(tunnelidt t, sessionidt s, u8 *p, u16 l)
 
                                        memcpy(q, o, length);
                                        q += length;
 
                                        memcpy(q, o, length);
                                        q += length;
-                                       *((u16 *) (response + 2)) = q - response; // LCP header length
+                                       *((u16 *) (response + 2)) = htons(q - response); // LCP header length
                        }
                        x -= length;
                        o += length;
                        }
                        x -= length;
                        o += length;
@@ -478,12 +478,12 @@ void processlcp(tunnelidt t, sessionidt s, u8 *p, u16 l)
                if (!response)
                {
                        // Send back a ConfigAck
                if (!response)
                {
                        // Send back a ConfigAck
-                       q = makeppp(b, sizeof(b), p, l, t, s, PPPLCP);
+                       q = response = makeppp(b, sizeof(b), p, l, t, s, PPPLCP);
                        if (!q) return;
                        if (!q) return;
-                       response = *q = ConfigAck;
+                       *q = ConfigAck;
                }
 
                }
 
-               LOG(3, s, t, "Sending %s\n", ppp_lcp_types[response]);
+               LOG(3, s, t, "Sending %s\n", ppp_lcp_types[*response]);
                tunnelsend(b, l + (q - b), t);
 
                if (!(session[s].flags & SF_LCP_ACKED))
                tunnelsend(b, l + (q - b), t);
 
                if (!(session[s].flags & SF_LCP_ACKED))
@@ -666,7 +666,8 @@ void processipcp(tunnelidt t, sessionidt s, u8 *p, u16 l)
                                {
                                        *(u32 *) (i + 2) = htonl(session[s].dns1);
                                        *p = ConfigNak;
                                {
                                        *(u32 *) (i + 2) = htonl(session[s].dns1);
                                        *p = ConfigNak;
-                                       LOG(5, s, t, "   DNS1 = %s\n", fmtaddr(session[s].dns1, 0));
+                                       LOG(5, s, t, "   DNS1 = %s\n",
+                                               fmtaddr(htonl(session[s].dns1), 0));
                                }
                        }
                        if ((i = findppp(p, 0x83))) // Secondary DNS address (TBA, is it)
                                }
                        }
                        if ((i = findppp(p, 0x83))) // Secondary DNS address (TBA, is it)
@@ -675,7 +676,8 @@ void processipcp(tunnelidt t, sessionidt s, u8 *p, u16 l)
                                {
                                        *(u32 *) (i + 2) = htonl(session[s].dns2);
                                        *p = ConfigNak;
                                {
                                        *(u32 *) (i + 2) = htonl(session[s].dns2);
                                        *p = ConfigNak;
-                                       LOG(5, s, t, "   DNS2 = %s\n", fmtaddr(session[s].dns2, 0));
+                                       LOG(5, s, t, "   DNS2 = %s\n",
+                                               fmtaddr(htonl(session[s].dns2), 0));
                                }
                        }
                        i = findppp(p, 3);              // IP address
                                }
                        }
                        i = findppp(p, 3);              // IP address