NMDeviceFactory parent; } NMTeamFactory; typedef struct { NMDeviceFactoryClass parent; } NMTeamFactoryClass; static GType nm_team_factory_get_type (void); G_DEFINE_TYPE (NMTeamFactory, nm_team_factory, NM_TYPE_DEVICE_FACTORY) /*****************************************************************************/ NM_DEVICE_FACTORY_DECLARE_TYPES ( NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_TEAM) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_TEAM_SETTING_NAME) ) G_MODULE_EXPORT NMDeviceFactory * nm_device_factory_create (GError **error) { nm_manager_set_capability (nm_manager_get (), NM_CAPABILITY_TEAM); return (NMDeviceFactory *) g_object_new (NM_TYPE_TEAM_FACTORY, NULL); } /*****************************************************************************/ static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, const NMPlatformLink *plink,
} static char * get_virtual_iface_name (NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface) { const char *ifname; NMSettingIPTunnel *s_ip_tunnel; g_return_val_if_fail (nm_connection_is_type (connection, NM_SETTING_IP_TUNNEL_SETTING_NAME), NULL); s_ip_tunnel = nm_connection_get_setting_ip_tunnel (connection); g_assert (s_ip_tunnel); if (nm_setting_ip_tunnel_get_parent (s_ip_tunnel) && !parent_iface) return NULL; ifname = nm_connection_get_interface_name (connection); return g_strdup (ifname); } NM_DEVICE_FACTORY_DEFINE_INTERNAL (IP_TUNNEL, IPTunnel, ip_tunnel, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_GRE, NM_LINK_TYPE_SIT, NM_LINK_TYPE_IPIP) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_IP_TUNNEL_SETTING_NAME), factory_iface->create_device = create_device; factory_iface->get_connection_parent = get_connection_parent; factory_iface->get_virtual_iface_name = get_virtual_iface_name; )
} static char * get_connection_iface (NMDeviceFactory *factory, NMConnection *connection, const char *parent_iface) { const char *ifname; NMSettingVxlan *s_vxlan; g_return_val_if_fail (nm_connection_is_type (connection, NM_SETTING_VXLAN_SETTING_NAME), NULL); s_vxlan = nm_connection_get_setting_vxlan (connection); g_assert (s_vxlan); if (nm_setting_vxlan_get_parent (s_vxlan) && !parent_iface) return NULL; ifname = nm_connection_get_interface_name (connection); return g_strdup (ifname); } NM_DEVICE_FACTORY_DEFINE_INTERNAL (VXLAN, Vxlan, vxlan, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_VXLAN) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_VXLAN_SETTING_NAME), factory_iface->create_device = create_device; factory_iface->get_connection_parent = get_connection_parent; factory_iface->get_connection_iface = get_connection_iface; )
port = nm_modem_get_control_port (modem); nm_log_info (LOGD_MB, "ignoring modem '%s' (no associated Bluetooth device)", port); return; } /* Make the new modem device */ device = nm_device_modem_new (modem); g_assert (device); g_signal_emit_by_name (self, NM_DEVICE_FACTORY_DEVICE_ADDED, device); g_object_unref (device); } NM_DEVICE_FACTORY_DECLARE_TYPES ( NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_WWAN_ETHERNET) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_GSM_SETTING_NAME, NM_SETTING_CDMA_SETTING_NAME) ) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { g_return_val_if_fail (plink, NULL); g_return_val_if_fail (plink->type == NM_LINK_TYPE_WWAN_ETHERNET, NULL); *out_ignore = TRUE; return NULL; }
typedef struct { NMDeviceFactoryClass parent; } NMBluezManagerClass; static GType nm_bluez_manager_get_type (void); G_DEFINE_TYPE (NMBluezManager, nm_bluez_manager, NM_TYPE_DEVICE_FACTORY); #define NM_BLUEZ_MANAGER_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMBluezManager, NM_IS_BLUEZ_MANAGER) /*****************************************************************************/ NM_DEVICE_FACTORY_DECLARE_TYPES ( NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_BNEP) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_BLUETOOTH_SETTING_NAME) ) G_MODULE_EXPORT NMDeviceFactory * nm_device_factory_create (GError **error) { return (NMDeviceFactory *) g_object_new (NM_TYPE_BLUEZ_MANAGER, NULL); } /*****************************************************************************/ #define _NMLOG_DOMAIN LOGD_BT #define _NMLOG(level, ...) __NMLOG_DEFAULT (level, _NMLOG_DOMAIN, "bluez", __VA_ARGS__) /*****************************************************************************/
} /*************************************************************/ #define NM_TYPE_BRIDGE_FACTORY (nm_bridge_factory_get_type ()) #define NM_BRIDGE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_BRIDGE_FACTORY, NMBridgeFactory)) static NMDevice * create_device (NMDeviceFactory *factory, const char *iface, const NMPlatformLink *plink, NMConnection *connection, gboolean *out_ignore) { return (NMDevice *) g_object_new (NM_TYPE_DEVICE_BRIDGE, NM_DEVICE_IFACE, iface, NM_DEVICE_DRIVER, "bridge", NM_DEVICE_TYPE_DESC, "Bridge", NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_BRIDGE, NM_DEVICE_LINK_TYPE, NM_LINK_TYPE_BRIDGE, NM_DEVICE_IS_MASTER, TRUE, NULL); } NM_DEVICE_FACTORY_DEFINE_INTERNAL (BRIDGE, Bridge, bridge, NM_DEVICE_FACTORY_DECLARE_LINK_TYPES (NM_LINK_TYPE_BRIDGE) NM_DEVICE_FACTORY_DECLARE_SETTING_TYPES (NM_SETTING_BRIDGE_SETTING_NAME), factory_iface->create_device = create_device; )