// Copyright (c) 2002 FireBrick (Andrews & Arnold Ltd / Watchfront Ltd) - GPL licenced
// vim: sw=8 ts=8
-char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.16 2004/07/26 00:20:41 fred_nerk Exp $";
+char const *cvs_id_l2tpns = "$Id: l2tpns.c,v 1.20 2004/08/02 05:40:21 fred_nerk Exp $";
#include <arpa/inet.h>
#include <assert.h>
struct config_descriptt config_values[] = {
CONFIG("debug", debug, INT),
CONFIG("log_file", log_filename, STRING),
+ CONFIG("pid_file", pid_file, STRING),
CONFIG("l2tp_secret", l2tpsecret, STRING),
CONFIG("primary_dns", default_dns1, IP),
CONFIG("secondary_dns", default_dns2, IP),
*(u16 *) (q + 2) = htons(10);
q[4] = 3;
q[5] = 6;
- *(u32 *) (q + 6) = config->bind_address; // send my IP
+ *(u32 *) (q + 6) = 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.
}
memcpy(calling, b, (n >= MAXTEL) ? (MAXTEL-1) : n);
log(4, ntohl(addr->sin_addr.s_addr), s, t, " Calling <%s>\n", calling);
break;
+ case 23: // subtype
+ break;
case 24: // tx connect speed
if (n == 4)
{
if (!session[s].tunnel) // Session isn't in use
continue;
- if (!session[s].die && session[s].ip && !(session[s].flags & SF_IPCP_ACKED) )
+ 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");
/* remove plugins (so cleanup code gets run) */
plugins_done();
+ // Remove the PID file if we wrote it
+ if (config->wrote_pid && *config->pid_file == '/')
+ unlink(config->pid_file);
+
/* kill CLI children */
signal(SIGTERM, SIG_IGN);
kill(0, SIGTERM);
timeout = config->cluster_hb_timeout;
}
+ // Write PID file
+ if (*config->pid_file == '/' && !config->wrote_pid)
+ {
+ FILE *f;
+ if ((f = fopen(config->pid_file, "w")))
+ {
+ fprintf(f, "%d\n", getpid());
+ fclose(f);
+ config->wrote_pid = 1;
+ }
+ else
+ {
+ log(0, 0, 0, 0, "Can't write to PID file %s: %s\n", config->pid_file, strerror(errno));
+ }
+ }
+
config->reload_config = 0;
}
for (r = 0; r < MAXROUTE && session[s].route[r].ip; r++)
routeset(s, session[s].route[r].ip, session[s].route[r].mask, session[s].ip, 1);
- if (!session[s].sid) { // did this session just finish radius?
+ if (!session[s].sid)
+ {
+ // did this session just finish radius?
log(3, session[s].ip, s, t, "Sending initial IPCP to client\n");
sendipcp(t, s);
session[s].sid = ++last_sid;