#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
-#include <sys/socket.h>
#include <linux/rtnetlink.h>
+#include <netinet/ip6.h>
+#include "dhcp6.h"
#include "l2tpns.h"
#include "constants.h"
#include "plugin.h"
if (session[s].ipv6prefixlen)
route6set(s, session[s].ipv6route, session[s].ipv6prefixlen, 1);
+ if (session[s].ipv6address.s6_addr[0])
+ {
+ // Check if included in prefix
+ if (sessionbyipv6(session[s].ipv6address) != s)
+ route6set(s, session[s].ipv6address, 128, 1);
+ }
+
// Send an initial RA (TODO: Should we send these regularly?)
send_ipv6_ra(s, t, NULL);
}
// (i.e. this routine writes to p[-4]).
void processipin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
{
- in_addr_t ip;
+ in_addr_t ip, ip_dst;
CSTAT(processipin);
}
ip = ntohl(*(uint32_t *)(p + 12));
+ ip_dst = *(uint32_t *)(p + 16);
if (l > MAXETHER)
{
if (session[s].tbf_in)
{
- // Are we throttling this session?
- if (config->cluster_iam_master)
- tbf_queue_packet(session[s].tbf_in, p, l);
- else
- master_throttle_packet(session[s].tbf_in, p, l);
- return;
+ if (!config->no_throttle_local_IP || !sessionbyip(ip_dst))
+ {
+ // Are we throttling this session?
+ if (config->cluster_iam_master)
+ tbf_queue_packet(session[s].tbf_in, p, l);
+ else
+ master_throttle_packet(session[s].tbf_in, p, l);
+ return;
+ }
}
// send to ethernet
return;
}
+ // Check if DhcpV6, IP dst: FF02::1:2, Src Port 0x0222 (546), Dst Port 0x0223 (547)
+ if (*(p + 6) == 17 && *(p + 24) == 0xFF && *(p + 25) == 2 &&
+ *(uint32_t *)(p + 26) == 0 && *(uint32_t *)(p + 30) == 0 &&
+ *(uint16_t *)(p + 34) == 0 && *(p + 36) == 0 && *(p + 37) == 1 && *(p + 38) == 0 && *(p + 39) == 2 &&
+ *(p + 40) == 2 && *(p + 41) == 0x22 && *(p + 42) == 2 && *(p + 43) == 0x23)
+ {
+ dhcpv6_process(s, t, p, l);
+ return;
+ }
+
// Add on the tun header
p -= 4;
*(uint32_t *) p = htonl(PKTIPV6);
q[1] = radius[r].id; // ID
q[4] = 16; // value size (size of challenge)
memcpy(q + 5, radius[r].auth, 16); // challenge
- strcpy((char *) q + 21, hostname); // our name
- *(uint16_t *) (q + 2) = htons(strlen(hostname) + 21); // length
- tunnelsend(b, strlen(hostname) + 21 + (q - b), t); // send it
+ strcpy((char *) q + 21, config->multi_n_hostname[tunnel[t].indexudp][0]?config->multi_n_hostname[tunnel[t].indexudp]:hostname); // our name
+ *(uint16_t *) (q + 2) = htons(strlen(config->multi_n_hostname[tunnel[t].indexudp][0]?config->multi_n_hostname[tunnel[t].indexudp]:hostname) + 21); // length
+ tunnelsend(b, strlen(config->multi_n_hostname[tunnel[t].indexudp][0]?config->multi_n_hostname[tunnel[t].indexudp]:hostname) + 21 + (q - b), t); // send it
}
// fill in a L2TP message with a PPP frame,