111 | 111 |
*/
|
112 | 112 |
static int nc_wi_static_ipv4(const struct netcfg_interface *interface, FILE *fd)
|
113 | 113 |
{
|
114 | |
char network[INET_ADDRSTRLEN];
|
115 | |
char broadcast[INET_ADDRSTRLEN];
|
116 | |
char netmask[INET_ADDRSTRLEN];
|
117 | |
|
118 | |
netcfg_network_address(interface, network);
|
119 | |
netcfg_broadcast_address(interface, broadcast);
|
120 | |
inet_mtop(AF_INET, interface->masklen, netmask, INET_ADDRSTRLEN);
|
121 | |
|
122 | 114 |
fprintf(fd, "\n# The primary network interface\n");
|
123 | 115 |
if (!iface_is_hotpluggable(interface->name) && !find_in_stab(interface->name))
|
124 | 116 |
fprintf(fd, "auto %s\n", interface->name);
|
125 | 117 |
else
|
126 | 118 |
fprintf(fd, "allow-hotplug %s\n", interface->name);
|
127 | 119 |
fprintf(fd, "iface %s inet static\n", interface->name);
|
128 | |
fprintf(fd, "\taddress %s\n", interface->ipaddress);
|
129 | |
fprintf(fd, "\tnetmask %s\n", empty_str(interface->pointopoint) ? netmask : "255.255.255.255");
|
130 | |
fprintf(fd, "\tnetwork %s\n", network);
|
131 | |
fprintf(fd, "\tbroadcast %s\n", broadcast);
|
|
120 |
fprintf(fd, "\taddress %s/%i\n", interface->ipaddress,
|
|
121 |
empty_str(interface->pointopoint) ? interface->masklen : 32);
|
132 | 122 |
if (!empty_str(interface->gateway))
|
133 | 123 |
fprintf(fd, "\tgateway %s\n",
|
134 | 124 |
empty_str(interface->pointopoint) ? interface->gateway : interface->pointopoint);
|
|
148 | 138 |
else
|
149 | 139 |
fprintf(fd, "allow-hotplug %s\n", interface->name);
|
150 | 140 |
fprintf(fd, "iface %s inet6 static\n", interface->name);
|
151 | |
fprintf(fd, "\taddress %s\n", interface->ipaddress);
|
152 | |
fprintf(fd, "\tnetmask %i\n", interface->masklen);
|
|
141 |
fprintf(fd, "\taddress %s/%i\n", interface->ipaddress, interface->masklen);
|
153 | 142 |
if (!empty_str(interface->gateway))
|
154 | 143 |
fprintf(fd, "\tgateway %s\n", interface->gateway);
|
155 | 144 |
|