Browse Source

* add support for GNU/kFreeBSD.

r63589
tags/1.53
Aurelien Jarno 11 years ago
parent
commit
116898f571
4 changed files with 56 additions and 0 deletions
  1. +1
    -0
      debian/changelog
  2. +9
    -0
      dhcp.c
  3. +6
    -0
      netcfg-common.c
  4. +40
    -0
      static.c

+ 1
- 0
debian/changelog View File

@@ -20,6 +20,7 @@ netcfg (1.53) UNRELEASED; urgency=low
[ Aurelien Jarno ]
* simplify kfreebsd dependencies.
* depends on freebsd-net-tools-udeb on kfreebsd.
* add support for GNU/kFreeBSD.

-- Frans Pop <fjp@debian.org> Thu, 08 Apr 2010 00:32:48 +0200



+ 9
- 0
dhcp.c View File

@@ -16,6 +16,7 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <time.h>
@@ -80,6 +81,13 @@ static void netcfg_write_dhcp (char *iface, char *dhostname)
/* Returns 1 if no default route is available */
static short no_default_route (void)
{
#if defined(__FreeBSD_kernel__)
int status;

status = system("exec /lib/freebsd/route show default >/dev/null 2>&1");

return WEXITSTATUS(status) != 0;
#else
FILE* iproute = NULL;
char buf[256] = { 0 };

@@ -94,6 +102,7 @@ static short no_default_route (void)
}

return 1;
#endif
}

/*


+ 6
- 0
netcfg-common.c View File

@@ -764,12 +764,18 @@ void loop_setup(void)

deconfigure_network();

#if defined(__FreeBSD_kernel__)
/* GNU/kFreeBSD currently uses the ifconfig command */
di_exec_shell_log("ifconfig "LO_IF" up");
di_exec_shell_log("ifconfig "LO_IF" 127.0.0.1 netmask 255.0.0.0");
#else
if (afpacket_notloaded)
afpacket_notloaded = di_exec_shell("modprobe af_packet"); /* should become 0 */

di_exec_shell_log("ip link set "LO_IF" up");
di_exec_shell_log("ip addr flush dev "LO_IF);
di_exec_shell_log("ip addr add 127.0.0.1/8 dev "LO_IF);
#endif
}

void seed_hostname_from_dns (struct debconfclient * client, struct in_addr *ipaddr)


+ 40
- 0
static.c View File

@@ -288,6 +288,46 @@ int netcfg_activate_static(struct debconfclient *client)

rv |= di_exec_shell_log(buf);

#elif defined(__FreeBSD_kernel__)
deconfigure_network();
loop_setup();
interface_up(interface);
/* Flush all previous addresses, routes */
snprintf(buf, sizeof(buf), "ifconfig %s inet 0 down", interface);
rv |= di_exec_shell_log(buf);
snprintf(buf, sizeof(buf), "ifconfig %s up", interface);
rv |= di_exec_shell_log(buf);
snprintf(buf, sizeof(buf), "ifconfig %s %s",
interface,
inet_ntop (AF_INET, &ipaddress, ptr1, sizeof (ptr1)));
/* avoid using a second buffer */
di_snprintfcat(buf, sizeof(buf), " netmask %s",
inet_ntop (AF_INET, &netmask, ptr1, sizeof (ptr1)));

/* avoid using a third buffer */
di_snprintfcat(buf, sizeof(buf), " broadcast %s",
inet_ntop (AF_INET, &broadcast, ptr1, sizeof (ptr1)));
di_info("executing: %s", buf);
rv |= di_exec_shell_log(buf);
if (pointopoint.s_addr) {
snprintf(buf, sizeof(buf), "route add %s",
inet_ntop (AF_INET, &pointopoint, ptr1, sizeof (ptr1)));
/* avoid using a second buffer */
di_snprintfcat(buf, sizeof(buf), "%s",
inet_ntop (AF_INET, &ipaddress, ptr1, sizeof (ptr1)));
rv |= di_exec_shell_log(buf);
} else if (gateway.s_addr) {
snprintf(buf, sizeof(buf), "route add default %s",
inet_ntop (AF_INET, &gateway, ptr1, sizeof (ptr1)));
rv |= di_exec_shell_log(buf);
}
#else
deconfigure_network();



Loading…
Cancel
Save