]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Added identification constructor using a chunk of data, guessing id type
authorMartin Willi <martin@strongswan.org>
Thu, 29 Oct 2009 14:52:00 +0000 (15:52 +0100)
committerMartin Willi <martin@strongswan.org>
Thu, 12 Nov 2009 09:34:01 +0000 (10:34 +0100)
src/libstrongswan/utils/identification.c
src/libstrongswan/utils/identification.h

index f123991152c25ad33694b7c64091923782f090cc..abdae6e075fe7dfc1460e2ce50ba7700ccdd5e0f 100644 (file)
@@ -1005,6 +1005,18 @@ identification_t *identification_create_from_string(char *string)
        }
 }
 
+/*
+ * Described in header.
+ */
+identification_t * identification_create_from_data(chunk_t data)
+{
+       char buf[data.len + 1];
+
+       /* use string constructor */
+       snprintf(buf, sizeof(buf), "%.*s", data.len, data.ptr);
+       return identification_create_from_string(buf);
+}
+
 /*
  * Described in header.
  */
index f619d0c44991bba46b32b9ec93887b8ff320e318..fe5c7d0fd131d63c7241d7263f27eda59e4396f5 100644 (file)
@@ -314,6 +314,14 @@ struct identification_t {
  */
 identification_t * identification_create_from_string(char *string);
 
+/**
+ * Creates an identification from a chunk of data, guessing its type.
+ *
+ * @param data         identification data
+ * @return                     identification_t
+ */
+identification_t * identification_create_from_data(chunk_t data);
+
 /**
  * Creates an identification_t object from an encoded chunk.
  *