[strongSwan-dev] How to print struct

Martin Willi martin at strongswan.org
Tue Jul 15 14:19:17 CEST 2014


> > How can I "convert" a struct (identification_t) to its char array 
> > representation? 
> 
> The identification_t class has a get_encoding() getter method

Forgot to add: get_encoding() returns a raw binary blob of the exchanged
identification payload, having arbitrary bytes. For Distinguished Names,
this is raw ASN.1 DER encoding. The IKE identification type can be
queried using the get_type() method.

To get the human readable string representation of the identity, just
print it to a string buffer.

> char buf[256];
> snprintf(buf, sizeof(buf), "%Y", id);

Regards
Martin



More information about the Dev mailing list