Using the HP-UX IPQoS API

Using Lists

To obtain the next object in a list, use the following functions: IpqosGetAdapterListNext(), IpqosGetPolicyListNext(), IpqosGetFilterListNext(). These functions return IPQOS_LIST_EMPTY if the end of the list has been reached, that is, there is no such object.

Functions exist that count the number of items in a list. To obtain the count, use the following functions: IpqosGetFilterListCount(), IpqosGetPolicyListCount() and IpqosGetAdapterListCount().

Code Example: Traversing An Adapter List

The following code sample illustrates one way to traverse an adapter list. In this example, the count value determines the loop.

The example uses a function QosError(), which terminates the program gracefully after reporting the error. Note that this function is shown for illustrative purposes as part of the example, it is not part of the HP-UX IPQoS API. If you want to use a similar function in your programs, you will need to create one.

IpqosAdapter ipqosAdaptr;

...

result = IpqosGetAdapterListHead(&ipqosAdaptr); while (true)

(

uint32_t pcount;

if (result == IPQOS_S_LIST_EMPTY) break;

if (result != IPQOS_S_SUCCESS) QosError(__FILE__, __LINE__, result);

result = IpqosGetPolicyListCount(ipqosAdaptr, &pcount); if (result != IPQOS_S_SUCCESS)

QosError(__FILE__, __LINE__, result);

if (pcount > 0) //The adapter’s policy list is not empty

...<do something with the policy list here>...

}

result = IpqosGetAdapterListNext(&ipqosAdaptr); if (result != IPQOS_S_SUCCESS &&

result != IPQOS_S_LIST_EMPTY) QosError(__FILE__, __LINE__, result);

}

28

Chapter 2