Adding the possibility to set multiple hostname.
This commit is contained in:
parent
9944e87dfe
commit
9c1869ccb1
3 changed files with 47 additions and 6 deletions
42
l2tpns.c
42
l2tpns.c
|
|
@ -187,6 +187,7 @@ config_descriptt config_values[] = {
|
||||||
CONFIG("disable_no_spoof", disable_no_spoof, BOOL),
|
CONFIG("disable_no_spoof", disable_no_spoof, BOOL),
|
||||||
CONFIG("bind_multi_address", bind_multi_address, STRING),
|
CONFIG("bind_multi_address", bind_multi_address, STRING),
|
||||||
CONFIG("pppoe_only_equal_svc_name", pppoe_only_equal_svc_name, BOOL),
|
CONFIG("pppoe_only_equal_svc_name", pppoe_only_equal_svc_name, BOOL),
|
||||||
|
CONFIG("multi_hostname", multi_hostname, STRING),
|
||||||
{ NULL, 0, 0, 0 }
|
{ NULL, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -3066,7 +3067,7 @@ void processudp(uint8_t *buf, int len, struct sockaddr_in *addr, uint16_t indexu
|
||||||
controlt *c = controlnew(2); // sending SCCRP
|
controlt *c = controlnew(2); // sending SCCRP
|
||||||
control16(c, 2, version, 1); // protocol version
|
control16(c, 2, version, 1); // protocol version
|
||||||
control32(c, 3, 3, 1); // framing
|
control32(c, 3, 3, 1); // framing
|
||||||
controls(c, 7, hostname, 1); // host name
|
controls(c, 7, config->multi_n_hostname[tunnel[t].indexudp][0]?config->multi_n_hostname[tunnel[t].indexudp]:hostname, 1); // host name
|
||||||
if (sendchalresponse) controlb(c, 13, sendchalresponse, 16, 1); // Send Challenge response
|
if (sendchalresponse) controlb(c, 13, sendchalresponse, 16, 1); // Send Challenge response
|
||||||
control16(c, 9, t, 1); // assigned tunnel
|
control16(c, 9, t, 1); // assigned tunnel
|
||||||
controladd(c, 0, t); // send the resply
|
controladd(c, 0, t); // send the resply
|
||||||
|
|
@ -3092,7 +3093,7 @@ void processudp(uint8_t *buf, int len, struct sockaddr_in *addr, uint16_t indexu
|
||||||
{
|
{
|
||||||
LOG(3, s, t, "sending SCCCN to REMOTE LNS\n");
|
LOG(3, s, t, "sending SCCCN to REMOTE LNS\n");
|
||||||
controlt *c = controlnew(3); // sending SCCCN
|
controlt *c = controlnew(3); // sending SCCCN
|
||||||
controls(c, 7, hostname, 1); // host name
|
controls(c, 7, config->multi_n_hostname[tunnel[t].indexudp][0]?config->multi_n_hostname[tunnel[t].indexudp]:hostname, 1); // host name
|
||||||
controls(c, 8, Vendor_name, 1); // Vendor name
|
controls(c, 8, Vendor_name, 1); // Vendor name
|
||||||
control16(c, 2, version, 1); // protocol version
|
control16(c, 2, version, 1); // protocol version
|
||||||
control32(c, 3, 3, 1); // framing Capabilities
|
control32(c, 3, 3, 1); // framing Capabilities
|
||||||
|
|
@ -5426,6 +5427,8 @@ static void update_config()
|
||||||
config->iftun_n_address[config->nbmultiaddress] = htonl(ip);
|
config->iftun_n_address[config->nbmultiaddress] = htonl(ip);
|
||||||
config->nbmultiaddress++;
|
config->nbmultiaddress++;
|
||||||
LOG(1, 0, 0, "Bind address %s\n", fmtaddr(htonl(ip), 0));
|
LOG(1, 0, 0, "Bind address %s\n", fmtaddr(htonl(ip), 0));
|
||||||
|
|
||||||
|
if (config->nbmultiaddress >= MAX_BINDADDR) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sip = n;
|
sip = n;
|
||||||
|
|
@ -5444,6 +5447,39 @@ static void update_config()
|
||||||
config->iftun_n_address[0] = config->iftun_address;
|
config->iftun_n_address[0] = config->iftun_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*config->multi_hostname)
|
||||||
|
{
|
||||||
|
char *shost = config->multi_hostname;
|
||||||
|
char *n = shost;
|
||||||
|
char *e = config->multi_hostname + strlen(config->multi_hostname);
|
||||||
|
config->nbmultihostname = 0;
|
||||||
|
|
||||||
|
while (*shost && (shost < e))
|
||||||
|
{
|
||||||
|
while ((n < e) && (*n == ' ' || *n == '\t')) n++;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (n < e && (*n != ',') && (*n != '\t'))
|
||||||
|
{
|
||||||
|
config->multi_n_hostname[config->nbmultihostname][i] = *n;
|
||||||
|
n++;i++;
|
||||||
|
}
|
||||||
|
if (i > 0)
|
||||||
|
{
|
||||||
|
config->multi_n_hostname[config->nbmultihostname][i] = 0;
|
||||||
|
LOG(1, 0, 0, "Bind Hostname %s\n", config->multi_n_hostname[config->nbmultihostname]);
|
||||||
|
config->nbmultihostname++;
|
||||||
|
if (config->nbmultihostname >= MAX_NBHOSTNAME) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config->nbmultihostname >= 1)
|
||||||
|
{
|
||||||
|
strcpy(hostname, config->multi_n_hostname[0]);
|
||||||
|
strcpy(config->hostname, hostname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!*config->pppoe_ac_name)
|
if (!*config->pppoe_ac_name)
|
||||||
strncpy(config->pppoe_ac_name, DEFAULT_PPPOE_AC_NAME, sizeof(config->pppoe_ac_name) - 1);
|
strncpy(config->pppoe_ac_name, DEFAULT_PPPOE_AC_NAME, sizeof(config->pppoe_ac_name) - 1);
|
||||||
|
|
||||||
|
|
@ -6518,7 +6554,7 @@ void lac_send_SCCRQ(tunnelidt t, uint8_t * auth, unsigned int auth_len)
|
||||||
|
|
||||||
// Sent SCCRQ - Start Control Connection Request
|
// Sent SCCRQ - Start Control Connection Request
|
||||||
controlt *c = controlnew(1); // sending SCCRQ
|
controlt *c = controlnew(1); // sending SCCRQ
|
||||||
controls(c, 7, hostname, 1); // host name
|
controls(c, 7, config->multi_n_hostname[tunnel[t].indexudp][0]?config->multi_n_hostname[tunnel[t].indexudp]:hostname, 1); // host name
|
||||||
controls(c, 8, Vendor_name, 1); // Vendor name
|
controls(c, 8, Vendor_name, 1); // Vendor name
|
||||||
control16(c, 2, version, 1); // protocol version
|
control16(c, 2, version, 1); // protocol version
|
||||||
control32(c, 3, 3, 1); // framing Capabilities
|
control32(c, 3, 3, 1); // framing Capabilities
|
||||||
|
|
|
||||||
5
l2tpns.h
5
l2tpns.h
|
|
@ -69,6 +69,8 @@
|
||||||
// Multi bind address constants
|
// Multi bind address constants
|
||||||
#define MAX_UDPFD 4
|
#define MAX_UDPFD 4
|
||||||
#define MAX_BINDADDR MAX_UDPFD
|
#define MAX_BINDADDR MAX_UDPFD
|
||||||
|
// + 1 for the LAC Hostname
|
||||||
|
#define MAX_NBHOSTNAME (MAX_UDPFD + 1)
|
||||||
// 4 + 1 for the udplac
|
// 4 + 1 for the udplac
|
||||||
#define INIT_TABUDPFD {-1, -1, -1, -1, -1}
|
#define INIT_TABUDPFD {-1, -1, -1, -1, -1}
|
||||||
#define INIT_TABUDPVAR {0, 0, 0, 0, 0}
|
#define INIT_TABUDPVAR {0, 0, 0, 0, 0}
|
||||||
|
|
@ -780,9 +782,12 @@ typedef struct
|
||||||
int nbudpfd; // number UDP file handle
|
int nbudpfd; // number UDP file handle
|
||||||
int nbmultiaddress; // number multi address to bind
|
int nbmultiaddress; // number multi address to bind
|
||||||
int indexlacudpfd; // Index UDP LAC file handle (in udpfd[])
|
int indexlacudpfd; // Index UDP LAC file handle (in udpfd[])
|
||||||
|
int nbmultihostname; // number hostname, normally the same number as the nbudpfd
|
||||||
in_addr_t bind_n_address[MAX_BINDADDR];
|
in_addr_t bind_n_address[MAX_BINDADDR];
|
||||||
in_addr_t iftun_n_address[MAX_BINDADDR];
|
in_addr_t iftun_n_address[MAX_BINDADDR];
|
||||||
char bind_multi_address[256];
|
char bind_multi_address[256];
|
||||||
|
char multi_hostname[512];
|
||||||
|
char multi_n_hostname[MAX_NBHOSTNAME][MAXHOSTNAME]; // list hostname
|
||||||
} configt;
|
} configt;
|
||||||
|
|
||||||
enum config_typet { INT, STRING, UNSIGNED_LONG, SHORT, BOOL, IPv4, IPv6 };
|
enum config_typet { INT, STRING, UNSIGNED_LONG, SHORT, BOOL, IPv4, IPv6 };
|
||||||
|
|
|
||||||
6
ppp.c
6
ppp.c
|
|
@ -2507,9 +2507,9 @@ void sendchap(sessionidt s, tunnelidt t)
|
||||||
q[1] = radius[r].id; // ID
|
q[1] = radius[r].id; // ID
|
||||||
q[4] = 16; // value size (size of challenge)
|
q[4] = 16; // value size (size of challenge)
|
||||||
memcpy(q + 5, radius[r].auth, 16); // challenge
|
memcpy(q + 5, radius[r].auth, 16); // challenge
|
||||||
strcpy((char *) q + 21, hostname); // our name
|
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(hostname) + 21); // length
|
*(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(hostname) + 21 + (q - b), t); // send it
|
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,
|
// fill in a L2TP message with a PPP frame,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue