projects
/
l2tpns.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
manual update
[l2tpns.git]
/
ppp.c
diff --git
a/ppp.c
b/ppp.c
index
2343ad3
..
5ed8563
100644
(file)
--- a/
ppp.c
+++ b/
ppp.c
@@
-12,6
+12,11
@@
#include "tbf.h"
#include "cluster.h"
#include "tbf.h"
#include "cluster.h"
+#ifdef LAC
+#include "l2tplac.h"
+#endif
+#include "pppoe.h"
+
extern tunnelt *tunnel;
extern bundlet *bundle;
extern fragmentationt *frag;
extern tunnelt *tunnel;
extern bundlet *bundle;
extern fragmentationt *frag;
@@
-21,6
+26,7
@@
extern int tunfd;
extern char hostname[];
extern uint32_t eth_tx;
extern time_t time_now;
extern char hostname[];
extern uint32_t eth_tx;
extern time_t time_now;
+extern uint64_t time_now_ms;
extern configt *config;
static int add_lcp_auth(uint8_t *b, int size, int authtype);
extern configt *config;
static int add_lcp_auth(uint8_t *b, int size, int authtype);
@@
-99,6
+105,14
@@
void processpap(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
LOG(3, s, t, "PAP login %s/%s\n", user, pass);
}
LOG(3, s, t, "PAP login %s/%s\n", user, pass);
}
+#ifdef LAC
+ if ((!config->disable_lac_func) && lac_conf_forwardtoremotelns(s, user))
+ {
+ // Creating a tunnel/session has been started
+ return;
+ }
+#endif
+
if (session[s].ip || !(r = radiusnew(s)))
{
// respond now, either no RADIUS available or already authenticated
if (session[s].ip || !(r = radiusnew(s)))
{
// respond now, either no RADIUS available or already authenticated
@@
-250,6
+264,16
@@
void processchap(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
packet.username = calloc(l + 1, 1);
memcpy(packet.username, p, l);
packet.username = calloc(l + 1, 1);
memcpy(packet.username, p, l);
+#ifdef LAC
+ if ((!config->disable_lac_func) && lac_conf_forwardtoremotelns(s, packet.username))
+ {
+ free(packet.username);
+ free(packet.password);
+ // Creating a tunnel/session has been started
+ return;
+ }
+#endif
+
run_plugins(PLUGIN_PRE_AUTH, &packet);
if (!packet.continue_auth)
{
run_plugins(PLUGIN_PRE_AUTH, &packet);
if (!packet.continue_auth)
{
@@
-402,7
+426,7
@@
void lcp_open(sessionidt s, tunnelidt t)
}
}
}
}
-
static
void lcp_restart(sessionidt s)
+void lcp_restart(sessionidt s)
{
session[s].ppp.phase = Establish;
// This-Layer-Down
{
session[s].ppp.phase = Establish;
// This-Layer-Down
@@
-535,7
+559,7
@@
void processlcp(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
if (session[s].die) // going down...
return;
if (session[s].die) // going down...
return;
- LOG((
*p == EchoReq || *p == EchoReply) ? 4 : 3
, s, t,
+ LOG((
(*p == EchoReq || *p == EchoReply) ? 4 : 3)
, s, t,
"LCP: recv %s\n", ppp_code(*p));
if (config->debug > 3) dumplcp(p, l);
"LCP: recv %s\n", ppp_code(*p));
if (config->debug > 3) dumplcp(p, l);
@@
-1876,6
+1900,14
@@
void processmpin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
sess_local[s].last_seq = seq_num;
sess_local[s].last_seq = seq_num;
+ // calculate the jitter average
+ uint32_t ljitter = time_now_ms - sess_local[s].prev_time;
+ if (ljitter > 0)
+ {
+ sess_local[s].jitteravg = (sess_local[s].jitteravg + ljitter)>>1;
+ sess_local[s].prev_time = time_now_ms;
+ }
+
uint32_t Mmin;
if (seq_num < this_fragmentation->M)
uint32_t Mmin;
if (seq_num < this_fragmentation->M)
@@
-1902,7
+1934,7
@@
void processmpin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
{
// There have a long break of the link !!!!!!!!
// M_offset is bigger that the fragmentation buffer size
{
// There have a long break of the link !!!!!!!!
// M_offset is bigger that the fragmentation buffer size
- LOG(3, s, t, "MPPP: M_offset out of range, min:%d, begin_seq:%d
\n", Mmin, this_fragmentation->start_seq
);
+ LOG(3, s, t, "MPPP: M_offset out of range, min:%d, begin_seq:%d
, jitteravg:%d\n", Mmin, this_fragmentation->start_seq, sess_local[s].jitteravg
);
// Calculate the new start index, the previous frag are lost
begin_index = (M_offset + this_fragmentation->start_index) & MAXFRAGNUM_MASK;
// Calculate the new start index, the previous frag are lost
begin_index = (M_offset + this_fragmentation->start_index) & MAXFRAGNUM_MASK;
@@
-1927,7
+1959,7
@@
void processmpin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
if (frag_offset >= MAXFRAGNUM)
{
// frag_offset is bigger that the fragmentation buffer size
if (frag_offset >= MAXFRAGNUM)
{
// frag_offset is bigger that the fragmentation buffer size
- LOG(3, s, t, "MPPP: Index out of range, seq:%d, begin_seq:%d,
size frag:%d\n", seq_num, this_fragmentation->start_seq, l
);
+ LOG(3, s, t, "MPPP: Index out of range, seq:%d, begin_seq:%d,
jitteravg:%d\n", seq_num, this_fragmentation->start_seq, sess_local[s].jitteravg
);
return;
}
return;
}
@@
-1939,13
+1971,15
@@
void processmpin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
if (this_frag->length > 0)
// This fragment is lost, It was around the buffer and it was never completed the packet.
if (this_frag->length > 0)
// This fragment is lost, It was around the buffer and it was never completed the packet.
- LOG(3, this_frag->sid, this_frag->tid, "MPPP: (INSERT) seq_num:%d frag_index:%d flags:%d is LOST\n",
- this_frag->seq, frag_index, this_frag->flags);
+ LOG(3, this_frag->sid, this_frag->tid, "MPPP: (INSERT) seq_num:%d frag_index:%d flags:%d
jitteravg:%d
is LOST\n",
+ this_frag->seq, frag_index, this_frag->flags
, this_frag->jitteravg
);
this_frag->length = l;
this_frag->sid = s;
this_frag->length = l;
this_frag->sid = s;
+ this_frag->tid = t;
this_frag->flags = flags;
this_frag->seq = seq_num;
this_frag->flags = flags;
this_frag->seq = seq_num;
+ this_frag->jitteravg = sess_local[s].jitteravg;
memcpy(this_frag->data, p, l);
LOG(4, s, t, "MPPP: seq_num:%d frag_index:%d INSERTED flags: %02X\n", seq_num, frag_index, flags);
memcpy(this_frag->data, p, l);
LOG(4, s, t, "MPPP: seq_num:%d frag_index:%d INSERTED flags: %02X\n", seq_num, frag_index, flags);
@@
-1967,8
+2001,9
@@
void processmpin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
{
// This fragment is lost, It was around the buffer and it was never completed the packet.
LOG(3, this_fragmentation->fragment[frag_index_next].sid, this_fragmentation->fragment[frag_index_next].tid,
{
// This fragment is lost, It was around the buffer and it was never completed the packet.
LOG(3, this_fragmentation->fragment[frag_index_next].sid, this_fragmentation->fragment[frag_index_next].tid,
- "MPPP: (NEXT) seq_num:%d frag_index:%d flags:%d is LOST\n",
- this_fragmentation->fragment[frag_index_next].seq, frag_index_next, this_fragmentation->fragment[frag_index_next].flags);
+ "MPPP: (NEXT) seq_num:%d frag_index:%d flags:%d jitteravg:%d is LOST\n",
+ this_fragmentation->fragment[frag_index_next].seq, frag_index_next,
+ this_fragmentation->fragment[frag_index_next].flags, this_fragmentation->fragment[frag_index_next].jitteravg);
// this frag is lost
this_fragmentation->fragment[frag_index_next].length = 0;
this_fragmentation->fragment[frag_index_next].flags = 0;
// this frag is lost
this_fragmentation->fragment[frag_index_next].length = 0;
this_fragmentation->fragment[frag_index_next].flags = 0;
@@
-1985,8
+2020,9
@@
void processmpin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
{
// This fragment is lost, It was around the buffer and it was never completed the packet.
LOG(3, this_fragmentation->fragment[frag_index_prev].sid, this_fragmentation->fragment[frag_index_prev].tid,
{
// This fragment is lost, It was around the buffer and it was never completed the packet.
LOG(3, this_fragmentation->fragment[frag_index_prev].sid, this_fragmentation->fragment[frag_index_prev].tid,
- "MPPP: (PREV) seq_num:%d frag_index:%d flags:%d is LOST\n",
- this_fragmentation->fragment[frag_index_prev].seq, frag_index_prev, this_fragmentation->fragment[frag_index_prev].flags);
+ "MPPP: (PREV) seq_num:%d frag_index:%d flags:%d jitteravg:%d is LOST\n",
+ this_fragmentation->fragment[frag_index_prev].seq, frag_index_prev,
+ this_fragmentation->fragment[frag_index_prev].flags, this_fragmentation->fragment[frag_index_prev].jitteravg);
this_fragmentation->fragment[frag_index_prev].length = 0;
this_fragmentation->fragment[frag_index_prev].flags = 0;
this_fragmentation->fragment[frag_index_prev].length = 0;
this_fragmentation->fragment[frag_index_prev].flags = 0;
@@
-2030,8
+2066,9
@@
find_frame:
{
// This fragment is lost, it was never completed the packet.
LOG(3, this_fragmentation->fragment[end_index].sid, this_fragmentation->fragment[end_index].tid,
{
// This fragment is lost, it was never completed the packet.
LOG(3, this_fragmentation->fragment[end_index].sid, this_fragmentation->fragment[end_index].tid,
- "MPPP: (FIND END) seq_num:%d frag_index:%d flags:%d is LOST\n",
- this_fragmentation->fragment[end_index].seq, begin_index, this_fragmentation->fragment[end_index].flags);
+ "MPPP: (FIND END) seq_num:%d frag_index:%d flags:%d jitteravg:%d is LOST\n",
+ this_fragmentation->fragment[end_index].seq, begin_index,
+ this_fragmentation->fragment[end_index].flags, this_fragmentation->fragment[end_index].jitteravg);
// this frag is lost
this_fragmentation->fragment[end_index].length = 0;
this_fragmentation->fragment[end_index].flags = 0;
// this frag is lost
this_fragmentation->fragment[end_index].length = 0;
this_fragmentation->fragment[end_index].flags = 0;
@@
-2060,8
+2097,9
@@
find_frame:
{
// This fragment is lost, it was never completed the packet.
LOG(3, this_fragmentation->fragment[begin_index].sid, this_fragmentation->fragment[begin_index].tid,
{
// This fragment is lost, it was never completed the packet.
LOG(3, this_fragmentation->fragment[begin_index].sid, this_fragmentation->fragment[begin_index].tid,
- "MPPP: (FIND BEGIN) seq_num:%d frag_index:%d flags:%d is LOST\n",
- this_fragmentation->fragment[begin_index].seq, begin_index, this_fragmentation->fragment[begin_index].flags);
+ "MPPP: (FIND BEGIN) seq_num:%d frag_index:%d flags:%d jitteravg:%d is LOST\n",
+ this_fragmentation->fragment[begin_index].seq, begin_index,
+ this_fragmentation->fragment[begin_index].flags, this_fragmentation->fragment[begin_index].jitteravg);
// this frag is lost
this_fragmentation->fragment[begin_index].length = 0;
this_fragmentation->fragment[begin_index].flags = 0;
// this frag is lost
this_fragmentation->fragment[begin_index].length = 0;
this_fragmentation->fragment[begin_index].flags = 0;
@@
-2072,7
+2110,7
@@
find_frame:
}
assembling_frame:
}
assembling_frame:
- // try to assemble the frame that has the received fragment as a member
+ // try to assemble the frame that has the received fragment as a member
// get the beginning of this frame
begin_index = end_index = this_fragmentation->start_index;
if (this_fragmentation->fragment[begin_index].length)
// get the beginning of this frame
begin_index = end_index = this_fragmentation->start_index;
if (this_fragmentation->fragment[begin_index].length)
@@
-2157,8
+2195,9
@@
assembling_frame:
(this_fragmentation->fragment[begin_index].seq != this_fragmentation->start_seq))
{
LOG(3, this_fragmentation->fragment[begin_index].sid, this_fragmentation->fragment[begin_index].tid,
(this_fragmentation->fragment[begin_index].seq != this_fragmentation->start_seq))
{
LOG(3, this_fragmentation->fragment[begin_index].sid, this_fragmentation->fragment[begin_index].tid,
- "MPPP: (START) seq_num:%d frag_index:%d flags:%d is LOST\n",
- this_fragmentation->fragment[begin_index].seq, begin_index, this_fragmentation->fragment[begin_index].flags);
+ "MPPP: (START) seq_num:%d frag_index:%d flags:%d jitteravg:%d is LOST\n",
+ this_fragmentation->fragment[begin_index].seq, begin_index,
+ this_fragmentation->fragment[begin_index].flags, this_fragmentation->fragment[begin_index].jitteravg);
this_fragmentation->fragment[begin_index].length = 0;
this_fragmentation->fragment[begin_index].flags = 0;
}
this_fragmentation->fragment[begin_index].length = 0;
this_fragmentation->fragment[begin_index].flags = 0;
}
@@
-2483,6
+2522,11
@@
uint8_t *makeppp(uint8_t *b, int size, uint8_t *p, int l, sessionidt s, tunnelid
uint16_t type = mtype;
uint8_t *start = b;
uint16_t type = mtype;
uint8_t *start = b;
+ if (t == TUNNEL_ID_PPPOE)
+ {
+ return pppoe_makeppp(b, size, p, l, s, t, mtype, prio, bid, mp_bits);
+ }
+
if (size < 16) // Need more space than this!!
{
LOG(0, s, t, "makeppp buffer too small for L2TP header (size=%d)\n", size);
if (size < 16) // Need more space than this!!
{
LOG(0, s, t, "makeppp buffer too small for L2TP header (size=%d)\n", size);