HP-UX IPQoS A.01.00 Programmer's Guide (October 2005)
Code Example
Configuration Code Example
Appendix C54
Configuration Code Example
The following pseudo-code example shows how to use the HP-UX IPQoS API to reserve 50%
bandwidth on lan0 for traffic with destination port numbers in the range of 80-100.
##########
function checkResult(function, result){
if (result != IPQOS_S_SUCCESS){
print “%s returned %d: %s”,
function, result, IpqosStrerror(result);
IpqosAbortSession();
exit;
}
else{
return;
}
}
main(){
/* start a session of type IPQOS_SESSION_CONFIG */
result = IpqosInitSession(IPQOS_API_VERSION_ID_1,NULL,
IPQOS_SESSION_CONFIG)
checkResult(“IpqosInitSession”,result);
/* look for lan0 in adapter list */
result = IpqosGetAdapterListHead(&ipqosAdapter);
while(result != IPQOS_S_LIST_EMPTY){
checkResult(“IpqosGetAdapterListHead/IpqosGetAdapterListNext”,
result);
/* get the name of the adapter and compare with lan0 */
result = IpqosGetAdapterName(ipqosAdapter,&adapterName);
checkResult(“IpqosGetAdapterName”,result);
if (adapterName == “lan0”)
break; /* found it! */
/* continue search */
result = IpqosGetAdapterListNext(&ipqosAdapter);
}
/* did we find lan0 at all? */
if (result == IPQOS_S_LIST_EMPTY){
print “Error: could not find lan0 in API’s adapter list”
exit;