Exemplo n.º 1
0
/* write the IP address to /etc/config/config so the user can tell what
 * IP address the NETtel got. 
 *
 * Secondly, launch dhcpcd-change, but only if it is not a DISKTEL
 */
int ipfwadm_rules(char *ifname, u_int32_t yiaddr)
{
	char buf[32];
	FILE *in;
	pid_t pid;
	char tmp[MAX_CONFIG_LINE_SIZE];
	struct in_addr inp;
	struct stat st;
	
	inp.s_addr = yiaddr;

	/* No need to write this config to flash because it is dynamic
	 * information. */
	sprintf(buf, "ip%s\0", ifname);
	writeConfig("/etc/config/config", buf, (char *) inet_ntoa(inp));

#ifndef CONFIG_DEFAULTS_LINEO_DISKTEL
	if (stat("/etc/config/dhcpcd-change", &st) == 0) {
		launch_script("/etc/config/dhcpcd-change");
	} else {
		launch_script("/etc/config/ipfwrules");
	}
#endif

	return 0;
}
Exemplo n.º 2
0
Arquivo: tap.c Projeto: D3cedut0/QEMU
static int net_tap_init(QemuOpts *opts, int *vnet_hdr)
{
    int fd, vnet_hdr_required;
    char ifname[128] = {0,};
    const char *setup_script;

    if (qemu_opt_get(opts, "ifname")) {
        pstrcpy(ifname, sizeof(ifname), qemu_opt_get(opts, "ifname"));
    }

    *vnet_hdr = qemu_opt_get_bool(opts, "vnet_hdr", 1);
    if (qemu_opt_get(opts, "vnet_hdr")) {
        vnet_hdr_required = *vnet_hdr;
    } else {
        vnet_hdr_required = 0;
    }

    TFR(fd = tap_open(ifname, sizeof(ifname), vnet_hdr, vnet_hdr_required));
    if (fd < 0) {
        return -1;
    }

    setup_script = qemu_opt_get(opts, "script");
    if (setup_script &&
        setup_script[0] != '\0' &&
        strcmp(setup_script, "no") != 0 &&
        launch_script(setup_script, ifname, fd)) {
        close(fd);
        return -1;
    }

    qemu_opt_set(opts, "ifname", ifname);

    return fd;
}
Exemplo n.º 3
0
static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr,
                        const char *setup_script, char *ifname,
                        size_t ifname_sz, int mq_required)
{
    int fd, vnet_hdr_required;

    if (tap->has_vnet_hdr) {
        *vnet_hdr = tap->vnet_hdr;
        vnet_hdr_required = *vnet_hdr;
    } else {
        *vnet_hdr = 1;
        vnet_hdr_required = 0;
    }

    TFR(fd = tap_open(ifname, ifname_sz, vnet_hdr, vnet_hdr_required,
                      mq_required));
    if (fd < 0) {
        return -1;
    }

    if (setup_script &&
        setup_script[0] != '\0' &&
        strcmp(setup_script, "no") != 0 &&
        launch_script(setup_script, ifname, fd)) {
        close(fd);
        return -1;
    }

    return fd;
}
Exemplo n.º 4
0
Arquivo: tap.c Projeto: PennPanda/qemu
static int net_tap_init(const NetdevTapOptions *tap, int *vnet_hdr,
                        const char *setup_script, char *ifname,
                        size_t ifname_sz, int mq_required, Error **errp)
{
    Error *err = NULL;
    int fd, vnet_hdr_required;

    if (tap->has_vnet_hdr) {
        *vnet_hdr = tap->vnet_hdr;
        vnet_hdr_required = *vnet_hdr;
    } else {
        *vnet_hdr = 1;
        vnet_hdr_required = 0;
    }

    TFR(fd = tap_open(ifname, ifname_sz, vnet_hdr, vnet_hdr_required,
                      mq_required, errp));
    if (fd < 0) {
        return -1;
    }

    if (setup_script &&
        setup_script[0] != '\0' &&
        strcmp(setup_script, "no") != 0) {
        launch_script(setup_script, ifname, fd, &err);
        if (err) {
            error_propagate(errp, err);
            close(fd);
            return -1;
        }
    }

    return fd;
}
Exemplo n.º 5
0
Arquivo: tap.c Projeto: PennPanda/qemu
static void tap_exit_notify(Notifier *notifier, void *data)
{
    TAPState *s = container_of(notifier, TAPState, exit);
    Error *err = NULL;

    if (s->down_script[0]) {
        launch_script(s->down_script, s->down_script_arg, s->fd, &err);
        if (err) {
            error_report_err(err);
        }
    }
}
Exemplo n.º 6
0
static void tap_cleanup(VLANClientState *nc)
{
    TAPState *s = DO_UPCAST(TAPState, nc, nc);

    qemu_purge_queued_packets(nc);

    if (s->down_script[0])
        launch_script(s->down_script, s->down_script_arg, s->fd);

    tap_read_poll(s, 0);
    tap_write_poll(s, 0);
    close(s->fd);
}
Exemplo n.º 7
0
void		exec_rtconf(t_system *system)
{
  char		*path;
  t_file	*rcfile;

  path = get_rc_path(system);
  if (path)
    {
      if (access(path, R_OK) == 0)
	{
	  rcfile = open_file(path, FILE_R);
	  launch_script(rcfile, system);
	  close_file(rcfile);
	}
      free(path);
    }
}
Exemplo n.º 8
0
static void tap_cleanup(NetClientState *nc)
{
    TAPState *s = DO_UPCAST(TAPState, nc, nc);

    if (s->vhost_net) {
        vhost_net_cleanup(s->vhost_net);
        s->vhost_net = NULL;
    }

    qemu_purge_queued_packets(nc);

    if (s->down_script[0])
        launch_script(s->down_script, s->down_script_arg, s->fd);

    tap_read_poll(s, false);
    tap_write_poll(s, false);
    close(s->fd);
    s->fd = -1;
}