> On Feb 28, 2020, at 11:49 AM, Ole Troan <otr...@employees.org> wrote:
> 
> Christian,
> 
> OK, can update to
> #define IPSEC_API_SEMVER 3002001 /* MMMmmmppp */
> 
> Just to be clear,
> you don't use this on the VPP side, but on the client side right?

Correct, it's for things like supporting VPP as an option in other open source 
projects like strongswan.

> So if VAPI client wrapper provided this define, that would be fine too?

I could include the vapi header to get to the define, sure.

[ I don't actually use VAPI in my stuff b/c I don't want to have to define 
callbacks for every sync API function I use. :) ]

Thanks,
Chris.

> 
> Cheers,
> Ole
> 
>> On 28 Feb 2020, at 16:56, Christian Hopps <cho...@chopps.org> wrote:
>> 
>> This would be great, but how about these defines get generated (e.g., for 
>> ipsec.api with version "3.2.1")
>> 
>> #define IPSEC_API_SEMVER_MAJOR 3
>> #define IPSEC_API_SEMVER_MINOR 2
>> #define IPSEC_API_SEMVER_FIX   1
>> #define IPSEC_API_SEMVER 3002001 /* MMMmmmppp */
>> 
>> The last define is all that's really needed though.
>> 
>> Then one can do this in code:
>> 
>> #if (IPSEC_API_SERVER < 4000000) && (IPSEC_API_SEMVER >= 3002000)
>> 
>>   /* use an API introduced in ipsec.api verion 3.2.0 */
>> 
>> #elif (IPSEC_API_SERVER >= 4000000) && (IPSEC_API_SERVER < 5000000)
>> 
>>   /* use the same API call whose definition changed in 4.0.0 */
>> 
>> #else
>> #error code only supports VPP ipsec.api between 3.2.0 and 4.x.x
>> #endif
>> 
>> The other defines just make this a little cleaner looking:
>> 
>> #if IPSEC_API_SERVER_MAJOR == 3 && IPSEC_API_SEMVER_MINOR >= 2
>> 
>>   /* use an API introduced in ipsec.api verion 3.2.0 */
>> 
>> #elif IPSEC_API_SERVER_MAJOR == 4
>> 
>>   /* use the same API call whose definition changed in 4.0.0 */
>> 
>> #else
>> #error code only supports VPP ipsec.api between 3.2.0 and 4.x.x
>> #endif
>> 
>> Thanks,
>> Chris.
>> 
>>> On Feb 28, 2020, at 7:36 AM, otr...@employees.org wrote:
>>> 
>>> Christian,
>>> 
>>>> How does one conditionally compile code based on the API version? I was 
>>>> looking for a compile time conditional I could then use #if's with, but I 
>>>> can't seem to find one. A release version #define would work too, although 
>>>> not be as nice as the per file semver one.
>>>> 
>>>> I did find these are generated:
>>>> 
>>>> #ifdef vl_api_version_tuple
>>>> vl_api_version_tuple(ipsec.api, 3, 0, 0)
>>>> #endif /* vl_api_version_tuple */
>>>> 
>>>> but I dont know how to utilize this during CPP in an #if conditional
>>> 
>>> that functions is used like this:
>>> #define vl_api_version_tuple(n,mj, mi, p) \
>>> vl_msg_api_add_version (am, #n, mj, mi, p);
>>> #include <vpp/api/vpe_all_api_h.h>
>>> #undef vl_api_version_tuple
>>> 
>>> But if you want a simple define to use I can trivially add something like:
>>> #define <MODULE>_SEMVER 1
>>> 
>>> Could go in <module>.api_types.h
>>> 
>>> Cheers,
>>> Ole
>> 
> 
> 

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#15625): https://lists.fd.io/g/vpp-dev/message/15625
Mute This Topic: https://lists.fd.io/mt/71604387/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to