about summary refs log tree commit diff
path: root/src/nm-cloud-setup/nmcs-provider.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nm-cloud-setup/nmcs-provider.h')
-rw-r--r--src/nm-cloud-setup/nmcs-provider.h43
1 files changed, 37 insertions, 6 deletions
diff --git a/src/nm-cloud-setup/nmcs-provider.h b/src/nm-cloud-setup/nmcs-provider.h
index bce41dcb..502f1d03 100644
--- a/src/nm-cloud-setup/nmcs-provider.h
+++ b/src/nm-cloud-setup/nmcs-provider.h
@@ -9,11 +9,16 @@
 
 /*****************************************************************************/
 
+struct _NMCSProvider;
+struct _NMCSProviderGetConfigTaskData;
+
 typedef struct {
     /* And it's exactly the same pointer that is also the key for the iface_datas
      * dictionary. */
     const char *hwaddr;
 
+    struct _NMCSProviderGetConfigTaskData *get_config_data;
+
     in_addr_t *ipv4s_arr;
     gsize      ipv4s_len;
 
@@ -36,6 +41,18 @@ typedef struct {
      * nmcs_provider_get_config(). */
     bool was_requested : 1;
 
+    /* Usually we would want that the parent class NMCSProvider is not aware about
+     * the implementations. However, it's convenient to track implementation specific data
+     * here, thus we violate such separation. In practice, all subclasses are known
+     * at compile time, and it will be simpler this way. */
+    union {
+        struct {
+            in_addr_t primary_ip_address;
+            bool      has_primary_ip_address : 1;
+            bool      ipv4s_arr_ordered : 1;
+        } aliyun;
+    } priv;
+
 } NMCSProviderGetConfigIfaceData;
 
 static inline gboolean
@@ -45,10 +62,6 @@ nmcs_provider_get_config_iface_data_is_valid(const NMCSProviderGetConfigIfaceDat
            && ((config_data->has_ipv4s && config_data->has_cidr) || config_data->iproutes_len);
 }
 
-NMCSProviderGetConfigIfaceData *nmcs_provider_get_config_iface_data_create(GHashTable *iface_datas,
-                                                                           gboolean was_requested,
-                                                                           const char *hwaddr);
-
 /*****************************************************************************/
 
 typedef struct {
@@ -83,9 +96,11 @@ NM_AUTO_DEFINE_FCN0(NMCSProviderGetConfigResult *,
 
 /*****************************************************************************/
 
-typedef struct {
+typedef struct _NMCSProviderGetConfigTaskData {
     GTask *task;
 
+    struct _NMCSProvider *self;
+
     GHashTable *result_dict;
 
     /* this cancellable should be used for the provider implementation
@@ -105,6 +120,15 @@ typedef struct {
     bool any : 1;
 } NMCSProviderGetConfigTaskData;
 
+/*****************************************************************************/
+
+NMCSProviderGetConfigIfaceData *
+nmcs_provider_get_config_iface_data_create(NMCSProviderGetConfigTaskData *get_config_data,
+                                           gboolean                       was_requested,
+                                           const char                    *hwaddr);
+
+/*****************************************************************************/
+
 #define NMCS_TYPE_PROVIDER (nmcs_provider_get_type())
 #define NMCS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NMCS_TYPE_PROVIDER, NMCSProvider))
 #define NMCS_PROVIDER_CLASS(klass) \
@@ -118,7 +142,7 @@ typedef struct {
 
 struct _NMCSProviderPrivate;
 
-typedef struct {
+typedef struct _NMCSProvider {
     GObject                      parent;
     struct _NMCSProviderPrivate *_priv;
 } NMCSProvider;
@@ -167,4 +191,11 @@ void nmcs_provider_get_config(NMCSProvider       *provider,
 NMCSProviderGetConfigResult *
 nmcs_provider_get_config_finish(NMCSProvider *provider, GAsyncResult *result, GError **error);
 
+/*****************************************************************************/
+
+/* Forward declare the implemented gtype getters so we can use it at a few places without requiring
+ * to include the full header. The other parts of those headers should not be used aside where they
+ * are necessary. */
+GType nmcs_provider_aliyun_get_type(void);
+
 #endif /* __NMCS_PROVIDER_H__ */