Browse Source

Add pointopoint support.

r605
master
Matt Kraai 22 years ago
parent
commit
bc6b9dc667
  1. 8
      debian/template/netcfg-static.templates
  2. 9
      debian/template/netcfg-static.templates.en
  3. 54
      netcfg-static.c

8
debian/template/netcfg-static.templates

@ -30,6 +30,14 @@ Description-ru: IP
разделенных точками. Если вы не знаете, что нужно указать, то
проконсультируйтесь с вашим сетевым администратором.
Template: netcfg/get_pointopoint
Type: string
Description: Pointopoint address?
The pointopoint address is used to determine the other endpoint of the
point to point network. Consult your network administrator if you do
not know the value. The pointopoint address should be entered as four
numbers separated by periods.
Template: netcfg/gateway_unreachable
Type: note
Description: The gateway you entered is unreachable.

9
debian/template/netcfg-static.templates.en

@ -5,6 +5,14 @@ Description: IP address?
numbers separated by periods. If you don't know what to use here,
consult your network administrator.
Template: netcfg/get_pointopoint
Type: string
Description: Pointopoint address?
The pointopoint address is used to determine the other endpoint of the
point to point network. Consult your network administrator if you do
not know the value. The pointopoint address should be entered as four
numbers separated by periods.
Template: netcfg/get_netmask
Type: string
Description: Netmask?
@ -39,5 +47,6 @@ Description: Is this configuration correct?
ipaddress = ${ipaddress}
netmask = ${netmask}
gateway = ${gateway}
pointopoint = ${pointopoint}
nameservers = ${nameservers}

54
netcfg-static.c

@ -43,6 +43,7 @@ static u_int32_t network = 0;
static u_int32_t broadcast = 0;
static u_int32_t netmask = 0;
static u_int32_t gateway = 0;
static u_int32_t pointopoint = 0;
static struct debconfclient *client;
char *
@ -61,7 +62,7 @@ netcfg_get_static ()
{
char *ptr;
ipaddress = network = broadcast = netmask = gateway = 0;
ipaddress = network = broadcast = netmask = gateway = pointopoint = 0;
ptr = debconf_input ("critical", "netcfg/get_ipaddress");
dot2num (&ipaddress, ptr);
@ -70,28 +71,44 @@ netcfg_get_static ()
"ipaddress",
(ipaddress ? num2dot (ipaddress) : "<none>"), NULL);
ptr = debconf_input ("critical", "netcfg/get_netmask");
dot2num (&netmask, ptr);
client->command (client, "subst", "netcfg/confirm_static",
"netmask", (netmask ? num2dot (netmask) : "<none>"), NULL);
if (strncmp (interface, "plip", 4) == 0
|| strncmp (interface, "slip", 4) == 0)
{
ptr = debconf_input ("critical", "netcfg/get_pointopoint");
dot2num (&pointopoint, ptr);
network = ipaddress & netmask;
dot2num (&netmask, "255.255.255.255");
network = ipaddress;
gateway = pointopoint;
}
else
{
ptr = debconf_input ("critical", "netcfg/get_netmask");
dot2num (&netmask, ptr);
ptr = debconf_input ("critical", "netcfg/get_gateway");
dot2num (&gateway, ptr);
ptr = debconf_input ("critical", "netcfg/get_gateway");
dot2num (&gateway, ptr);
client->command (client, "subst", "netcfg/confirm_static",
"gateway", (gateway ? num2dot (gateway) : "<none>"), NULL);
network = ipaddress & netmask;
if (gateway && ((gateway & netmask) != network))
{
client->command (client, "input", "high",
"netcfg/gateway_unreachable", NULL);
client->command (client, "go", NULL);
if (gateway && ((gateway & netmask) != network))
{
client->command (client, "input", "high",
"netcfg/gateway_unreachable", NULL);
client->command (client, "go", NULL);
}
}
broadcast = (network | ~netmask);
client->command (client, "subst", "netcfg/confirm_static", "netmask",
(netmask ? num2dot (netmask) : "<none>"), NULL);
client->command (client, "subst", "netcfg/confirm_static", "gateway",
(gateway ? num2dot (gateway) : "<none>"), NULL);
client->command (client, "subst", "netcfg/confirm_static", "pointopoint",
(pointopoint ? num2dot (pointopoint) : "<none>"), NULL);
broadcast = (network | ~netmask);
}
@ -120,6 +137,8 @@ netcfg_write_static ()
fprintf (fp, "\tbroadcast %s\n", num2dot (broadcast));
if (gateway)
fprintf (fp, "\tgateway %s\n", num2dot (gateway));
if (pointopoint)
fprintf (fp, "\tpointopoint %s\n", num2dot (pointopoint));
fclose (fp);
}
else
@ -155,6 +174,9 @@ netcfg_activate_static ()
interface, num2dot (ipaddress), num2dot (netmask),
num2dot (broadcast));
if (pointopoint)
snprintfcat (buf, sizeof (buf), " pointopoint %s", num2dot (pointopoint));
rv |= execlog (buf);
if (gateway)

Loading…
Cancel
Save