use OS type on IMV side
[strongswan.git] / src / libimcv / plugins / imv_os / imv_os_state.c
index e36d4ae..49d2e56 100644 (file)
@@ -65,9 +65,35 @@ struct private_imv_os_state_t {
        TNC_IMV_Evaluation_Result eval;
 
        /**
-        * OS Product Information
+        * OS Product Information (concatenation of OS Name and Version)
         */
        char *info;
+
+       /**
+        * OS Type
+        */
+       os_type_t type;
+
+       /**
+        * OS Name
+        */
+       chunk_t name;
+
+       /**
+        * OS Version
+        */
+       chunk_t version;
+
+       /**
+        * OS Installed Package request sent - mandatory response expected
+        */
+       bool package_request;
+
+       /**
+        * Angel count
+        */
+       int angel_count;
+
 };
 
 typedef struct entry_t entry_t;
@@ -160,11 +186,13 @@ METHOD(imv_state_t, destroy, void,
        private_imv_os_state_t *this)
 {
        free(this->info);
+       free(this->name.ptr);
+       free(this->version.ptr);
        free(this);
 }
 
 METHOD(imv_os_state_t, set_info, void,
-       private_imv_os_state_t *this, chunk_t name, chunk_t version)
+       private_imv_os_state_t *this, os_type_t type, chunk_t name, chunk_t version)
 {
        int len = name.len + 1 + version.len + 1;
 
@@ -173,14 +201,60 @@ METHOD(imv_os_state_t, set_info, void,
        this->info = malloc(len);
        snprintf(this->info, len, "%.*s %.*s", name.len, name.ptr,
                                                                                   version.len, version.ptr);
+       this->type = type;
+       this->name = chunk_clone(name);
+       this->version = chunk_clone(version);
 }
 
 METHOD(imv_os_state_t, get_info, char*,
-       private_imv_os_state_t *this)
+       private_imv_os_state_t *this, os_type_t *type, chunk_t *name,
+       chunk_t *version)
 {
+       if (type)
+       {
+               *type = this->type;
+       }
+       if (name)
+       {
+               *name = this->name;
+       }
+       if (version)
+       {
+               *version = this->version;
+       }
        return this->info;
 }
 
+METHOD(imv_os_state_t, get_type, os_type_t,
+       private_imv_os_state_t *this)
+{
+       return this->type;
+}
+
+METHOD(imv_os_state_t, set_package_request, void,
+       private_imv_os_state_t *this, bool set)
+{
+       this->package_request = set;
+}
+
+METHOD(imv_os_state_t, get_package_request, bool,
+       private_imv_os_state_t *this)
+{
+       return this->package_request;
+}
+
+METHOD(imv_os_state_t, set_angel_count, void,
+       private_imv_os_state_t *this, bool start)
+{
+       this->angel_count += start ? 1 : -1;
+}
+
+METHOD(imv_os_state_t, get_angel_count, int,
+       private_imv_os_state_t *this)
+{
+       return this->angel_count;
+}
+
 /**
  * Described in header.
  */
@@ -205,6 +279,10 @@ imv_state_t *imv_os_state_create(TNC_ConnectionID connection_id)
                        },
                        .set_info = _set_info,
                        .get_info = _get_info,
+                       .set_package_request = _set_package_request,
+                       .get_package_request = _get_package_request,
+                       .set_angel_count = _set_angel_count,
+                       .get_angel_count = _get_angel_count,
                },
                .state = TNC_CONNECTION_STATE_CREATE,
                .rec = TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,