transmit Product Vendor ID if known
authorAndreas Steffen <andreas.steffen@strongswan.org>
Wed, 31 Oct 2012 19:29:36 +0000 (20:29 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Wed, 31 Oct 2012 19:29:36 +0000 (20:29 +0100)
src/libimcv/plugins/imc_os/imc_os.c
src/libimcv/plugins/imv_os/imv_os.c
src/libstrongswan/pen/pen.c

index f50b8aa..48bc6e2 100644 (file)
@@ -123,8 +123,32 @@ TNC_Result TNC_IMC_NotifyConnectionChange(TNC_IMCID imc_id,
 static void add_product_info(imc_msg_t *msg)
 {
        pa_tnc_attr_t *attr;
-
-       attr = ietf_attr_product_info_create(PEN_IETF, 0, os->get_name(os));
+       chunk_t os_name;
+       pen_t vendor_id = PEN_IETF;
+       char *vendor;
+       int i;
+
+       typedef struct vendor_pen_t {
+               char *vendor;
+               pen_t pen;
+       } vendor_pen_t;
+
+       vendor_pen_t vendor_pens[] = {
+               { "Debian", PEN_DEBIAN },
+               { "Ubuntu", PEN_CANONICAL }
+       };
+
+       os_name = os->get_name(os);
+       for (i = 0; i < countof(vendor_pens); i++)
+       {
+               vendor = vendor_pens[i].vendor;
+               if (chunk_equals(os_name, chunk_create(vendor, strlen(vendor))))
+               {
+                       vendor_id = vendor_pens[i].pen;
+                       break;
+               }
+       }
+       attr = ietf_attr_product_info_create(vendor_id, 0, os_name);
        msg->add_attribute(msg, attr);
 }
 
index 2346918..2cb60ef 100644 (file)
@@ -138,11 +138,21 @@ static TNC_Result receive_message(imv_state_t *state, imv_msg_t *in_msg)
                        case IETF_ATTR_PRODUCT_INFORMATION:
                        {
                                ietf_attr_product_info_t *attr_cast;
+                               pen_t vendor_id;
 
                                attr_cast = (ietf_attr_product_info_t*)attr;
-                               os_name = attr_cast->get_info(attr_cast, NULL, NULL);
-                               DBG1(DBG_IMV, "operating system name is '%.*s'",
-                                                          os_name.len, os_name.ptr);
+                               os_name = attr_cast->get_info(attr_cast, &vendor_id, NULL);
+                               if (vendor_id != PEN_IETF)
+                               {
+                                       DBG1(DBG_IMV, "operating system name is '%.*s' "
+                                                                 "from vendor %N", os_name.len, os_name.ptr,
+                                                                  pen_names, vendor_id);
+                               }
+                               else
+                               {
+                                       DBG1(DBG_IMV, "operating system name is '%.*s'",
+                                                                  os_name.len, os_name.ptr);
+                               }
                                break;
                        }
                        case IETF_ATTR_STRING_VERSION:
index 6ca6f2c..b1b0731 100644 (file)
@@ -26,7 +26,7 @@ ENUM_NEXT(pen_names, PEN_REDHAT, PEN_REDHAT, PEN_MICROSOFT,
 ENUM_NEXT(pen_names, PEN_OSC, PEN_OSC, PEN_REDHAT,
        "OSC");
 ENUM_NEXT(pen_names, PEN_DEBIAN, PEN_DEBIAN, PEN_OSC,
-       "Debian");
+       "Debian Project");
 ENUM_NEXT(pen_names, PEN_GOOGLE, PEN_GOOGLE, PEN_DEBIAN,
        "Google");
 ENUM_NEXT(pen_names, PEN_TCG, PEN_TCG, PEN_GOOGLE,
@@ -34,7 +34,7 @@ ENUM_NEXT(pen_names, PEN_TCG, PEN_TCG, PEN_GOOGLE,
 ENUM_NEXT(pen_names, PEN_CANONICAL, PEN_CANONICAL, PEN_TCG,
     "Canonical");
 ENUM_NEXT(pen_names, PEN_FEDORA, PEN_FEDORA, PEN_CANONICAL,
-       "Fedora");
+       "Fedora Project");
 ENUM_NEXT(pen_names, PEN_FHH, PEN_FHH, PEN_FEDORA,
        "FHH");
 ENUM_NEXT(pen_names, PEN_ITA, PEN_ITA, PEN_FHH,