Discussion:
[strongSwan-dev] Working of format specifiers in DBG
Anand Murali
2017-01-13 05:46:37 UTC
Permalink
Hi,


I have been going through the source code of strongswan.


I came across lots of custom format specifiers like:


DBG1(DBG_ENC, "U_INT Type %N is not supported",
encoding_type_names, int_type);

DBG2(DBG_CFG, "received proposals: %#P", proposals);


I'm new to this. Have been going through this code for a week. I'm not able to figure out how these are evaluated.


Any help to understand how these are evaluated?


If there is an internal code that does this parsing, can you point me to that file?


Thanks
Andreas Steffen
2017-01-13 14:01:09 UTC
Permalink
Hi Anand,

strongswan uses standard libc printf hooks if they are available.
Otherwise vstr is used to emulate printf hooks. The strongSwan
printf_hook_t framework is defined here:

https://git.strongswan.org/?p=strongswan.git;a=tree;f=src/libstrongswan/utils/printf_hook;h=2c506f08bef7aa1953a2f138f4d649843d181fb6;hb=HEAD

E.g. the printf_hook handler for %N (printing of enum_name_t types) is
defined here:

https://git.strongswan.org/?p=strongswan.git;a=blob;f=src/libstrongswan/utils/enum.c;h=1cead77cae75bc9de50abf118f259e3e283663e9;hb=9ad147ac63df03740a156fd1f3b017ef1d0e89ae#l137

and the all hooks used by libstrongswan are assigned here:

https://git.strongswan.org/?p=strongswan.git;a=blob;f=src/libstrongswan/library.c;h=4f79dcc5b12f7601ff2df4c5ad319108f3e60476;hb=9ad147ac63df03740a156fd1f3b017ef1d0e89ae#l338

Hope this helps

Andreas
Post by Anand Murali
Hi,
I have been going through the source code of strongswan.
DBG1(DBG_ENC, "U_INT Type *%N* is not supported",
encoding_type_names, int_type);
DBG2(DBG_CFG, "received proposals: *%#P*", proposals);
I'm new to this. Have been going through this code for a week. I'm not
able to figure out how these are evaluated.
Any help to understand how these are evaluated?
If there is an internal code that does this parsing, can you point me to that file?
Thanks
======================================================================
Andreas Steffen ***@strongswan.org
strongSwan - the Open Source VPN Solution! www.strongswan.org
Institute for Internet Technologies and Applications
University of Applied Sciences Rapperswil
CH-8640 Rapperswil (Switzerland)
===========================================================[ITA-HSR]==
Loading...