Table of Contents

Name

ULLA (Unified Link Layer API) - access link layer information

Synopsis

#include <ulla/lu.h>

ullaResultCode_t ullaTupleNext(const ullaTupleId_t utId);
ullaResultCode_t ullaTupleFieldCount(const ullaTupleId_t utId, ullaFieldNum_t *fieldCount);

ullaResultCode_t ullaFieldNameLength(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaStringLen_t *fieldNameLen);
ullaResultCode_t ullaFieldName(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaString_t fieldName, ullaStringLen_t *fieldNameLen);
ullaResultCode_t ullaFieldStatus(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaResultCode_t *fieldStatus);

Additional accessor functions for ullaRequestAttribute, ullaRequestCommand, ullaRequestSample, ullaRequestNotification
ullaResultCode_t ullaFieldTimestamp(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaTime_t *timestamp, ullaTime_t *now);

Additional accessor functions for ullaRequestAttribute, ullaRequestCommand, ullaRequestSample, ullaRequestNotification
ullaResultCode_t ullaFieldType(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaType_t *fieldType);
ullaResultCode_t ullaFieldValueLength(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaStringLen_t *fieldLen);
ullaResultCode_t ullaFieldValueToInt(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaInteger_t *fieldValue);
ullaResultCode_t ullaFieldValueToString(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaString_t fieldValue, ullaStringLen_t *fieldValueLen);

Additional accessor functions for ullaRequestReflection
ullaResultCode_t ullaFieldModifier(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaModifier_t *modifier);
ullaResultCode_t ullaFieldDescriptionLength(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaStringLen_t *descriptionLen);
ullaResultCode_t ullaFieldDescription(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaString_t description, ullaStringLen_t *descriptionLen);
ullaResultCode_t ullaFieldMin(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaInteger_t *min);
ullaResultCode_t ullaFieldMax(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaInteger_t *max);
ullaResultCode_t ullaFieldValueSetLength(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaStringLen_t *valueSetLen);
ullaResultCode_t ullaFieldValueSet(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaString_t valueSet, ullaStringLen_t *valueSetLen);
ullaResultCode_t ullaFieldUnitLength(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaStringLen_t *unitLen);
ullaResultCode_t ullaFieldUnit(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaString_t unit, ullaStringLen_t *unitLen);
ullaResultCode_t ullaFieldParameterLength(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaStringLen_t *ParameterLen);
ullaResultCode_t ullaFieldParameter(const ullaTupleId_t utId, const ullaFieldNum_t fieldNum, ullaString_t parameter, ullaStringLen_t *parameterLen);

Description

In order to access the data from the ULLA result, the Link User (LU), or application using ULLA, can utilize the accessor functions. The ULLA result is structured using tuples and fields. Using a tupleId the LU can iterate over the "rows" in the ullaResult. The method ullaTupleNext allows to increment the tupleId to access the next tuple in the ullaResult.

Each tuple within the same ullaResult has as the same number of fields, according to the uql_statement used. The number of fields can be retrieved using the ullaTupleFieldCount method. The order of the attribute or command names in the uqp_statement determines the order the data is stored into the ULLA result fields.

All further functions work based on a combination of utId and fieldNum in order to address a specific field in the ullaResult. Please look at the individual descriptions of these so-called "accessor-functions". All xxxLength functions are indicating the amount of bytes used for a string. This does include the trailing \0 at the end of the string.

Another specific function is the ullaFieldStatus method. It is possible to verify the status of the field data is ok. In the case of an ullaResult from a ullaRequestAttribute call the attribute data might not be available at all times. In this case the status indicates the corresponding error code (see below). In the case of an ullaResult from an ullaRequestCommand call the status indicates the success of the command execution of a specific command in the select_clause of the uql_statement.

ullaTupleNext is used to increment the ULLA Core internal tuple pointer to the next tuple of the same ullaResult. Before getting any information from the ullaTuple, this functions needs to be called to access the first tuple.

ullaTupleFieldCount returns the number of fields within all tuples of the same ullaResult.

Using ullaFieldName and ullaFieldNameLength the LU can verify that the name of the data field matches the one in the query. The position of the data value is subsequently the same as in the select clause of the query.

ullaFieldTimestamp returns the current timestamp and the timestamp the field was filled by the LLA.

ullaFieldType returns the ULLA-type of the field data according to the type-specific accessor functions (see below).

ullaFieldValueLength returns the number of bytes required to hold the data of the field.

ullaFieldValueToInt is a type-specific accessor function that works on field containing an ulla_integer_t value. It casts the value to int and copies the data to the pre-allocates location.

ullaFieldValueToString is a type-specific accessor function that works on field containing an ulla_string_t value. It casts the value to int and copies the data to the pre-allocates location.

The following accessor functions are used only for the reflection interface:

ullaFieldModifier returns the ULLA-modifier of the attribute.

ullaFieldDescription and ullaFieldDescriptionLength return the description of the attribute according to the attribute semantics.

ullaFieldMin and ullaFieldMax are valid for ulla_integer_t attributes and return the minimum and maximum value the attribute data can have.

ullaFieldValueSet and ullaFieldValueSetLength in case there is a specific list of possible values the attribute data can have, this list can be retrieved by the means of these two functions.

ullaFieldUnit and ullaFieldUnitLength describe the unit of the attribute value.

ullaFieldParameter and ullaFieldParameterLength are valid if the field describes a command. The list of attributes, which are parameters to this command are listed by these two functions.

Parameters

The following parameters have to be carefully considered:

utId 
handle to iterate over the "rows" of the ullaResult. The LU may chose to create multiple utId handles on the same ullaResult.
fieldCount 
number of fields within a tuple.
fieldNum 
index of the addressed field within a specified tuple.
fieldName 
name of the field according to the attribute or command name used in the uql_statment.
fieldNameLen 
length of the field name in bytes including the trailing \0.
fieldStatus 
status of the field data. This is filled by the ULLA Core as the result code of the function call on the LLA.
timestamp 
point of time when the field data was valid.
now 
reference timestamp. It gives the point of time the ullaFieldTimestamp function call was issued.
type 
type of the field data according to the ullaType_t.
fieldLen 
and fieldValueLen  are the number of bytes required to hold the field data.
fieldValue 
field value according to the fieldType.
modifier 
is the modifier of the attribute data (read, write or read-write).
description 
is the semantic description of the attribute or command.
descriptionLen 
is the length of the attribute or command description.
min 
is the minimum value for this attribute or command value.
max 
is the maximum value for this attribute or command value.
valueSet 
is a list of possible values this attribute or command can return.
valueSetLen 
is a length of the valueSet.
unit 
is unit of the attribute data.
unitLen 
is a length of the unit.
parameter 
is the list of parameters for a command.
parameterLen 
is a length of the parameter description.

Return Vallue

ULLA_OK
everything is fine.

ULLA_NO_MEMORY
everything is fine.

ULLA_NO_MEMORY
ran out of user space or kernel space RAM memory.

ULLA_INSUFICIENT_MEMORY
ran out of user space RAM memory.

ULLA_ERROR_IN_VALUE
a parameter is syntactically or semantically incorrect.

ULLA_ERROR_FAULT
general error occured.

ULLA_NOT_SUPPORTED
field status might have this error code. If the tables listed in the uql_statment do not contain the specific attribute or command this error code is set.

ULLA_ATTRIBUTE_NOT_AVAILABLE
field status might have this error code. If the LLA was not able to provide the data value of the attribute or, in the case of commands, was unable to execute the command at that point of time the field status is set to ULLA_ATTRIBUTE_NOT_AVAILABLE.

ULLA_SEGMENTATION_FAULT
ULLA Core implementation error.

ULLA_CORE_NOT_PRESENT
the ULLA Core kernel module cannot be loaded.

ULLA_BUG
ULLA Core implementation bug.

ULLA_NO_MORE_TUPLES_ERROR
if the ullaTupleNext function cannot increment to the next tuple in the ullaResult because the final tuple has been reached this error code is returned to the LU.

ULLA_FIELD_VALUE_ERROR
field value cannot be retrieved due to bad field status.

ULLA_ERROR_LOCKED
if an attribute was to be set, or a command was to be excuted, which is locked by some other LU, the field status is set to ULLA_ERROR_LOCKED.

Examples

Some examples for the usage of accessor-functions on an ullaResult:

How-to extract all integer field values from an ullaResults?

#include <ulla/lu.h>
ullaResultId_t urId;
ullaTupleId_t utId;
ullaFieldNum_t i, count;
ullaType_t type;
ullaInteger_t integer;

if( (res = ullaResultTuple(urId, &utId)) < 0) {
/* failed to access tuples from ullaResult */

/* verify status of the ullaResult if shared among threads */

}

while(ullaTupleNext(utId) != ULLA_NO_MORE_TUPLES_ERROR) {
if( (res = ullaFieldCount(utId, &count)) < 0) {

/* failed to get field count */

}

for(i=0; i<count; i++) {

if( (res = ullaFieldType(utId, i, &type)) < ) {

/* failed to get field type */
}

if( type == ULLA_TYPE_INTEGER ) {

if( (res = ullaFieldValueToInt(utId, i, &integer)) < 0) {

/* failed to cast field data to ulla_integer_t */

}

printf("extracted integer value %i\n", integer);

}

}

}

ullaResultFree(urId);

See Also

ullaReflection(1) , ullaAttribute(1) , ullaCommand(1) , ullaSample(1) , ullaNotification(1) , ullaTools(1)

ulla(2) , uql(2) , ullaResult(2) , ullaTuple(2) , ullaRequestReflection(2) , ullaRequestAttribute(2) , ullaRequestCommand(2) , ullaRequestNotification(2) , ullaRequestSample(2) , ullaRequestLock(2) , ullaGetCoreDescriptor(2)

Conforming to

RWTH contribution to the GOLLUM project (http://www.ist-gollum.org). Compliant with ULLA C-API Version 1.0 (http://ulla.sourceforge.net).

Author

This man page was written by Marten Bandholz (mba@mobnets.rwth-aachen.de).


Table of Contents