This ticket is for implementing a tunneling API that can be used to tunnel
NUL-terminated strings through the old SaNameT type.
Ticket [#886] and [#873] are for adding support for long DN tunneling in IMM
and NTF, respectively. Ticket [#643] is for adding a new SaStringT based API
to the IMM that will also by default support long DNs.
The tunneling API is defined below:
The SaNameT type is deprecated will be replaced with string parameters in new SAF APIs. As an intermediate solution, the extended format of the SaNameT type can be used to pass string parameters to and from old SAF APIs as well, by tunneling them through the SaNameT type. To enable the extended SaNameT format, the application source code has to be compiled with the SA_EXTENDED_NAME_SOURCE preprocessor macro defined, and the environment variable SA_ENABLE_EXTENDED_NAMES must be set to the value 1 before the first call to any SAF API function.
When the extended SaNameT format is enabled, the SA_MAX_NAME_LENGTH constant must not be used, and the application must treat the SaNameT type as opaque and not access any of its members directly. Instead, the saAisNameLend() and saAisNameBorrow() access functions shall be used. The SA_MAX_UNEXTENDED_NAME_LENGTH constant can be used to refer to the maximum string length that can be stored in the unextended SaNameT type.
#ifdef SA_EXTENDED_NAME_SOURCE
#define SA_MAX_UNEXTENDED_NAME_LENGTH 256
#endif /* SA_EXTENDED_NAME_SOURCE */
#ifdef SA_EXTENDED_NAME_SOURCE
void
saAisNameLend(
SaConstStringT value,
SaNameT* name);
#endif /* SA_EXTENDED_NAME_SOURCE */
value - [in] A pointer to a NUL-terminated string that will be tunneled through the SaNameT type.
name - [out] A pointer to an SaNameT type to be used for tunneling.
Tunnel a NUL-terminated string through a SaNameT type. If length of the string is strictly less than SA_MAX_UNEXTENDED_NAME_LENGTH bytes, the contents of the string is copied into the SaNameT type and can be read in a backwards compatible way by legacy applications that do not support the extended SaNameT format. If length of the string is greater than or equal to SA_MAX_UNEXTENDED_NAME_LENGTH, no copying is performed. Instead, a reference to the original string is stored in the SaNameT type. In this case, it is therefore important that the original string is not modified or freed for as long as the SaNameT type may still used.
#ifdef SA_EXTENDED_NAME_SOURCE
SaConstStringT
saAisNameBorrow(
const SaNameT* name);
#endif /* SA_EXTENDED_NAME_SOURCE */
name - [in] A pointer to an SaNameT type that has been previously set using the saAisNameLend() function.
Retrieve a tunneled string from an SaNameT type. Before calling this function, the SaNameT stucture must have been initialized either by a call to the saAisNameLend() function or by being used as an output parameter of any other SAF API function. If the length of the returned string is strictly less than SA_MAX_UNEXTENDED_NAME_LENGTH bytes, the returned pointer points to a copy of the string stored inside the SaNameT type. Otherwise, the returned pointer is equal to the original string pointer that was passed as a parameter to the saAisNameLend() function.
A pointer to a NUL-terminated string, or a NULL pointer in case of a failure.
Tickets: #1315
Tickets: #1574
Tickets: #1642
Tickets: #1906
Tickets: #191
Tickets: #643
Tickets: #873
Tickets: #886
Tickets: #930
Wiki: NEWS-4.5.0
Migrated from:
http://devel.opensaf.org/ticket/2475
A pair of wrapper functions for packing and unpacking long SaNameT values would also be
needed. This would be provided by he imma library. These functions would pack a string
shorter than 256 bytes in the regular way, but pack a longer string according to the
extended representation.
I have done some prototyping on this - will publish code once I have cleaned it up a bit.
Note that thios is a discussion topic ticket.
Actually doing something about SaNameT is much bigger than a change in IMM.
In the text for this discussion topic I outlined a solution that could be
ïmplemented in the IMM first, that is tranpsarently backwards compatible
for DNs shorter than 256 bytes, and where other services and OpenSAF
applications can be addapted later.
Once a proposal has been prototyped and agreed on, then separate enhancement
tickets should be created for the impacted OpensAF services and this
discussion topic could be closed. I doubt that the entire conversion
for OpenSAF could be accomplished in 4.4
This ticket is a discussion topic. What does it mean to accept it?
I think there should be a new enhancement ticket once this ticket has been used to discuss and agree on the solution to implement.
It was a discussion toppic, but I changed it to an enhancement some weeks ago.
Here is a prototype for long DN support in IMM. It is far from complete - for example I believe there are memory leaks in immutil.c, and thus, in all IMM tools. The patch only adapts the IMM service and tools. No other service has been changed, and thus no other service supports long DNs.
Adapting an application to support long DNs is fairly straight forward. You recompile the application with the preprocessor macro SA_LONGNAME_SOURCE defined, and fix all the resulting compilation errors. That's it.
gcc -DSA_LONGNAME_SOURCE myapp.c
You will get compilation errors at all places where the application is accessing the fiels inside the SaNameT type, or where is it using the SA_MAX_NAME_LENGTH constant. These places have to be fixed. The constant has been removed, so you will need to use e.g. dynamic memory allocation instead of using fixed-size buffers. And instead of accessing the fields inside SaNameT, you need to use the access function saAisNameLend() and saAisNameBorrow(). These functions are used to insert and retrieve a string pointer to/from an SaNameT object.
I have re-based this patch so that it applies on OpenSAF 4.4.RC1. In addition, this new version contains (yet untested) modifications to NTF and SMF, to get a feeling for how difficult it is to adapt these services for long DNs.
Good.
I hope to also provide a first version of an SaStringT based IMM API
(#643 https://sourceforge.net/p/opensaf/tickets/643)
for review quite soon (as soon as we finish 4.4.0). This will be
provided as incremental include files saImmOm_A_2_14.h
and saImmOi_A_2_14.h and be available ofr imm handles initialized with
A.2.14
If and when that is approved in OpenSAF, then providing an
implementation should not be too difficult.
/AndersBj
Anders Widell wrote:
Related
Tickets:
#191Clarification of the scope of this ticket.
This ticket covers only the introduction of the osaf library support
for tunneling long DNs through the SaNameT type.
Currently there is a quite big patch containing a prototype, illustrating
that the proposed solution is relatively easy to introduce on all OpenSAF
services. The goal with that prototype is to get acceptance for the
approach/mechanism.
Assuming that no serious problems or objects surface soon, a new smaller
patch containing only the osaf library support for the SaNameT mechanism
will be sent out, for formal review. If that review gets an ack then that
patch will be pushed.
After this new and separate enhancement tickets should be written per
service. The IMM service would then be among the first to add support
for this mechanism, hopefully in 4.5.
These SaNameT overlaying functions need to be available also to
the applications using OpenSAF services.
I am not sure of the best way to provide that.
Maybe "samples" is the only option ?
That is a good question. In the prototype, I simply wrote them as inline functions in the header file, but that is probably not a good option for the final solution. I can see three alternatives:
Actually samples or immutils will not work because we will be needing to
use these tunneling finctions inside new implementations of the
libSaImmaOm and libSaImmOi. This to support long DNs in the old IMM API.
Amd we cant have a dependency from these to immutils or samples.
Perhaps we can keep them as inline defined functions, say in saAis_B_5_14.h
??
I am planning to add them to libopensaf_core, which can be used by the OpenSAF code itself. In order to make them accessible to applications, we can add wrapper functions in e.g. libSaAis or libSaImmOm, that call the functions in libopensaf_core. Or we can put a copy of them in immutils.
Inline functins is one possibility, but I put a question mark on the legal aspect. I am not fully sure what that would mean from a licensing perspective. Though it should be no different than the C++ standard library, which also has a lot of inline code. Need to check it first, though.
Yes I suppose we could (perhaps even should) keep these SaNameT tunneling
primitives as a pure OpenSAF enhancement (not SAF).
This also means that the support for long DNs in the old SaNameT based APIs
will be an OpenSAF feature.
But supporting long DNs via the new SaStringT/SaConstrStringT API should be
kept compatible with being adopted by SAF in the future.
This distinction may be academic at this point in time, but I still think we
should keep the conceptual domains (and naming domains) clear.
Diff:
Prototype re-based and updated to use the patches sent out for review.
Diff:
Re-based the prototype to changeset f1f2eebd6019e56adc41fb69182d2678e4751150