Solaris Bandwidth Manager 1.6 Developer Guide

Chapter 4 C Statistics API Reference

This chapter contains reference material for the functions defined by the C Statistics API. Functions are arranged in alphabetical order. For information about using the C Statistics API refer to Chapter 3, Using the C Statistics API.

ba_close()

Name

ba_close() -- close driver file and reset event mask

Synopsis

#include <netinet/ba_stat.h>

int ba_close();

Description

The function ba_close() closes the driver file /dev/ipqos and resets the event mask to its default value (0). The file is reopened automatically by the next function call through the C Statistics API.

Returns

The function ba_close() returns 0 on success, and -1 on error.

Errors

If an error occurs during a call to ba_close(), the variable ba_errno is set to:

BA_SYSERR

OS error: check errno 

ba_decode_ifname()

Name

ba_decode_ifname() -- extract physical interface name and direction

Synopsis

#include <netinet/ba_stat.h>

int ba_decode_ifname(
   const char *ifname; /*bandwidth manager interface name*/
   char *interface; /*physical interface*/
   uint_t direction; /*traffic direction*/
  );

Description

The function ba_decode_ifname() extracts the physical interface name interface and the direction of traffic handled by the interface from the Solaris Bandwidth Manager interface name ifname. For example, if ifname contains le0_in, the interface is le0 and the direction is BA_DIR_INCOMING.

Arguments

The function ba_decode_ifname() is passed the following arguments:

ifname

Pointer to a character string that contains the encoded interface name, for example le0_in.

interface

Pointer to the decoded physical interface name. Be sure to allocate sufficient memory. 

direction

Pointer to the decoded direction. 

Returns

The function ba_decode_ifname() returns the number of characters written on success, and -1 on error.

Errors

If an error occurs during a call to ba_decode_ifname(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_disable_signal()

Name

ba_disable_signal() -- disables the signalling mechanism

Synopsis

#include <netinet/ba_stat.h>

	int ba_disable_signal();

Description

The function ba_disable_signal() disables the signalling mechanism that is used by the ipqos module to send signals directly to the user process.

Returns

The function ba_disable_signal() returns 0 on success, and -1 on error.

Errors

If an error occurs during a call to ba_disable_signal(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_enable_signal()

Name

ba_enable_signal() -- enables the signalling mechanism

Synopsis

#include <netinet/ba_stat.h>

	int ba_enable_signal (
		int signo
);

Description

The function ba_enable_signal() enables the signalling mechanism that is used by the ipqos module to send signals directly to the user process.


Note -

When using the signal(3C) library calls, some signals may be lost if two signals are sent at the same time. In your signal handler, always check that all pending events have been processed before returning.


Arguments

The function ba_enable_signal() is passed the following argument:

signo

Integer signal value. See signal(5) for a list of the current valid values for signo.

Returns

The function ba_enable_signal() returns 0 on success, and -1 on error.

Errors

If an error occurs during a call to ba_enable_signal(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_encode_ifname()

Name

ba_encode_ifname() -- build a Solaris Bandwidth Manager interface name

Synopsis

#include <netinet/ba_stat.h>

int ba_encode_ifname(
   const char *interface; /*interface name*/
   const uint_t direction; /*traffic direction*/
   char *ifname;
);

Description

The function ba_encode_ifname() builds the interface name ifname from the physical interface name interface and the direction of traffic handled by the interface. For example, if interface is leo and direction is BA_DIR_INCOMING, ifname contains le0_in.

Arguments

The function ba_encode_ifname() is passed the following arguments:

interface

Pointer to a character string that contains the name of the managed interface. For example, le0, hme0.

direction

An integer indicating the interfaces direction- one of BA_DIR_INCOMING or BA_DIR_OUTGOING.

ifname

Pointer to the encoded interface name. Be sure to allocate sufficient memory. 

Returns

The function ba_encode_ifname() returns the number of characters written on success, and -1 on error.

Errors

If an error occurs during a call to ba_encode_ifname(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_free()

Name

ba_free() -- free memory assigned to buffer

Synopsis

#include <netinet/ba_stat.h>

void ba_free (int *ptr);

Description

The function ba_free() frees the specified buffer. It is equivalent to the system function free(). The buffer must have been allocated by one of the following functions: ba_list_interface_config(), ba_list_classes() or ba_get_flow_stats().

Arguments

The function ba_free() is passed the following argument:

ptr

A pointer to the buffer to be freed 

ba_get_class_stats()

Name

ba_get_class_stats() -- retrieve statistics for a given class

Synopsis

#include <netinet/ba_stat.h>

int ba_get_class_stats (
	const char *interface,
	const char *classname,
	ba_class_stats_t *stats
);

Description

The function ba_get_class_stats() retrieves statistics information about a given class for a given managed interface. It returns the following information:

Arguments

The function ba_get_class_stats() is passed the following arguments:

interface

Pointer to a character string that contains the name of the managed interface. For example, le0, hme0. To specify the direction for which you want class information, append _in or _out to the interface name. If you do not specify the direction, it is assumed to be _out.

classname

Pointer to a character string that contains the class name. 

stats

Pointer to a structure of type ba_class_stats_t. This is the buffer into which statistics for the specified class are written.

Structures of type ba_class_stats_t are defined as follows:

typedef struct {
   ba_name_t   interface; /* name and direction of the interface */
   ba_name_t   classname; /* name of the class */
   u_int       npackets; /* packets sent in this class */
   u_int       nbytes; /* bytes sent in this class */
   u_int       borrows; /* # times tried to borrow */
   u_int       drops; /* packets dropped */
   u_int       bdrops; /* bytes dropped */
   hrtime_t    lastseen; /* timestamp of last packet sent */
*/
} ba_class_stats_t;

You must allocate sufficient memory for the buffer, either statically or dynamically. For example:

/* static allocation */
{
	class_stats_t stats;
	
	if (ba_get_class_stats("hme0", "root", &stats) != -1) {
		printf("Number of bytes sent: %d\n", stats.nbytes);
	} else {
		/* error handling */
	}
}

/* dynamic allocation */
{
	class_stats_t *statsp;
	
	statsp = (class_stats_t *) malloc(sizeof class_stats_t);
	if (ba_get_class_stats("hme0", "root", statsp) != -1) {
		printf("Number of bytes sent: %d\n", statsp->nbytes);
	} else {
		/* error handling */
	}
}

Returns

The function ba_get_class_stats() returns 0 on success, and -1 on error.

Errors

If an error occurs during a call to ba_get_class_stats(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_get_event_mask()

Name

ba_get_event_mask() -- get event mask

Synopsis

#include <netinet/ba_stat.h>

int ba_get_event_mask();

Description

The function ba_get_event_mask() gets the current event mask.

Returns

The function ba_get_event_mask() returns the event mask on success, and -1 on error.

Errors

If an error occurs during a call to ba_set_event_mask(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_get_flow_stats()

Name

ba_get_flow_stats() -- retrieve statistics for flows in a given class

Synopsis

#include <netinet/ba_stat.h>

int ba_get_flow_stats (
	const char *interface,
	const char *classname,
	ba_flow_stats_t **flow_stats
);

Description

The function ba_get_flow_stats() retrieves statistics information about the flows associated with a given class for a given managed interface.

Arguments

The function ba_get_flow_stats() is passed the following arguments:

interface

Pointer to a character string that contains the name of the managed interface. For example, le0, hme0. To specify the direction for which you want class information, append _in or _out to the interface name. If you do not specify the direction, it is assumed to be _out.

classname

Pointer to a character string that contains the class name. 

flow_stats

Pointer to a structure of type ba_flow_stats_t. This is the buffer into which statistics for the flows are written.

Structures of type ba_flow_stats_t are defined as follows:

typedef struct {
	 ba_name_t   interface; /* name and direction of the interface */
	 ba_name_t   classname; /* name of the class */
	 struct      in_addrip_local; /* local IP address */
	 struct      in_addrip_remote; /* remote IP address */
	 uchar_t     protocol; /* protocol */
	 ushort_t    port_local; /* localport number */
	 ushort_t    port_remote; /* remoteport number */
	 uchar_t     tos_sent; /* TOS value */
	 uint_t      npackets; /* number of incoming packets */
	 uint_t      nbytes /* number of incoming bytes */
	 union {
         uchar_t        *url;
         u_longlong_t   url_pad;
} url_union;
  hrtime_t    firstseen /* timestamp of first packet sent */
  hrtime_t    lastseen /* timestamp of last packet sent */

} ba_flow_stats_t;
#define   ba_flow_url   url_union.url

Returns

The function ba_get_flow_stats() returns 0 on success, and -1 on error.

Errors

If an error occurs during a call to ba_get_flow_stats(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_get_interface_config()

Name

ba_get_interface_config() -- retrieve the interface configuration information

Synopsis

#include <netinet/ba_stat.h>

int ba_get_interface_config(
	 const char *interface /*interface name*/
	 ba_interface_t *config /*configuration information*/
);

Description

The function ba_get_interface_config() retrieves the configuration information for the specified interface.

Arguments

The function ba_get_interface_config() is passed the following argument:

interface

Pointer to a character string that contains the name of the managed interface. For example, le0, hme0.

Structures of type ba_interface_t are defined as follows:

typedef struct {
	ba_name_t					name_suffix;
	uint_t					activate;
	uint_t					rate;
} ba_interface_t;

Where suffix is either in to indicate that the interface handles incoming traffic, or out to indicate that it handles outgoing traffic.

Returns

The function ba_get_interface_config() returns 0 on success, and -1 on error.

Errors

If an error occurs during a call to ba_get_interface_config(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_get_next_event()

Name

ba_get_next_event() -- retrieve information about events

Synopsis

#include <netinet/ba_stat.h>

int ba_get_next_event (
	ba_event_t *event,
	int blocking
);

Description

The function ba_get_next_event() retrieves information about the next event queued in the FIFO buffer. It can be called in either blocking or non-blocking mode:

Arguments

The function ba_get_next_event() is passed the following arguments:

event

Pointer to a structure of type ba_event_t, which contains information about the next event in the FIFO buffer.

blocking

Integer that sets blocking or non-blocking mode. A zero value enables blocking; any non-zero value enables non-blocking. 

Structures of type ba_event_t are defined as follows:

typedef struct {
	u_int           ba_event_type;
	u_int           ba_event_drops;

union {
      	ba_name_t       ba_event_iface;
      ba_name_t       ba_event_info;
      } ba_event_config;
      struct {
             ba_name_t     ba_flow_iface; /* no suffix */
             uint_t        ba_num_flows;
             ba_flow_event_t
ba_event_flows[BA_EVENT_MAX_FLOWS];
               } ba_event_flow;
               ba_class_stats_t   ba_event_stats;
               ba_filter_event_t  ba_event_filter;
               ba_cl_filter_event_tba_event_cl_filter;
       } ba_event_union;
} ba_event_t;

The elements of structures of type ba_event_t are set as follows:

ba_event_type

Set to identify the event type that has occurred. See Table 3-1 for possible values.

ba_event_iface

Set to identify the interface on which the event has occurred. It is set to the name of the reconfigured interface for events of type BA_EVENT_CONFIG_STARTING and BA_EVENT_CONFIG_ENDING. It is left blank for events of type BA_EVENT_DAEMON_ENDING.

ba_event_info

Reserved for future use. 

Structures of type ba_flow_event_t are defined as follows:

typedef struct {
     ba_name_t       classname_in; 
     ba_name_t       classname_out;
     struct in_addr  ip_local;
     struct in_addr  ip_remote;
     uchar_t         protocol;
     ushort_t        port_local;
     ushort_t        port_remote;
     uchar_t         tos_sent_in;
     uchar_t         tos_sent_out;
     uint_t          npackets_in;
     uint_t          nbytes_in;
     uint_t          npackets_out;
     uint_t          nbytes_out;
     uint_t          url_length;
     union {
             uchar_t         *url;
             u_longlong_t    url_pad;} url_union;
     hrtime_t   firstseen_in; /* timestamp of first packet sent (ns)*/
     hrtime_t   lastseen_in;  /* timestamp of last packet sent (ns) */
     hrtime_t   firstseen_out;/* timestamp of first packet sent (ns)*/
     hrtime_t   lastseen_out; /* timestamp of last packet sent (ns) */
} ba_flow_event_t;

#define ba_flow_url     url_union.url

Returns

The function ba_get_next_event() returns 0 on success, and -1 on error.

Errors

If an error occurs during a call to ba_get_next_event(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_get_num_classes()

Name

ba_get_num_classes() -- retrieve the number of classes for a managed interface.

Synopsis

#include <netinet/ba_stat.h>

int ba_get_num_classes (
	 const char *interface 	 /* interface name*/
);

Description

The function ba_get_num_classes() retrieves the number of configured classes per managed interface.

Arguments

The function ba_get_num_classes() is passed the following argument:

interface

Pointer to a character string that contains the name of the managed interface. For example, le0, hme0. To specify the direction for which you want class information, append _in or _out to the interface name. If you do not specify the direction, it is assumed to be _out.

Returns

The function ba_get_num_classes() returns the number of classes on success, and -1 on error.

Errors

If an error occurs during a call to ba_get_num_classes(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_get_num_interfaces()

Name

ba_get_num_interfaces() -- retrieve the number of managed interfaces

Synopsis

#include <netinet/ba_stat.h>

int ba_get_num_interfaces();

Description

The function ba_get_num_interfaces() retrieves the total number of interfaces that the policy agent has been configured to manage.

Returns

The function ba_get_num_interfaces() returns the number of interfaces on success, and -1 on error.

Errors

If an error occurs during a call to ba_get_num_interfaces(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_list_class_names()

Name

ba_list_class_names() -- retrieve the names of classes for a managed interface

Synopsis

#include <netinet/ba_stat.h>

int ba_list_class_names (
	const char *interface,	/* interface name: le0, hme0, ... */
	ba_class_pair_t *classes	/* allocate buffer */
);

Description

The function ba_list_class_names() retrieves a list of the names of all configured classes and their respective parents for a given managed interface. The parent of the root class is root.

Arguments

The function ba_list_class_names() is passed the following arguments:

interface

Pointer to a character string that contains the name of the managed interface (for example, le0, hih0, or hme0).

classes

Pointer to an array of structures of type ba_class_pair_t, which is the buffer into which the names of the classes are written. There is one structure per class/parent pair.

Structures of type ba_class_pair_t are defined as follows:

typedef struct {
	ba_name_t       parent;   /* name of the parent */
	ba_name_t       child;    /* name of the class */
} ba_class_pair_t;

Structures of type ba_class_pair_t contain a pair of structures of type ba_name_t, which are defined as follows:

typedef struct {
	char    name[BA_NAMES_LEN + 1];
	char    padding[3];
	u_short namelen;
	char    padding2[2];
} ba_name_t;

You must always allocate sufficient memory for the buffer, the size of which is dependent on the number of classes. For example:

int nclasses;
ba_class_pairs_t *classesp;

nclasses = ba_get_num_classes("hme0");
if (nclasses > 0) {
	classesp = (ba_class_pairs_t *) calloc(nclasses,sizeof ba_class_pairs_t);
	if (ba_list_class_names("hme0", classesp) != -1) {
		/* process classesp ... */
	} else {
		/* error handling */
	}
	free(classesp);
}

Returns

The function ba_list_class_names() returns 0 on success, and -1 on error.

Errors

If an error occurs during a call to ba_get_list_class_names(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_list_classes()

Name

ba_list_classes() -- retrieve child classes for a specified class

Synopsis

#include <netinet/ba_stat.h>

int ba_list_classes (
	 const char *interface_suffix /* interface name */
  const char *classname /* class name */
  ba_class_pair_t **classes /* array containing information requested */
);

Description

The function ba_list_classes() retrieves a list of the names of the parent and child classes of the class you specified. These are returned in an array of parent-child pairs and include the name of the class you specified. The parent of the root class is root.

Arguments

The function ba_list_classes() is passed the following arguments:

interface

Pointer to a character string containing the name of the managed interface, for example le0_suffix, hme0_suffix, where suffix is one of in, indicating that the interface carries incoming traffic, or out, indicating that the interface carries outgoing traffic.

classname

Pointer to a character string containing the name of the class for which information is required. 

classes

Pointer to an array of structures of type ba_class_pair_t, containing the parent and child class names. There is one structure per parent child pair.

Memory is allocated automatically. You must call ba_free() when the memory is no longer required.

Structures of type ba_class_pair_t are defined as follows:

typedef struct {
	ba_name_t       parent;   /* name of the parent */
	ba_name_t       child;    /* name of the class */
} ba_class_pair_t;

Structures of type ba_class_pair_t contain a pair of structures of type ba_name_t, which are defined as follows:

typedef struct {
	char    name[BA_NAMES_LEN + 1];
	char    padding[3];
	u_short namelen;
	char    padding2[2];
} ba_name_t;

Returns

The function ba_list_classes() returns the number of classes on success, and -1 on error.

Errors

If an error occurs during a call to ba_list_classes(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_list_interface_config()

Name

ba_list_interface_config() -- retrieve configuration information for all managed interfaces

Synopsis

#include <netinet/ba_stat.h>

int ba_list_interface_config(
	 ba_interface_t *interfaces /*interface information*/
);

Description

The function ba_list_interface_config() retrieves the configuration information for all managed interfaces.

Arguments

Structures of type ba_interface_t are defined as follows:

typedef struct {
	ba_name_t					name_suffix;
	uint_t					activate;
	uint_t					rate;
} ba_interface_t;

Where suffix is either in to indicate that the interface handles incoming traffic, or out to indicate that it handles outgoing traffic.

You must always allocate sufficient memory for the buffer, the size of which is dependent on the number of interfaces.

Returns

The function ba_list_interface_config() returns 0 on success, and -1 on error.

Errors

If an error occurs during a call to ba_list_interface_config(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_list_interfaces()

Name

ba_list_interfaces() -- retrieve the names of the managed interfaces

Synopsis

#include <netinet/ba_stat.h>

int ba_list_interfaces (
	 ba_name_t *interfaces /* allocate buffer */
);

Description

The function ba_list_interfaces() retrieves a list of the names of the interfaces that the policy agent has been configured to manage.

Arguments

The function ba_list_interfaces() is passed the following argument:

interfaces

Pointer to an array of structures of type ba_name_t, which is the buffer into which the names of the interfaces are written. There is one structure per name.

Structures of type ba_name_t are defined as follows:

typedef struct {
	char    name[BA_NAMES_LEN + 1];
	char    padding[3];
	u_short namelen;
	char    padding2[2];
} ba_name_t;

You must always allocate sufficient memory for the buffer, the size of which is dependent on the number of classes. For example:

nintface = ba_get_num_interfaces();
if (nintface > 0) {
	interfaces = (ba_name_t *) calloc(nintface, sizeof ba_name_t);
	if (ba_list_interfaces(interfaces) != -1) {
	/* process interfaces .. */
} else {
	/* error handling */
}
	free(interfaces);
}

Returns

The function ba_list_interfaces() returns the number of interfaces on success, and -1 on error.

Errors

If an error occurs during a call to ba_list_interfaces(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_open()

Name

ba_open() -- open driver file and get file descriptor

Synopsis

#include <netinet/ba_stat.h>

int ba_open();

Description

The function ba_open() opens the driver file /dev/ipqos, which is used to access the ipqos module, and returns the file descriptor. There can only be one instance of the ipqos module per user process; therefore, if the file has already been opened by a previous function call, ba_open() returns the current file descriptor.

If the device driver has been closed previously with a call to ba_close(), the event mask is reset to the default value (0). You must set the event mask again for events to be detected by ba_get_next_event().

Returns

The function ba_open() returns the file descriptor on success, and --1 on error.

Errors

If an error occurs during a call to ba_open(), the variable ba_errno is set to:

BA_SYSERR

OS error: check errno 

ba_perror()

Name

ba_perror() -- print error message

Synopsis

#include <netinet/ba_stat.h>

void ba_perror(const char *msgstr);

Description

The function ba_perror() prints a message on the standard error output that describes the last error encountered during a call to the C Statistics API. It is equivalent to the system function perror(3C).

The error message is printed using the following format:

msgstr: error_message

where msgstr is a user-supplied character string that gives context to the message, and error_message is the result of a call to ba_strerror(ba_errno). In most cases, msgstr is set to provide information about the function call that caused the error condition.

For example, if ba_errno is set to BA_INVIFACE as the result of a call to ba_get_num_classes(), and msgstr is set as follows:

ba_get_num_classes (le1)

the message produced by a call to ba_perror() would be:

ba_get_num_classes (le1): interface not found

Arguments

The function ba_perror() is passed the following argument:

msgstr

Character string to be printed at the start of each message. 

ba_reset_class_stats()

Name

ba_reset_class_stats() -- reset statistics for a given class

Synopsis

#include <netinet/ba_stat.h>

int ba_reset_class_stats (
	const char *interface,
	const char *classname
);

Description

The function ba_reset_class_stats() resets the statistics information for a given class and all its child classes. This function may only be called by a privileged process.

Arguments

The function ba_reset_class_stats() is passed the following arguments:

interface

Pointer to a character string that contains the name of the managed interface (for example, le0, or hme0).

classname

Pointer to a character string that contains the class name. 

Returns

The function ba_reset_class_stats() returns 0 on success, and -1 on error.

Errors

If an error occurs during a call to ba_reset_class_stats(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_set_event_mask()

Name

ba_set_event_mask() -- set event mask

Synopsis

#include <netinet/ba_stat.h>

int ba_set_event_mask (
	int eventmask
);

Description

The function ba_set_event_mask() sets the event mask that defines which events are reported to the user process. The event mask is reset to its default value (0) when the driver file /dev/ipqos is closed by a call to ba_close().

The event mask is a bitwise OR of the possible events listed in Table 4-1.

Table 4-1 Setting the Event Mask

Bit Value 

Event Type 

Description 

1  

(00000001) 

BA_EVENT_CONFIG_STARTING

Generated when the policy agent starts to read a new configuration 

2  

(00000010) 

BA_EVENT_CONFIG_ENDING

Generated when the policy agent finishes reading a new configuration 

4  

(00000100) 

BA_EVENT_DAEMON_ENDING

Generated when the policy agent stops or is killed 

64 

(01000000) 

BA_EVENT_FLOW_ACCOUNTING

Generated when a flow has timed out or when the TOS field changes for a flow 

128 

(10000000) 

BA_EVENT_STATS_RESET

Generated when a class has been reset or remove 

For example:

Provided the relevant bit of the event mask is set, information about an event that occurs is written into a structure of type ba_event_t and queued in a FIFO buffer so that it can be retrieved by a call to ba_get_next_event().

Structures of type ba_event_t are defined as follows:

typedef struct {
	u_int           ba_event_type;
	u_int           ba_event_drops;

union {
      	ba_name_t       ba_event_iface;
      ba_name_t       ba_event_info;
      } ba_event_config;
      struct {
             ba_name_t     ba_flow_iface; /* no suffix */
             uint_t        ba_num_flows;
             ba_flow_event_t
ba_event_flows[BA_EVENT_MAX_FLOWS];
               } ba_event_flow;
               ba_class_stats_t      ba_event_stats;

/* the following is for internal use only */
               ba_filter_event_t     ba_event_filter;
               ba_cl_filter_event_t  ba_event_cl_filter;
       } ba_event_union;
} ba_event_t;

The elements of structures of type ba_event_t are set as follows:

ba_event_type

Set to identify the event type that has occurred. See Table 3-1 for possible values.

ba_event_iface

Set to identify the interface on which the event has occurred. It is set to the name of the reconfigured interface for events of type BA_EVENT_CONFIG_STARTING and BA_EVENT_CONFIG_ENDING. It is left blank for events of type BA_EVENT_DAEMON_ENDING.

ba_event_info

Reserved for future use. 

Structures of type ba_flow_event_t are defined as follows:

typedef struct {
     ba_name_t       classname_in; 
     ba_name_t       classname_out;
     struct in_addr  ip_local;
     struct in_addr  ip_remote;
     uchar_t         protocol;
     ushort_t        port_local;
     ushort_t        port_remote;
     uchar_t         tos_sent_in;
     uchar_t         tos_sent_out;
     uint_t          npackets_in;
     uint_t          nbytes_in;
     uint_t          npackets_out;
     uint_t          nbytes_out;
     uint_t          url_length;
     union {
             uchar_t         *url;
             u_longlong_t    url_pad;} url_union;
     hrtime_t   firstseen_in; /* timestamp of first packet sent (ns)*/
     hrtime_t   lastseen_in;  /* timestamp of last packet sent (ns) */
     hrtime_t   firstseen_out;/* timestamp of first packet sent (ns)*/
     hrtime_t   lastseen_out; /* timestamp of last packet sent (ns) */
} ba_flow_event_t;

#define ba_flow_url     url_union.url

Arguments

The function ba_set_event_mask() is passed the following argument:

eventmask

Integer that represents the bitwise value of the event mask. 

Returns

The function ba_set_event_mask() returns 0 on success, and -1 on error.

Errors

If an error occurs during a call to ba_set_event_mask(), the variable ba_errno is set to one of the error codes listed in Table 4-2.

ba_strerror()

Name

ba_strerror() -- retrieve error message

Synopsis

#include <netinet/ba_stat.h>

char *ba_sterror(int errnum);

Description

The function ba_strerror() retrieves the error message associated with the error code errnum. It is equivalent to the system function strerror(3C).

Arguments

The function ba_strerror() is passed the following argument:

errnum

Integer error code. 

Returns

The function ba_strerror() returns a pointer to a character string that contains the error message on success, and -1 on error.

Statistics API Error Messages

Table 4-2 lists the errors returned by the C statistics API.

Table 4-2 Error Codes for ba_errno

No. 

Error Code 

Error Message 

1

BA_NOTRUNNING

daemon not running 

2

BA_INVIFACE

interface not found 

3

BA_NOROOT

no root class 

4

BA_NODEFAULT

no default class 

5

BA_INVCLHNDL

invalid class handle 

6

BA_INVPARTHDL

invalid parent handle 

7

BA_INVPREVHDL

invalid previous handle 

8

BA_INVFLTNAME

invalid filter name 

9

BA_NAMETOOLONG

name greater than the value ofBA_NAMES_LEN

10

BA_ROOTEXIST

root class already exists 

11

BA_DEFEXIST

default class already exists 

12

BA_CLEXIST

class already exists 

13

BA_NOCLLEFT

CBQ_MAX_CLASSES reached

14

BA_ISPARENT

class to remove has children 

15

BA_PRIOTOOBIG

priority greater than the value of RM_MAXPRIO

16

BA_NOTDAEMON

operation reserved to the daemon 

17

BA_INVCLNAME

invalid class name 

18

BA_PERM

not superuser 

19

BA_INVEVTMASK

event mask is out of bounds 

20

BA_SYSERR

OS error: check errno 

21

BA_INVSIGNO

invalid signal number 

22

BA_INVAL

invalid API argument 

23

BA_NOMEM

no memory left 

24

BA_CONFIGURING

configuration change 

25

BA_INVIFHDL

invalid interface handle 

26

BA_FLEXIST

filter already exists 

27

BA_INVFLHDL

invalid filter handle 

28

BA_INVITHDL

invalid filter item handle 

29

BA_FLINUSE

filter is still referenced