From: Martin Willi Date: Thu, 29 Oct 2009 14:52:00 +0000 (+0100) Subject: Added identification constructor using a chunk of data, guessing id type X-Git-Tag: 4.3.6~214 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=324528700d98ae6062845e64461c606d540ab616;p=thirdparty%2Fstrongswan.git Added identification constructor using a chunk of data, guessing id type --- diff --git a/src/libstrongswan/utils/identification.c b/src/libstrongswan/utils/identification.c index f123991152..abdae6e075 100644 --- a/src/libstrongswan/utils/identification.c +++ b/src/libstrongswan/utils/identification.c @@ -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. */ diff --git a/src/libstrongswan/utils/identification.h b/src/libstrongswan/utils/identification.h index f619d0c449..fe5c7d0fd1 100644 --- a/src/libstrongswan/utils/identification.h +++ b/src/libstrongswan/utils/identification.h @@ -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. *