CONFIG("radius_accounting", radius_accounting, BOOL),
CONFIG("radius_secret", radiussecret, STRING),
CONFIG("bind_address", bind_address, IP),
CONFIG("radius_accounting", radius_accounting, BOOL),
CONFIG("radius_secret", radiussecret, STRING),
CONFIG("bind_address", bind_address, IP),
CONFIG("send_garp", send_garp, BOOL),
CONFIG("throttle_speed", rl_rate, UNSIGNED_LONG),
CONFIG("throttle_buckets", num_tbfs, INT),
CONFIG("send_garp", send_garp, BOOL),
CONFIG("throttle_speed", rl_rate, UNSIGNED_LONG),
CONFIG("throttle_buckets", num_tbfs, INT),
//
void _log(int level, ipt address, sessionidt s, tunnelidt t, const char *format, ...)
{
//
void _log(int level, ipt address, sessionidt s, tunnelidt t, const char *format, ...)
{
if (log_stream)
{
_log(level, 0, 0, 0, "%s (%d bytes):\n", title, maxsize);
if (log_stream)
{
_log(level, 0, 0, 0, "%s (%d bytes):\n", title, maxsize);
- log(1, ip, 0, 0, "Route %s %u.%u.%u.%u/%u.%u.%u.%u %u.%u.%u.%u\n",
+ LOG(1, ip, 0, 0, "Route %s %u.%u.%u.%u/%u.%u.%u.%u %u.%u.%u.%u\n",
add ? "add" : "del",
ip >> 24, ip >> 16 & 0xff, ip >> 8 & 0xff, ip & 0xff,
mask >> 24, mask >> 16 & 0xff, mask >> 8 & 0xff, mask & 0xff,
gw >> 24, gw >> 16 & 0xff, gw >> 8 & 0xff, gw & 0xff);
if (ioctl(ifrfd, add ? SIOCADDRT : SIOCDELRT, (void *) &r) < 0)
add ? "add" : "del",
ip >> 24, ip >> 16 & 0xff, ip >> 8 & 0xff, ip & 0xff,
mask >> 24, mask >> 16 & 0xff, mask >> 8 & 0xff, mask & 0xff,
gw >> 24, gw >> 16 & 0xff, gw >> 8 & 0xff, gw & 0xff);
if (ioctl(ifrfd, add ? SIOCADDRT : SIOCDELRT, (void *) &r) < 0)
- log(0, 0, 0, 0, "routeset() error in ioctl: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "routeset() error in ioctl: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Can't open %s: %s\n", TUNDEVICE, strerror(errno));
+ LOG(0, 0, 0, 0, "Can't open %s: %s\n", TUNDEVICE, strerror(errno));
- log(0, 0, 0, 0, "Can't set tun interface: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Can't set tun interface: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Error setting tun address: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error setting tun address: %s\n", strerror(errno));
exit(1);
}
/* Bump up the qlen to deal with bursts from the network */
ifr.ifr_qlen = 1000;
if (ioctl(ifrfd, SIOCSIFTXQLEN, (void *) &ifr) < 0)
{
exit(1);
}
/* Bump up the qlen to deal with bursts from the network */
ifr.ifr_qlen = 1000;
if (ioctl(ifrfd, SIOCSIFTXQLEN, (void *) &ifr) < 0)
{
- log(0, 0, 0, 0, "Error setting tun queue length: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error setting tun queue length: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Error setting tun flags: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error setting tun flags: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Error setting tun ifindex: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error setting tun ifindex: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Error in UDP bind: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error in UDP bind: %s\n", strerror(errno));
setsockopt(controlfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
if (bind(controlfd, (void *) &addr, sizeof(addr)) < 0)
{
setsockopt(controlfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
if (bind(controlfd, (void *) &addr, sizeof(addr)) < 0)
{
- log(0, 0, 0, 0, "Error in control bind: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error in control bind: %s\n", strerror(errno));
- log(4, ip, s, session[s].tunnel, "Caching ip address %s\n", inet_toa(nip));
+ LOG(4, ip, s, session[s].tunnel, "Caching ip address %s\n", inet_toa(nip));
- log(4, ip, 0, 0, "Un-caching ip address %s\n", inet_toa(nip));
+ LOG(4, ip, 0, 0, "Un-caching ip address %s\n", inet_toa(nip));
- log(0, 0, 0, 0, "Error creating socket for GARP: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error creating socket for GARP: %s\n", strerror(errno));
return;
}
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, "eth0", sizeof(ifr.ifr_name) - 1);
if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0)
{
return;
}
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, "eth0", sizeof(ifr.ifr_name) - 1);
if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0)
{
- log(0, 0, 0, 0, "Error getting eth0 hardware address for GARP: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error getting eth0 hardware address for GARP: %s\n", strerror(errno));
close(s);
return;
}
memcpy(mac, &ifr.ifr_hwaddr.sa_data, 6*sizeof(char));
if (ioctl(s, SIOCGIFINDEX, &ifr) < 0)
{
close(s);
return;
}
memcpy(mac, &ifr.ifr_hwaddr.sa_data, 6*sizeof(char));
if (ioctl(s, SIOCGIFINDEX, &ifr) < 0)
{
- log(0, 0, 0, 0, "Error getting eth0 interface index for GARP: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error getting eth0 interface index for GARP: %s\n", strerror(errno));
- log(0, 0, 0, t, "tunnelsend called with 0 as tunnel id\n");
+ LOG(0, 0, 0, t, "tunnelsend called with 0 as tunnel id\n");
- log(1, 0, 0, t, "Error sending data out tunnel: no remote endpoint (tunnel not set up)\n");
+ LOG(1, 0, 0, t, "Error sending data out tunnel: no remote endpoint (tunnel not set up)\n");
- log(3, tunnel[t].ip, 0, t, "Control message resend try %d\n", tunnel[t].try);
+ LOG(3, tunnel[t].ip, 0, t, "Control message resend try %d\n", tunnel[t].try);
}
}
if (sendto(udpfd, buf, l, 0, (void *) &addr, sizeof(addr)) < 0)
{
}
}
if (sendto(udpfd, buf, l, 0, (void *) &addr, sizeof(addr)) < 0)
{
- log(0, tunnel[t].ip, ntohs((*(u16 *) (buf + 6))), t, "Error sending data out tunnel: %s (udpfd=%d, buf=%p, len=%d, dest=%s)\n",
+ LOG(0, tunnel[t].ip, ntohs((*(u16 *) (buf + 6))), t, "Error sending data out tunnel: %s (udpfd=%d, buf=%p, len=%d, dest=%s)\n",
strerror(errno), udpfd, buf, l, inet_ntoa(addr.sin_addr));
STAT(tunnel_tx_errors);
return;
}
strerror(errno), udpfd, buf, l, inet_ntoa(addr.sin_addr));
STAT(tunnel_tx_errors);
return;
}
- log_hex(5, "Send Tunnel Data", buf, l);
+ LOG_HEX(5, "Send Tunnel Data", buf, l);
- log(1, 0, 0, 0, "Short IP, %d bytes\n", len);
+ LOG(1, 0, 0, 0, "Short IP, %d bytes\n", len);
- log(1, 0, 0, 0, "Oversize IP packet %d bytes\n", len);
+ LOG(1, 0, 0, 0, "Oversize IP packet %d bytes\n", len);
- log(1, 0, 0, 0, "IP: Don't understand anything except IPv4\n");
+ LOG(1, 0, 0, 0, "IP: Don't understand anything except IPv4\n");
- log(4, 0, 0, 0, "IP: Sending ICMP host unreachable to %s\n", inet_toa(*(u32 *)(buf + 12)));
+ LOG(4, 0, 0, 0, "IP: Sending ICMP host unreachable to %s\n", inet_toa(*(u32 *)(buf + 12)));
host_unreachable(*(u32 *)(buf + 12), *(u16 *)(buf + 4), ip, buf, (len < 64) ? 64 : len);
}
return;
host_unreachable(*(u32 *)(buf + 12), *(u16 *)(buf + 4), ip, buf, (len < 64) ? 64 : len);
}
return;
- // Snooping this session, send it to intercept box
- if (sp->snoop_ip && sp->snoop_port)
- snoop_send_packet(buf, len, sp->snoop_ip, sp->snoop_port);
-
- log(5, session[s].ip, s, t, "Ethernet -> Tunnel (%d bytes)\n", len);
+ LOG(5, session[s].ip, s, t, "Ethernet -> Tunnel (%d bytes)\n", len);
// Add on L2TP header
{
u8 *p = makeppp(b, sizeof(b), buf, len, t, s, PPPIP);
if (!p)
{
// Add on L2TP header
{
u8 *p = makeppp(b, sizeof(b), buf, len, t, s, PPPIP);
if (!p)
{
- log(3, session[s].ip, s, t, "failed to send packet in processipout.\n");
+ LOG(3, session[s].ip, s, t, "failed to send packet in processipout.\n");
+ // Snooping this session, send it to intercept box
+ if (sp->snoop_ip && sp->snoop_port)
+ snoop_send_packet(buf, len, sp->snoop_ip, sp->snoop_port);
+
- log(1,0,0,0, "Odd size IP packet: %d bytes\n", len);
+ LOG(1,0,0,0, "Odd size IP packet: %d bytes\n", len);
- log(5, session[s].ip, s, t, "Ethernet -> Tunnel (%d bytes)\n", len);
-
- // Snooping this session.
- if (sp->snoop_ip && sp->snoop_port)
- snoop_send_packet(buf, len, sp->snoop_ip, sp->snoop_port);
+ LOG(5, session[s].ip, s, t, "Ethernet -> Tunnel (%d bytes)\n", len);
// Add on L2TP header
{
u8 *p = makeppp(b, sizeof(b), buf, len, t, s, PPPIP);
if (!p)
{
// Add on L2TP header
{
u8 *p = makeppp(b, sizeof(b), buf, len, t, s, PPPIP);
if (!p)
{
- log(3, session[s].ip, s, t, "failed to send packet in send_ipout.\n");
+ LOG(3, session[s].ip, s, t, "failed to send packet in send_ipout.\n");
+
+ // Snooping this session.
+ if (sp->snoop_ip && sp->snoop_port)
+ snoop_send_packet(buf, len, sp->snoop_ip, sp->snoop_port);
+
- log(3, session[s].ip, s, session[s].tunnel, "Called sessionshutdown on a session with no tunnel.\n");
+ LOG(3, session[s].ip, s, session[s].tunnel, "Called sessionshutdown on a session with no tunnel.\n");
- log(2, 0, s, session[s].tunnel, "Shutting down session %d: %s\n", s, reason);
+ LOG(2, 0, s, session[s].tunnel, "Shutting down session %d: %s\n", s, reason);
- log(1, 0, s, session[s].tunnel, "No free RADIUS sessions for Stop message\n");
+ LOG(1, 0, s, session[s].tunnel, "No free RADIUS sessions for Stop message\n");
q = makeppp(buf,sizeof(buf), 0, 0, t, s, PPPIPCP);
if (!q)
{
q = makeppp(buf,sizeof(buf), 0, 0, t, s, PPPIPCP);
if (!q)
{
- log(3, session[s].ip, s, t, "failed to send packet in sendipcp.\n");
+ LOG(3, session[s].ip, s, t, "failed to send packet in sendipcp.\n");
- *(u32 *) (q + 6) = config->bind_address ? config->bind_address : my_address; // send my IP
+ *(u32 *) (q + 6) = config->peer_address ? config->peer_address :
+ config->bind_address ? config->bind_address :
+ my_address; // send my IP
+
tunnelsend(buf, 10 + (q - buf), t); // send it
session[s].flags &= ~SF_IPCP_ACKED; // Clear flag.
}
tunnelsend(buf, 10 + (q - buf), t); // send it
session[s].flags &= ~SF_IPCP_ACKED; // Clear flag.
}
- log(2, 0, s, session[s].tunnel, "Kill session %d (%s): %s\n", s, session[s].user, reason);
+ LOG(2, 0, s, session[s].tunnel, "Kill session %d (%s): %s\n", s, session[s].user, reason);
memset(&session[s], 0, sizeof(session[s]));
session[s].tunnel = T_FREE; // Mark it as free.
memset(&session[s], 0, sizeof(session[s]));
session[s].tunnel = T_FREE; // Mark it as free.
- log(1, 0, 0, t, "Kill tunnel %d: %s\n", t, reason);
+ LOG(1, 0, 0, t, "Kill tunnel %d: %s\n", t, reason);
- log(1, 0, 0, t, "Shutting down tunnel %d (%s)\n", t, reason);
+ LOG(1, 0, 0, t, "Shutting down tunnel %d (%s)\n", t, reason);
- log_hex(5, "UDP Data", buf, len);
+ LOG_HEX(5, "UDP Data", buf, len);
- log(1, ntohl(addr->sin_addr.s_addr), 0, 0, "Short UDP, %d bytes\n", len);
+ LOG(1, ntohl(addr->sin_addr.s_addr), 0, 0, "Short UDP, %d bytes\n", len);
- log(1, ntohl(addr->sin_addr.s_addr), 0, 0, "Bad L2TP ver %d\n", (buf[1] & 0x0F) != 2);
+ LOG(1, ntohl(addr->sin_addr.s_addr), 0, 0, "Bad L2TP ver %d\n", (buf[1] & 0x0F) != 2);
- log(1, ntohl(addr->sin_addr.s_addr), s, t, "Received UDP packet with invalid session ID\n");
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, "Received UDP packet with invalid session ID\n");
- log(1, ntohl(addr->sin_addr.s_addr), s, t, "Received UDP packet with invalid tunnel ID\n");
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, "Received UDP packet with invalid tunnel ID\n");
- log(1, ntohl(addr->sin_addr.s_addr), s, t, "Bad length %d>%d\n", (p - buf), l);
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, "Bad length %d>%d\n", (p - buf), l);
- log(1, ntohl(addr->sin_addr.s_addr), s, t, "Bad control header %02X\n", *buf);
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, "Bad control header %02X\n", *buf);
- log(3, ntohl(addr->sin_addr.s_addr), s, t, "Control message (%d bytes): (unacked %d) l-ns %d l-nr %d r-ns %d r-nr %d\n",
+ LOG(3, ntohl(addr->sin_addr.s_addr), s, t, "Control message (%d bytes): (unacked %d) l-ns %d l-nr %d r-ns %d r-nr %d\n",
l, tunnel[t].controlc, tunnel[t].ns, tunnel[t].nr, ns, nr);
// if no tunnel specified, assign one
if (!t)
l, tunnel[t].controlc, tunnel[t].ns, tunnel[t].nr, ns, nr);
// if no tunnel specified, assign one
if (!t)
- log(1, ntohl(addr->sin_addr.s_addr), 0, 0, "No more tunnels\n");
+ LOG(1, ntohl(addr->sin_addr.s_addr), 0, 0, "No more tunnels\n");
tunnel[t].ip = ntohl(*(ipt *) & addr->sin_addr);
tunnel[t].port = ntohs(addr->sin_port);
tunnel[t].window = 4; // default window
tunnel[t].ip = ntohl(*(ipt *) & addr->sin_addr);
tunnel[t].port = ntohs(addr->sin_port);
tunnel[t].window = 4; // default window
- log(1, ntohl(addr->sin_addr.s_addr), 0, t, " New tunnel from %u.%u.%u.%u/%u ID %d\n", tunnel[t].ip >> 24, tunnel[t].ip >> 16 & 255, tunnel[t].ip >> 8 & 255, tunnel[t].ip & 255, tunnel[t].port, t);
+ LOG(1, ntohl(addr->sin_addr.s_addr), 0, t, " New tunnel from %u.%u.%u.%u/%u ID %d\n", tunnel[t].ip >> 24, tunnel[t].ip >> 16 & 255, tunnel[t].ip >> 8 & 255, tunnel[t].ip & 255, tunnel[t].port, t);
- log(1, ntohl(addr->sin_addr.s_addr), 0, t, " Out of sequence tunnel %d, (%d is not the expected %d)\n", t, ns, tunnel[t].nr);
+ LOG(1, ntohl(addr->sin_addr.s_addr), 0, t, " Out of sequence tunnel %d, (%d is not the expected %d)\n", t, ns, tunnel[t].nr);
- log(1, ntohl(addr->sin_addr.s_addr), s, t, "Invalid length in AVP\n");
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, "Invalid length in AVP\n");
- log(1, ntohl(addr->sin_addr.s_addr), s, t, "Hidden AVP requested, but no L2TP secret.\n");
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, "Hidden AVP requested, but no L2TP secret.\n");
- log(1, ntohl(addr->sin_addr.s_addr), s, t, "Hidden AVP requested, but no random vector.\n");
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, "Hidden AVP requested, but no random vector.\n");
- log(4, ntohl(addr->sin_addr.s_addr), s, t, "Hidden AVP\n");
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, "Hidden AVP\n");
// Unhide the AVP
n = unhide_avp(b, t, s, n);
if (n == 0)
// Unhide the AVP
n = unhide_avp(b, t, s, n);
if (n == 0)
- log(1, ntohl(addr->sin_addr.s_addr), s, t, "Unrecognised AVP flags %02X\n", *b);
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, "Unrecognised AVP flags %02X\n", *b);
- log(2, ntohl(addr->sin_addr.s_addr), s, t, "Unknown AVP vendor %d\n", ntohs(*(u16 *) (b)));
+ LOG(2, ntohl(addr->sin_addr.s_addr), s, t, "Unknown AVP vendor %d\n", ntohs(*(u16 *) (b)));
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " AVP %d (%s) len %d\n", mtype, avpnames[mtype], n);
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " AVP %d (%s) len %d\n", mtype, avpnames[mtype], n);
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Message type = %d (%s)\n", *b,
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Message type = %d (%s)\n", *b,
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Result Code %d: %s\n",
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Result Code %d: %s\n",
const char* errdesc = "(unknown)";
if (errcode <= MAX_ERROR_CODE)
errdesc = error_codes[errcode];
const char* errdesc = "(unknown)";
if (errcode <= MAX_ERROR_CODE)
errdesc = error_codes[errcode];
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Error Code %d: %s\n",
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Error Code %d: %s\n",
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Error String: %.*s\n",
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Error String: %.*s\n",
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Protocol version = %d\n", version);
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Protocol version = %d\n", version);
- log(1, ntohl(addr->sin_addr.s_addr), s, t, " Bad protocol version %04X\n",
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, " Bad protocol version %04X\n",
-// log(4, ntohl(addr->sin_addr.s_addr), s, t, "Framing capabilities\n");
+// LOG(4, ntohl(addr->sin_addr.s_addr), s, t, "Framing capabilities\n");
-// log(4, ntohl(addr->sin_addr.s_addr), s, t, "Bearer capabilities\n");
+// LOG(4, ntohl(addr->sin_addr.s_addr), s, t, "Bearer capabilities\n");
-// log(4, ntohl(addr->sin_addr.s_addr), s, t, "Tie breaker\n");
+// LOG(4, ntohl(addr->sin_addr.s_addr), s, t, "Tie breaker\n");
-// log(4, ntohl(addr->sin_addr.s_addr), s, t, "Firmware revision\n");
+// LOG(4, ntohl(addr->sin_addr.s_addr), s, t, "Firmware revision\n");
break;
case 7: // host name
memset(tunnel[t].hostname, 0, 128);
memcpy(tunnel[t].hostname, b, (n >= 127) ? 127 : n);
break;
case 7: // host name
memset(tunnel[t].hostname, 0, 128);
memcpy(tunnel[t].hostname, b, (n >= 127) ? 127 : n);
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Tunnel hostname = \"%s\"\n", tunnel[t].hostname);
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Tunnel hostname = \"%s\"\n", tunnel[t].hostname);
// TBA - to send to RADIUS
break;
case 8: // vendor name
memset(tunnel[t].vendor, 0, sizeof(tunnel[t].vendor));
memcpy(tunnel[t].vendor, b, (n >= sizeof(tunnel[t].vendor) - 1) ? sizeof(tunnel[t].vendor) - 1 : n);
// TBA - to send to RADIUS
break;
case 8: // vendor name
memset(tunnel[t].vendor, 0, sizeof(tunnel[t].vendor));
memcpy(tunnel[t].vendor, b, (n >= sizeof(tunnel[t].vendor) - 1) ? sizeof(tunnel[t].vendor) - 1 : n);
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Vendor name = \"%s\"\n", tunnel[t].vendor);
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Vendor name = \"%s\"\n", tunnel[t].vendor);
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Remote tunnel id = %d\n", tunnel[t].far);
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Remote tunnel id = %d\n", tunnel[t].far);
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " rx window = %d\n", tunnel[t].window);
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " rx window = %d\n", tunnel[t].window);
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " LAC requested CHAP authentication for tunnel\n");
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " LAC requested CHAP authentication for tunnel\n");
build_chap_response(b, 2, n, &chapresponse);
}
break;
case 13: // Response
// Why did they send a response? We never challenge.
build_chap_response(b, 2, n, &chapresponse);
}
break;
case 13: // Response
// Why did they send a response? We never challenge.
- log(2, ntohl(addr->sin_addr.s_addr), s, t, " received unexpected challenge response\n");
+ LOG(2, ntohl(addr->sin_addr.s_addr), s, t, " received unexpected challenge response\n");
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " assigned session = %d\n", asession);
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " assigned session = %d\n", asession);
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " call serial number = %d\n", ntohl(*(u32 *)b));
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " call serial number = %d\n", ntohl(*(u32 *)b));
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " bearer type = %d\n", ntohl(*(u32 *)b));
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " bearer type = %d\n", ntohl(*(u32 *)b));
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " framing type = %d\n", ntohl(*(u32 *)b));
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " framing type = %d\n", ntohl(*(u32 *)b));
// TBA
break;
case 21: // called number
memset(called, 0, MAXTEL);
memcpy(called, b, (n >= MAXTEL) ? (MAXTEL-1) : n);
// TBA
break;
case 21: // called number
memset(called, 0, MAXTEL);
memcpy(called, b, (n >= MAXTEL) ? (MAXTEL-1) : n);
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Called <%s>\n", called);
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Called <%s>\n", called);
break;
case 22: // calling number
memset(calling, 0, MAXTEL);
memcpy(calling, b, (n >= MAXTEL) ? (MAXTEL-1) : n);
break;
case 22: // calling number
memset(calling, 0, MAXTEL);
memcpy(calling, b, (n >= MAXTEL) ? (MAXTEL-1) : n);
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Calling <%s>\n", calling);
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Calling <%s>\n", calling);
memcpy(tmp, b, (n >= 30) ? 30 : n);
session[s].tx_connect_speed = atol(tmp);
}
memcpy(tmp, b, (n >= 30) ? 30 : n);
session[s].tx_connect_speed = atol(tmp);
}
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " TX connect speed <%u>\n",
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " TX connect speed <%u>\n",
memcpy(tmp, b, (n >= 30) ? 30 : n);
session[s].rx_connect_speed = atol(tmp);
}
memcpy(tmp, b, (n >= 30) ? 30 : n);
session[s].rx_connect_speed = atol(tmp);
}
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " RX connect speed <%u>\n",
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " RX connect speed <%u>\n",
session[s].rx_connect_speed);
break;
case 25: // Physical Channel ID
{
u32 tmp = ntohl(*(u32 *)b);
session[s].rx_connect_speed);
break;
case 25: // Physical Channel ID
{
u32 tmp = ntohl(*(u32 *)b);
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Physical Channel ID <%X>\n", tmp);
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Physical Channel ID <%X>\n", tmp);
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Proxy Auth Type %d (%s)\n",
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Proxy Auth Type %d (%s)\n",
authtype, authtypes[authtype]);
requestchap = (authtype == 2);
break;
authtype, authtypes[authtype]);
requestchap = (authtype == 2);
break;
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Proxy Auth Name (%s)\n",
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Proxy Auth Name (%s)\n",
authname);
break;
}
case 31: // Proxy Authentication Challenge
{
memcpy(radius[session[s].radius].auth, b, 16);
authname);
break;
}
case 31: // Proxy Authentication Challenge
{
memcpy(radius[session[s].radius].auth, b, 16);
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Proxy Auth Challenge\n");
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Proxy Auth Challenge\n");
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Proxy Auth ID (%d)\n",
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Proxy Auth ID (%d)\n",
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Proxy Auth Response\n");
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Proxy Auth Response\n");
- log(4, ntohl(addr->sin_addr.s_addr), s, t, " Random Vector received. Enabled AVP Hiding.\n");
+ LOG(4, ntohl(addr->sin_addr.s_addr), s, t, " Random Vector received. Enabled AVP Hiding.\n");
memset(session[s].random_vector, 0, sizeof(session[s].random_vector));
memcpy(session[s].random_vector, b, n);
session[s].random_vector_length = n;
break;
default:
memset(session[s].random_vector, 0, sizeof(session[s].random_vector));
memcpy(session[s].random_vector, b, n);
session[s].random_vector_length = n;
break;
default:
- log(2, ntohl(addr->sin_addr.s_addr), s, t, " Unknown AVP type %d\n", mtype);
+ LOG(2, ntohl(addr->sin_addr.s_addr), s, t, " Unknown AVP type %d\n", mtype);
- log(1, ntohl(addr->sin_addr.s_addr), s, t, "No free RADIUS sessions for ICRQ\n");
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, "No free RADIUS sessions for ICRQ\n");
- log(3, ntohl(addr->sin_addr.s_addr), s, t, "New session (%d/%d)\n", tunnel[t].far, session[s].far);
+ LOG(3, ntohl(addr->sin_addr.s_addr), s, t, "New session (%d/%d)\n", tunnel[t].far, session[s].far);
control16(c, 14, s, 1); // assigned session
controladd(c, t, s); // send the reply
{
control16(c, 14, s, 1); // assigned session
controladd(c, t, s); // send the reply
{
if (amagic == 0) amagic = time_now;
session[s].magic = amagic; // set magic number
session[s].l2tp_flags = aflags; // set flags received
if (amagic == 0) amagic = time_now;
session[s].magic = amagic; // set magic number
session[s].l2tp_flags = aflags; // set flags received
- log(3, ntohl(addr->sin_addr.s_addr), s, t, "Magic %X Flags %X\n", amagic, aflags);
+ LOG(3, ntohl(addr->sin_addr.s_addr), s, t, "Magic %X Flags %X\n", amagic, aflags);
- log(1, ntohl(addr->sin_addr.s_addr), s, t, "Missing message type\n");
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, "Missing message type\n");
break;
default:
STAT(tunnel_rx_errors);
if (mandatorymessage & 0x80)
tunnelshutdown(t, "Unknown message");
else
break;
default:
STAT(tunnel_rx_errors);
if (mandatorymessage & 0x80)
tunnelshutdown(t, "Unknown message");
else
- log(1, ntohl(addr->sin_addr.s_addr), s, t, "Unknown message type %d\n", message);
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, "Unknown message type %d\n", message);
- log(4, 0, s, t, " Got a ZLB ack\n");
+ LOG(4, 0, s, t, " Got a ZLB ack\n");
- log_hex(5, "Receive Tunnel Data", p, l);
+ LOG_HEX(5, "Receive Tunnel Data", p, l);
if (l > 2 && p[0] == 0xFF && p[1] == 0x03)
{ // HDLC address header, discard
p += 2;
if (l > 2 && p[0] == 0xFF && p[1] == 0x03)
{ // HDLC address header, discard
p += 2;
- log(1, ntohl(addr->sin_addr.s_addr), s, t, "Short ppp length %d\n", l);
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, "Short ppp length %d\n", l);
- log(1, ntohl(addr->sin_addr.s_addr), s, t, "UDP packet contains session %d "
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, "UDP packet contains session %d "
"but no session[%d].tunnel exists (LAC said"
" tunnel = %d). Dropping packet.\n", s, s, t);
STAT(tunnel_rx_errors);
"but no session[%d].tunnel exists (LAC said"
" tunnel = %d). Dropping packet.\n", s, s, t);
STAT(tunnel_rx_errors);
- log(3, ntohl(addr->sin_addr.s_addr), s, t, "Session %d is closing. Don't process PPP packets\n", s);
+ LOG(3, ntohl(addr->sin_addr.s_addr), s, t, "Session %d is closing. Don't process PPP packets\n", s);
// I'm pretty sure this isn't right -- mo.
// return; // closing session, PPP not processed
}
// I'm pretty sure this isn't right -- mo.
// return; // closing session, PPP not processed
}
- log(1, ntohl(addr->sin_addr.s_addr), s, t, "Unknown PPP protocol %04X\n", prot);
+ LOG(1, ntohl(addr->sin_addr.s_addr), s, t, "Unknown PPP protocol %04X\n", prot);
// read and process packet on tun
void processtun(u8 * buf, int len)
{
// read and process packet on tun
void processtun(u8 * buf, int len)
{
- log_hex(5, "Receive TUN Data", buf, len);
+ LOG_HEX(5, "Receive TUN Data", buf, len);
- log(1, 0, 0, 0, "Short tun packet %d bytes\n", len);
+ LOG(1, 0, 0, 0, "Short tun packet %d bytes\n", len);
- log(3, 0, 0, 0, "Begin regular cleanup\n");
+ LOG(3, 0, 0, 0, "Begin regular cleanup\n");
{
controlt *c = controlnew(6); // sending HELLO
controladd(c, t, 0); // send the message
{
controlt *c = controlnew(6); // sending HELLO
controladd(c, t, 0); // send the message
- log(3, tunnel[t].ip, 0, t, "Sending HELLO message\n");
+ LOG(3, tunnel[t].ip, 0, t, "Sending HELLO message\n");
- log(2, tunnel[t].ip, 0, t, "Dropping tunnel by CLI\n");
+ LOG(2, tunnel[t].ip, 0, t, "Dropping tunnel by CLI\n");
if (!session[s].die && session[s].ip && !(session[s].flags & SF_IPCP_ACKED))
{
// IPCP has not completed yet. Resend
if (!session[s].die && session[s].ip && !(session[s].flags & SF_IPCP_ACKED))
{
// IPCP has not completed yet. Resend
- log(3, session[s].ip, s, session[s].tunnel, "No ACK for initial IPCP ConfigReq... resending\n");
+ LOG(3, session[s].ip, s, session[s].tunnel, "No ACK for initial IPCP ConfigReq... resending\n");
u8 *q = makeppp(b, sizeof(b), 0, 0, session[s].tunnel, s, PPPLCP);
if (!q)
{
u8 *q = makeppp(b, sizeof(b), 0, 0, session[s].tunnel, s, PPPLCP);
if (!q)
{
- log(3, session[s].ip, s, t, "failed to send ECHO packet.\n");
+ LOG(3, session[s].ip, s, t, "failed to send ECHO packet.\n");
- log(4, session[s].ip, s, session[s].tunnel, "No data in %d seconds, sending LCP ECHO\n",
+ LOG(4, session[s].ip, s, session[s].tunnel, "No data in %d seconds, sending LCP ECHO\n",
(int)(time_now - session[s].last_packet));
tunnelsend(b, 24, session[s].tunnel); // send it
if (++count >= MAX_ACTIONS) break;
(int)(time_now - session[s].last_packet));
tunnelsend(b, 24, session[s].tunnel); // send it
if (++count >= MAX_ACTIONS) break;
- log(2, 0, s, session[s].tunnel, "Dropping session by CLI\n");
+ LOG(2, 0, s, session[s].tunnel, "Dropping session by CLI\n");
sessionshutdown(s, "Requested by administrator");
a = 0; // dead, no need to check for other actions
}
if (a & CLI_SESS_NOSNOOP)
{
sessionshutdown(s, "Requested by administrator");
a = 0; // dead, no need to check for other actions
}
if (a & CLI_SESS_NOSNOOP)
{
- log(2, 0, s, session[s].tunnel, "Unsnooping session by CLI\n");
+ LOG(2, 0, s, session[s].tunnel, "Unsnooping session by CLI\n");
- log(2, 0, s, session[s].tunnel, "Snooping session by CLI (to %s:%d)\n",
+ LOG(2, 0, s, session[s].tunnel, "Snooping session by CLI (to %s:%d)\n",
inet_toa(cli_session_actions[s].snoop_ip), cli_session_actions[s].snoop_port);
session[s].snoop_ip = cli_session_actions[s].snoop_ip;
inet_toa(cli_session_actions[s].snoop_ip), cli_session_actions[s].snoop_port);
session[s].snoop_ip = cli_session_actions[s].snoop_ip;
- log(2, 0, s, session[s].tunnel, "Un-throttling session by CLI\n");
+ LOG(2, 0, s, session[s].tunnel, "Un-throttling session by CLI\n");
throttle_session(s, 0, 0);
send++;
}
else if (a & CLI_SESS_THROTTLE)
{
throttle_session(s, 0, 0);
send++;
}
else if (a & CLI_SESS_THROTTLE)
{
- log(2, 0, s, session[s].tunnel, "Throttling session by CLI (to %dkb/s up and %dkb/s down)\n",
+ LOG(2, 0, s, session[s].tunnel, "Throttling session by CLI (to %dkb/s up and %dkb/s down)\n",
cli_session_actions[s].throttle_in,
cli_session_actions[s].throttle_out);
cli_session_actions[s].throttle_in,
cli_session_actions[s].throttle_out);
- log(3, 0, 0, 0, "End regular cleanup (%d actions), next in %d seconds\n", count, config->cleanup_interval);
+ LOG(3, 0, 0, 0, "End regular cleanup (%d actions), next in %d seconds\n", count, config->cleanup_interval);
- log(2,0,0,0, "Tunnel %d still has un-acked control messages.\n", i);
+ LOG(2,0,0,0, "Tunnel %d still has un-acked control messages.\n", i);
// We stop waiting for radius after BUSY_WAIT_TIME 1/10th seconds
if (abs(TIME - start_busy_wait) > BUSY_WAIT_TIME)
{
// We stop waiting for radius after BUSY_WAIT_TIME 1/10th seconds
if (abs(TIME - start_busy_wait) > BUSY_WAIT_TIME)
{
- log(1, 0, 0, 0, "Giving up waiting for RADIUS to be empty. Shutting down anyway.\n");
+ LOG(1, 0, 0, 0, "Giving up waiting for RADIUS to be empty. Shutting down anyway.\n");
- log(2,0,0,0, "Radius session %d is still busy (sid %d)\n", i, radius[i].session);
+ LOG(2,0,0,0, "Radius session %d is still busy (sid %d)\n", i, radius[i].session);
clockt next_cluster_ping = 0; // send initial ping immediately
time_t next_clean = time_now + config->cleanup_interval;
clockt next_cluster_ping = 0; // send initial ping immediately
time_t next_clean = time_now + config->cleanup_interval;
- log(4, 0, 0, 0, "Beginning of main loop. udpfd=%d, tunfd=%d, cluster_sockfd=%d, controlfd=%d\n",
+ LOG(4, 0, 0, 0, "Beginning of main loop. udpfd=%d, tunfd=%d, cluster_sockfd=%d, controlfd=%d\n",
udpfd, tunfd, cluster_sockfd, controlfd);
FD_ZERO(&readset);
udpfd, tunfd, cluster_sockfd, controlfd);
FD_ZERO(&readset);
- log(0, 0, 0, 0, "Error returned from select(): %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error returned from select(): %s\n", strerror(errno));
- log(0, 0, 0, 0, "accept error: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "accept error: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Error doing malloc for _statistics: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error doing malloc for _statistics: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Error doing malloc for configuration: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error doing malloc for configuration: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Error doing malloc for tunnels: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error doing malloc for tunnels: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Error doing malloc for sessions: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error doing malloc for sessions: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Error doing malloc for sessions_count: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error doing malloc for sessions_count: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Error doing malloc for radius: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error doing malloc for radius: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Error doing malloc for ip_address_pool: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error doing malloc for ip_address_pool: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Error doing malloc for ringbuffer: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error doing malloc for ringbuffer: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Error doing malloc for cli session actions: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error doing malloc for cli session actions: %s\n", strerror(errno));
exit(1);
}
memset(cli_session_actions, 0, sizeof(struct cli_session_actions) * MAXSESSION);
if (!(cli_tunnel_actions = shared_malloc(sizeof(struct cli_tunnel_actions) * MAXSESSION)))
{
exit(1);
}
memset(cli_session_actions, 0, sizeof(struct cli_session_actions) * MAXSESSION);
if (!(cli_tunnel_actions = shared_malloc(sizeof(struct cli_tunnel_actions) * MAXSESSION)))
{
- log(0, 0, 0, 0, "Error doing malloc for cli tunnel actions: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error doing malloc for cli tunnel actions: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Error doing malloc for bgp: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error doing malloc for bgp: %s\n", strerror(errno));
- log(0, 0, s, session[s].tunnel, "assign_ip_address(): out of addresses\n");
+ LOG(0, 0, s, session[s].tunnel, "assign_ip_address(): out of addresses\n");
- log(4, ip_address_pool[best].address, s, session[s].tunnel,
+ LOG(4, ip_address_pool[best].address, s, session[s].tunnel,
- log(0, 0, i, 0, "Session %d has an IP address (%s) that was marked static, but is in the pool (%d)!\n",
+ LOG(0, 0, i, 0, "Session %d has an IP address (%s) that was marked static, but is in the pool (%d)!\n",
i, inet_toa(session[i].ip), ipid);
// Fall through and process it as part of the pool.
i, inet_toa(session[i].ip), ipid);
// Fall through and process it as part of the pool.
- log(0, 0, i, 0, "Session %d has a pool IP that's not found in the pool! (%d)\n", i, ipid);
+ LOG(0, 0, i, 0, "Session %d has a pool IP that's not found in the pool! (%d)\n", i, ipid);
- log(0,0,0,0, "Overflowed IP pool adding %s\n", inet_toa(htonl(addr)) );
+ LOG(0,0,0,0, "Overflowed IP pool adding %s\n", inet_toa(htonl(addr)) );
- log(0, 0, 0, 0, "Can't load pool file " IPPOOLFILE ": %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Can't load pool file " IPPOOLFILE ": %s\n", strerror(errno));
- log(0, 0, 0, 0, "Invalid address pool IP %s\n", buf);
+ LOG(0, 0, 0, 0, "Invalid address pool IP %s\n", buf);
- log(2, 0, 0, 0, "Adding IP address range %s\n", buf);
+ LOG(2, 0, 0, 0, "Adding IP address range %s\n", buf);
- log(0, 0, 0, 0, "Invalid pool range %s\n", buf);
+ LOG(0, 0, 0, 0, "Invalid pool range %s\n", buf);
continue;
}
start = ntohl(inet_addr(pool));
mask = (u32)(pow(2, numbits) - 1) << (32 - numbits);
// Add a static route for this pool
continue;
}
start = ntohl(inet_addr(pool));
mask = (u32)(pow(2, numbits) - 1) << (32 - numbits);
// Add a static route for this pool
- log(5, 0, 0, 0, "Adding route for address pool %s/%u\n", inet_toa(htonl(start)), 32 + mask);
+ LOG(5, 0, 0, 0, "Adding route for address pool %s/%u\n", inet_toa(htonl(start)), 32 + mask);
routeset(0, start, mask, 0, 1);
add_to_ip_pool(start, mask);
routeset(0, start, mask, 0, 1);
add_to_ip_pool(start, mask);
- log(1, 0, 0, 0, "IP address pool is %d addresses\n", ip_pool_size - 1);
+ LOG(1, 0, 0, 0, "IP address pool is %d addresses\n", ip_pool_size - 1);
}
void snoop_send_packet(char *packet, u16 size, ipt destination, u16 port)
}
void snoop_send_packet(char *packet, u16 size, ipt destination, u16 port)
- log(5, 0, 0, 0, "Snooping packet at %p (%d bytes) to %s:%d\n",
+ LOG(5, 0, 0, 0, "Snooping packet at %p (%d bytes) to %s:%d\n",
packet, size, inet_toa(snoop_addr.sin_addr.s_addr), htons(snoop_addr.sin_port));
if (sendto(snoopfd, packet, size, MSG_DONTWAIT | MSG_NOSIGNAL, (void *) &snoop_addr, sizeof(snoop_addr)) < 0)
packet, size, inet_toa(snoop_addr.sin_addr.s_addr), htons(snoop_addr.sin_port));
if (sendto(snoopfd, packet, size, MSG_DONTWAIT | MSG_NOSIGNAL, (void *) &snoop_addr, sizeof(snoop_addr)) < 0)
- log(0, 0, 0, 0, "Error sending intercept packet: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error sending intercept packet: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Can't write accounting info to %s: %s\n", filename, strerror(errno));
+ LOG(0, 0, 0, 0, "Can't write accounting info to %s: %s\n", filename, strerror(errno));
- log(3, 0, 0, 0, "Dumping accounting information to %s\n", filename);
+ LOG(3, 0, 0, 0, "Dumping accounting information to %s\n", filename);
- log(4, 0, 0, 0, "Dumping accounting information for %s\n", session[i].user);
+ LOG(4, 0, 0, 0, "Dumping accounting information for %s\n", session[i].user);
fprintf(f, "%s %s %d %u %u\n",
session[i].user, // username
inet_toa(htonl(session[i].ip)), // ip
fprintf(f, "%s %s %d %u %u\n",
session[i].user, // username
inet_toa(htonl(session[i].ip)), // ip
+ setsid();
+ freopen("/dev/null", "r", stdin);
+ freopen("/dev/null", "w", stdout);
+ freopen("/dev/null", "w", stderr);
- log(0, 0, 0, 0, "L2TPNS version " VERSION "\n");
- log(0, 0, 0, 0, "Copyright (c) 2003, 2004 Optus Internet Engineering\n");
- log(0, 0, 0, 0, "Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced\n");
+ LOG(0, 0, 0, 0, "L2TPNS version " VERSION "\n");
+ LOG(0, 0, 0, 0, "Copyright (c) 2003, 2004 Optus Internet Engineering\n");
+ LOG(0, 0, 0, 0, "Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced\n");
{
struct rlimit rlim;
rlim.rlim_cur = RLIM_INFINITY;
rlim.rlim_max = RLIM_INFINITY;
// Remove the maximum core size
if (setrlimit(RLIMIT_CORE, &rlim) < 0)
{
struct rlimit rlim;
rlim.rlim_cur = RLIM_INFINITY;
rlim.rlim_max = RLIM_INFINITY;
// Remove the maximum core size
if (setrlimit(RLIMIT_CORE, &rlim) < 0)
- log(0, 0, 0, 0, "Can't set ulimit: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Can't set ulimit: %s\n", strerror(errno));
- log(0, 0, 0, 0, "Not using FIFO scheduler, there is only 1 processor in the system.\n");
+ LOG(0, 0, 0, 0, "Not using FIFO scheduler, there is only 1 processor in the system.\n");
config->scheduler_fifo = 0;
}
else
{
if ((ret = sched_setscheduler(0, SCHED_FIFO, ¶ms)) == 0)
{
config->scheduler_fifo = 0;
}
else
{
if ((ret = sched_setscheduler(0, SCHED_FIFO, ¶ms)) == 0)
{
- log(1, 0, 0, 0, "Using FIFO scheduler. Say goodbye to any other processes running\n");
+ LOG(1, 0, 0, 0, "Using FIFO scheduler. Say goodbye to any other processes running\n");
- log(0, 0, 0, 0, "Error setting scheduler to FIFO: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Error setting scheduler to FIFO: %s\n", strerror(errno));
- log(1, 0, 0, 0, "Set up on interface %s\n", config->tundevice);
+ LOG(1, 0, 0, 0, "Set up on interface %s\n", config->tundevice);
- log(1, 0, 0, 0, "Locking pages into memory\n");
+ LOG(1, 0, 0, 0, "Locking pages into memory\n");
- log(0, 0, 0, 0, "Can't lock pages: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Can't lock pages: %s\n", strerror(errno));
- log(1, 0, 0, 0, "Shutting down cleanly\n");
+ LOG(1, 0, 0, 0, "Shutting down cleanly\n");
- log(1, 0, 0, 0, "Shutting down without saving sessions\n");
+ LOG(1, 0, 0, 0, "Shutting down without saving sessions\n");
- log(0, 0, 0, 0, "State file is too old to read, ignoring\n");
+ LOG(0, 0, 0, 0, "State file is too old to read, ignoring\n");
- log(0, 0, 0, 0, "Can't read state file: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Can't read state file: %s\n", strerror(errno));
exit(1);
}
if (fread(magic, sizeof(magic), 1, f) != 1 || strncmp(magic, DUMP_MAGIC, sizeof(magic)))
{
exit(1);
}
if (fread(magic, sizeof(magic), 1, f) != 1 || strncmp(magic, DUMP_MAGIC, sizeof(magic)))
{
- log(0, 0, 0, 0, "Bad state file magic\n");
+ LOG(0, 0, 0, 0, "Bad state file magic\n");
- log(1, 0, 0, 0, "Reading state information\n");
+ LOG(1, 0, 0, 0, "Reading state information\n");
if (fread(buf, sizeof(buf), 1, f) != 1 || buf[0] > MAXIPPOOL || buf[1] != sizeof(ippoolt))
{
if (fread(buf, sizeof(buf), 1, f) != 1 || buf[0] > MAXIPPOOL || buf[1] != sizeof(ippoolt))
{
- log(0, 0, 0, 0, "Error/mismatch reading ip pool header from state file\n");
+ LOG(0, 0, 0, 0, "Error/mismatch reading ip pool header from state file\n");
- log(0, 0, 0, 0, "ip pool has shrunk! state = %d, current = %d\n", buf[0], ip_pool_size);
+ LOG(0, 0, 0, 0, "ip pool has shrunk! state = %d, current = %d\n", buf[0], ip_pool_size);
- log(2, 0, 0, 0, "Loading %u ip addresses\n", buf[0]);
+ LOG(2, 0, 0, 0, "Loading %u ip addresses\n", buf[0]);
for (i = 0; i < buf[0]; i++)
{
if (fread(&itmp, sizeof(itmp), 1, f) != 1)
{
for (i = 0; i < buf[0]; i++)
{
if (fread(&itmp, sizeof(itmp), 1, f) != 1)
{
- log(0, 0, 0, 0, "Error reading ip %d from state file: %s\n", i, strerror(errno));
+ LOG(0, 0, 0, 0, "Error reading ip %d from state file: %s\n", i, strerror(errno));
- log(0, 0, 0, 0, "Mismatched ip %d from state file: pool may only be extended\n", i);
+ LOG(0, 0, 0, 0, "Mismatched ip %d from state file: pool may only be extended\n", i);
if (fread(buf, sizeof(buf), 1, f) != 1 || buf[0] != MAXTUNNEL || buf[1] != sizeof(tunnelt))
{
if (fread(buf, sizeof(buf), 1, f) != 1 || buf[0] != MAXTUNNEL || buf[1] != sizeof(tunnelt))
{
- log(0, 0, 0, 0, "Error/mismatch reading tunnel header from state file\n");
+ LOG(0, 0, 0, 0, "Error/mismatch reading tunnel header from state file\n");
- log(2, 0, 0, 0, "Loading %u tunnels\n", MAXTUNNEL);
+ LOG(2, 0, 0, 0, "Loading %u tunnels\n", MAXTUNNEL);
if (fread(tunnel, sizeof(tunnelt), MAXTUNNEL, f) != MAXTUNNEL)
{
if (fread(tunnel, sizeof(tunnelt), MAXTUNNEL, f) != MAXTUNNEL)
{
- log(0, 0, 0, 0, "Error reading tunnel data from state file\n");
+ LOG(0, 0, 0, 0, "Error reading tunnel data from state file\n");
- log(3, 0, 0, 0, "Created tunnel for %s\n", tunnel[i].hostname);
+ LOG(3, 0, 0, 0, "Created tunnel for %s\n", tunnel[i].hostname);
}
if (fread(buf, sizeof(buf), 1, f) != 1 || buf[0] != MAXSESSION || buf[1] != sizeof(sessiont))
{
}
if (fread(buf, sizeof(buf), 1, f) != 1 || buf[0] != MAXSESSION || buf[1] != sizeof(sessiont))
{
- log(0, 0, 0, 0, "Error/mismatch reading session header from state file\n");
+ LOG(0, 0, 0, 0, "Error/mismatch reading session header from state file\n");
- log(2, 0, 0, 0, "Loading %u sessions\n", MAXSESSION);
+ LOG(2, 0, 0, 0, "Loading %u sessions\n", MAXSESSION);
if (fread(session, sizeof(sessiont), MAXSESSION, f) != MAXSESSION)
{
if (fread(session, sizeof(sessiont), MAXSESSION, f) != MAXSESSION)
{
- log(0, 0, 0, 0, "Error reading session data from state file\n");
+ LOG(0, 0, 0, 0, "Error reading session data from state file\n");
- log(2, 0, i, 0, "Loaded active session for user %s\n", session[i].user);
+ LOG(2, 0, i, 0, "Loaded active session for user %s\n", session[i].user);
- log(0, 0, 0, 0, "Loaded saved state information\n");
+ LOG(0, 0, 0, 0, "Loaded saved state information\n");
- log(1, 0, 0, 0, "Dumping state information\n");
+ LOG(1, 0, 0, 0, "Dumping state information\n");
if (fwrite(DUMP_MAGIC, sizeof(DUMP_MAGIC) - 1, 1, f) != 1)
break;
if (fwrite(DUMP_MAGIC, sizeof(DUMP_MAGIC) - 1, 1, f) != 1)
break;
- log(2, 0, 0, 0, "Dumping %u ip addresses\n", ip_pool_size);
+ LOG(2, 0, 0, 0, "Dumping %u ip addresses\n", ip_pool_size);
buf[0] = ip_pool_size;
buf[1] = sizeof(ippoolt);
if (fwrite(buf, sizeof(buf), 1, f) != 1)
buf[0] = ip_pool_size;
buf[1] = sizeof(ippoolt);
if (fwrite(buf, sizeof(buf), 1, f) != 1)
if (fwrite(ip_address_pool, sizeof(ippoolt), ip_pool_size, f) != ip_pool_size)
break;
if (fwrite(ip_address_pool, sizeof(ippoolt), ip_pool_size, f) != ip_pool_size)
break;
- log(2, 0, 0, 0, "Dumping %u tunnels\n", MAXTUNNEL);
+ LOG(2, 0, 0, 0, "Dumping %u tunnels\n", MAXTUNNEL);
buf[0] = MAXTUNNEL;
buf[1] = sizeof(tunnelt);
if (fwrite(buf, sizeof(buf), 1, f) != 1)
buf[0] = MAXTUNNEL;
buf[1] = sizeof(tunnelt);
if (fwrite(buf, sizeof(buf), 1, f) != 1)
if (fwrite(tunnel, sizeof(tunnelt), MAXTUNNEL, f) != MAXTUNNEL)
break;
if (fwrite(tunnel, sizeof(tunnelt), MAXTUNNEL, f) != MAXTUNNEL)
break;
- log(2, 0, 0, 0, "Dumping %u sessions\n", MAXSESSION);
+ LOG(2, 0, 0, 0, "Dumping %u sessions\n", MAXSESSION);
buf[0] = MAXSESSION;
buf[1] = sizeof(sessiont);
if (fwrite(buf, sizeof(buf), 1, f) != 1)
buf[0] = MAXSESSION;
buf[1] = sizeof(sessiont);
if (fwrite(buf, sizeof(buf), 1, f) != 1)
- log(0, 0, 0, 0, "Can't write state information: %s\n", strerror(errno));
+ LOG(0, 0, 0, 0, "Can't write state information: %s\n", strerror(errno));
- log(0, 0, 0, 0, "LNS requested CHAP authentication, but no l2tp secret is defined\n");
+ LOG(0, 0, 0, 0, "LNS requested CHAP authentication, but no l2tp secret is defined\n");
- log(4, 0, 0, 0, " Building challenge response for CHAP request\n");
+ LOG(4, 0, 0, 0, " Building challenge response for CHAP request\n");
- log(0, 0, 0, 0, "No RADIUS servers defined!\n");
+ LOG(0, 0, 0, 0, "No RADIUS servers defined!\n");
- log(0,0,0,0, "Heartbeat timeout %d too low, adjusting to %d\n", config->cluster_hb_timeout, t);
+ LOG(0,0,0,0, "Heartbeat timeout %d too low, adjusting to %d\n", config->cluster_hb_timeout, t);
- log(0, 0, 0, 0, "Can't write to PID file %s: %s\n", config->pid_file, strerror(errno));
+ LOG(0, 0, 0, 0, "Can't write to PID file %s: %s\n", config->pid_file, strerror(errno));
- log(3, 0, 0, 0, "Reading config file %s\n", config->config_file);
+ LOG(3, 0, 0, 0, "Reading config file %s\n", config->config_file);
- log(3, 0, 0, 0, "Done reading config file\n");
+ LOG(3, 0, 0, 0, "Done reading config file\n");
- log(3, session[s].ip, s, t, "Doing session setup for session\n");
+ LOG(3, session[s].ip, s, t, "Doing session setup for session\n");
- log(0, 0, s, t, " No IP allocated. The IP address pool is FULL!\n");
+ LOG(0, 0, s, t, " No IP allocated. The IP address pool is FULL!\n");
- log(3, 0, s, t, " No IP allocated. Assigned %s from pool\n",
+ LOG(3, 0, s, t, " No IP allocated. Assigned %s from pool\n",
- log(3, session[s].ip, s, t, "Sending initial IPCP to client\n");
+ LOG(3, session[s].ip, s, t, "Sending initial IPCP to client\n");
char *sessionip, *tunnelip;
sessionip = strdup(inet_toa(htonl(session[s].ip)));
tunnelip = strdup(inet_toa(htonl(tunnel[t].ip)));
char *sessionip, *tunnelip;
sessionip = strdup(inet_toa(htonl(session[s].ip)));
tunnelip = strdup(inet_toa(htonl(tunnel[t].ip)));
- log(2, session[s].ip, s, t, "Login by %s at %s from %s (%s)\n",
+ LOG(2, session[s].ip, s, t, "Login by %s at %s from %s (%s)\n",
session[s].user, sessionip, tunnelip, tunnel[t].hostname);
if (sessionip) free(sessionip);
if (tunnelip) free(tunnelip);
session[s].user, sessionip, tunnelip, tunnel[t].hostname);
if (sessionip) free(sessionip);
if (tunnelip) free(tunnelip);
- log(0,0,s,0, "Strange session update received!\n");
+ LOG(0,0,s,0, "Strange session update received!\n");
char path[256] = "";
snprintf(path, 256, PLUGINDIR "/%s.so", plugin_name);
char path[256] = "";
snprintf(path, 256, PLUGINDIR "/%s.so", plugin_name);
- log(2, 0, 0, 0, "%soading plugin from %s\n", load ? "L" : "Un-l", path);
+ LOG(2, 0, 0, 0, "%soading plugin from %s\n", load ? "L" : "Un-l", path);
- log(1, 0, 0, 0, " Plugin load failed: %s\n", dlerror());
+ LOG(1, 0, 0, 0, " Plugin load failed: %s\n", dlerror());
int *v = dlsym(p, "__plugin_api_version");
if (!v || *v != PLUGIN_API_VERSION)
{
int *v = dlsym(p, "__plugin_api_version");
if (!v || *v != PLUGIN_API_VERSION)
{
- log(1, 0, 0, 0, " Plugin load failed: API version mismatch: %s\n", dlerror());
+ LOG(1, 0, 0, 0, " Plugin load failed: API version mismatch: %s\n", dlerror());
- log(1, 0, 0, 0, " Plugin load failed: plugin_init() returned FALSE: %s\n", dlerror());
+ LOG(1, 0, 0, 0, " Plugin load failed: plugin_init() returned FALSE: %s\n", dlerror());
- log(3, 0, 0, 0, " Supports function \"%s\"\n", plugin_functions[i]);
+ LOG(3, 0, 0, 0, " Supports function \"%s\"\n", plugin_functions[i]);
- log(2, 0, 0, 0, " Loaded plugin %s\n", plugin_name);
+ LOG(2, 0, 0, 0, " Loaded plugin %s\n", plugin_name);
- log(2, 0, 0, 0, "Removed plugin %s\n", plugin_name);
+ LOG(2, 0, 0, 0, "Removed plugin %s\n", plugin_name);
- log(4, ntohl(addr->sin_addr.s_addr), 0, 0, "Received ");
+ LOG(4, ntohl(addr->sin_addr.s_addr), 0, 0, "Received ");
if (param.send_response)
{
send_packet(controlfd, ntohl(addr->sin_addr.s_addr), ntohs(addr->sin_port), param.response, param.response_length);
if (param.send_response)
{
send_packet(controlfd, ntohl(addr->sin_addr.s_addr), ntohs(addr->sin_port), param.response, param.response_length);
- log(4, ntohl(addr->sin_addr.s_addr), 0, 0, "Sent Control packet response\n");
+ LOG(4, ntohl(addr->sin_addr.s_addr), 0, 0, "Sent Control packet response\n");
- log(1, 0, 0, 0, "Cleaning tunnels array\n");
+ LOG(1, 0, 0, 0, "Cleaning tunnels array\n");
- log(4, 0, 0, i, "Assigning tunnel ID %d\n", i);
+ LOG(4, 0, 0, i, "Assigning tunnel ID %d\n", i);
- log(0, 0, 0, 0, "Can't find a free tunnel! There shouldn't be this many in use!\n");
+ LOG(0, 0, 0, 0, "Can't find a free tunnel! There shouldn't be this many in use!\n");
- log(1, 0, s, t, "Hidden length %d too long in AVP of length %d\n", (int) hidden_length, (int) length);
+ LOG(1, 0, s, t, "Hidden length %d too long in AVP of length %d\n", (int) hidden_length, (int) length);