static gboolean
link_set_up (NMPlatform *platform, int ifindex)
{
	NMFakePlatformLink *device = link_get (platform, ifindex);

	if (!device)
		return FALSE;

	device->link.up = TRUE;
	switch (device->link.type) {
	case NM_LINK_TYPE_DUMMY:
	case NM_LINK_TYPE_VLAN:
		device->link.connected = TRUE;
		break;
	case NM_LINK_TYPE_BRIDGE:
	case NM_LINK_TYPE_BOND:
	case NM_LINK_TYPE_TEAM:
		device->link.connected = FALSE;
		break;
	default:
		device->link.connected = FALSE;
		g_error ("Unexpected device type: %d", device->link.type);
	}

	link_changed (platform, device);

	return TRUE;
}
static gboolean
link_release (NMPlatform *platform, int master_idx, int slave_idx)
{
	NMFakePlatformLink *master = link_get (platform, master_idx);
	NMFakePlatformLink *slave = link_get (platform, slave_idx);

	g_return_val_if_fail (master, FALSE);
	g_return_val_if_fail (slave, FALSE);

	if (slave->link.master != master->link.ifindex) {
		platform->error = NM_PLATFORM_ERROR_NOT_SLAVE;
		return FALSE;
	}

	slave->link.master = 0;

	link_changed (platform, slave);
	link_changed (platform, master);

	return TRUE;
}
static gboolean
link_set_mtu (NMPlatform *platform, int ifindex, guint32 mtu)
{
	NMFakePlatformLink *device = link_get (platform, ifindex);

	if (device) {
		device->link.mtu = mtu;
		link_changed (platform, device);
	}

	return !!device;
}
static gboolean
link_enslave (NMPlatform *platform, int master, int slave)
{
	NMFakePlatformLink *device = link_get (platform, slave);

	g_return_val_if_fail (device, FALSE);

	device->link.master = master;

	link_changed (platform, device);

	return TRUE;
}
static gboolean
link_set_address (NMPlatform *platform, int ifindex, gconstpointer addr, size_t len)
{
	NMFakePlatformLink *device = link_get (platform, ifindex);

	if (device->address)
		g_bytes_unref (device->address);

	device->address = g_bytes_new (addr, len);

	link_changed (platform, link_get (platform, ifindex));

	return TRUE;
}
static gboolean
link_set_noarp (NMPlatform *platform, int ifindex)
{
	NMFakePlatformLink *device = link_get (platform, ifindex);

	if (!device)
		return FALSE;

	device->link.arp = FALSE;

	link_changed (platform, device);

	return TRUE;
}
Example #7
0
/*
 * External interrupt handler for boards using elmer0.
 */
int elmer0_ext_intr_handler(adapter_t *adapter)
{
    	struct cphy *phy;
	int phy_cause;
    	u32 cause;

	t1_tpi_read(adapter, A_ELMER0_INT_CAUSE, &cause);

	switch (board_info(adapter)->board) {
	case CHBT_BOARD_N210:
	case CHBT_BOARD_N110:
		if (cause & ELMER0_GP_BIT6) { /* Marvell 88x2010 interrupt */
			phy = adapter->port[0].phy;
			phy_cause = phy->ops->interrupt_handler(phy);
			if (phy_cause & cphy_cause_link_change)
				link_changed(adapter, 0);
		}
		break;
	}
	t1_tpi_write(adapter, A_ELMER0_INT_CAUSE, cause);
	return 0;
}
static void
link_changed (NMPlatform *platform, NMFakePlatformLink *device)
{
	NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
	int i;

	g_signal_emit_by_name (platform, NM_PLATFORM_SIGNAL_LINK_CHANGED, device->link.ifindex, &device->link, NM_PLATFORM_SIGNAL_CHANGED, NM_PLATFORM_REASON_INTERNAL);

	if (device->link.master) {
		NMFakePlatformLink *master = link_get (platform, device->link.master);

		g_return_if_fail (master != device);

		master->link.connected = FALSE;
		for (i = 0; i < priv->links->len; i++) {
			NMFakePlatformLink *slave = &g_array_index (priv->links, NMFakePlatformLink, i);

			if (slave && slave->link.master == master->link.ifindex && slave->link.connected)
				master->link.connected = TRUE;
		}

		link_changed (platform, master);
	}
}
QWidget* TbInterfacesDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
    Q_UNUSED(option);
    QWidget *w = NULL;
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
    gint buffer = DEFAULT_CAPTURE_BUFFER_SIZE;
#endif
    guint snap = WTAP_MAX_PACKET_SIZE;
    GList *links = NULL;

    if (index.column() > 1) {
        interface_t device;
        QTableWidgetItem *it = table->item(index.row(), INTERFACE);
        QString interface_name = it->text();
        for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) {
            device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
            buffer = device.buffer;
#endif
            snap = device.snaplen;
            links = device.links;
            if (interface_name.compare(device.display_name) || device.hidden || device.type == IF_PIPE) {
                continue;
            } else {
                break;
            }
        }
        switch (index.column()) {
        case INTERFACE:
            break;
        case LINK:
        {
            GList *list;
            link_row *temp;
            QComboBox *cb = new QComboBox(parent);
            for (list=links; list!=NULL; list=g_list_next(list)) {
                temp = (link_row*)(list->data);
                cb->addItem(QString("%1").arg(temp->name));
            }
            connect(cb, SIGNAL(currentIndexChanged(QString)), this, SLOT(link_changed(QString)));
            w = (QWidget*) cb;
            break;
        }
        case PMODE:
        {
        // Create the combobox and populate it
            QComboBox *cb = new QComboBox(parent);
            cb->addItem(QString(tr("enabled")));
            cb->addItem(QString(tr("disabled")));
            connect(cb, SIGNAL(currentIndexChanged(QString)), this, SLOT(pmode_changed(QString)));
            w = (QWidget*) cb;
            break;
        }
#if defined (HAVE_PCAP_CREATE)
        case MONITOR:
        {
             if (index.data().toString().compare(QString("n/a"))) {
                QComboBox *cb = new QComboBox(parent);
                cb->addItem(QString(tr("enabled")));
                cb->addItem(QString(tr("disabled")));
                connect(cb, SIGNAL(currentIndexChanged(QString)), this, SLOT(monitor_changed(QString)));
                w = (QWidget*) cb;
             }
             break;
        }
#endif
        case SNAPLEN:
        {
            QSpinBox *sb = new QSpinBox(parent);
            sb->setRange(1, 65535);
            sb->setValue(snap);
            sb->setWrapping(true);
            connect(sb, SIGNAL(valueChanged(int)), this, SLOT(snaplen_changed(int)));
            w = (QWidget*) sb;
            break;
        }
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
        case BUFFER:
        {
            QSpinBox *sb = new QSpinBox(parent);
            sb->setRange(1, 65535);
            sb->setValue(buffer);
            sb->setWrapping(true);
            connect(sb, SIGNAL(valueChanged(int)), this, SLOT(buffer_changed(int)));
            w = (QWidget*) sb;
            break;
        }
#endif
        case FILTER:
        {
            CaptureFilterCombo *cf = new CaptureFilterCombo(parent);
            w = (QWidget*) cf;
        }
        }
    }