op_ici_format_print_proc_set()

Abstract

Sets a custom print procedure for the named structure field of ICIs with the given format.

Syntax

op_ici_format_print_proc_set (format_name, field_name, print_proc)
Argument Type Description
format_name const char * Name of the ICI format-of-interest.
field_name const char * Name of the field-of-interest.
[This name must be a defined structure field within the ICI format.]
print_proc Ici_Struct_Print_Meth User-defined print procedure to be called when an ICI with the specified format and field is printed. See the Details section for the function prototype.

Return Type

Compcode

Completion code indicating if the print procedure was successfully set. The value OPC_COMPCODE_FAILURE will be returned if any of the recoverable errors listed in the Errors section for this KP occur.

Example

/* Install a print procedure for the "address" field of all ICIs */
/* with the "ip_info" packet format. */
/* address_print_proc is defined in the function block as follows: */
/* */
/* void address_print_proc (void *structure_ptr, PrgT_List *dest_lptr) */
/*		{ */
/*		char *char_line; */
/*		ReqT_Address *addr_ptr; */
/* */
/*		addr_ptr = (ReqT_Address *) structure_ptr; */
/*		char_line = op_prg_mem_alloc (sizeof (char) * 60); */
/*		sprintf (char_line, "subnet: %d", addr_ptr->subnet); */
/*		op_prg_list_insert (dest_lptr, char_line, OPC_LISTPOS_TAIL); */
/*		char_line = op_prg_mem_alloc (sizeof (char) * 60); */
/*		sprintf (char_line, "node : %s", addr_ptr->node_name); */
/*		op_prg_list_insert (dest_lptr, char_line, OPC_LISTPOS_TAIL); */
/*		} */

op_ici_format_print_proc_set ("ip_info", "address", address_print_proc);

Details

Use this KP to specify a function to be used for creating a textual representation of a data structure stored inside a structure type ICI field. Such data structures may be complex, so a representation is useful in debugging.

When the ICI is printed (using iciprint_ev or iciprint_pk in ODB, or op_ici_print()), the specified print_proc will be called by the Simulation Kernel to obtain a textual representation of the particular structure field in the ICI.

The print_proc must have the following prototype:

typedef void
(*Ici_Struct_Print_Meth) (void *structure_ptr, PrgT_List *dest_lptr);

The print_proc must add new entries to *dest_lptr. The contents of the structure field are passed in *structure_ptr. Use prg_mem_alloc() to allocate strings for addition to the list. The Simulation Kernel automatically deallocates all memory.

Purpose

Sets print_proc as the function to be called when the specified field (field_name) is printed for any ICI with the specified format (format_name). field_name must identify a structure field.

Allows you to specify how structures unknown to the Simulation Kernel will be displayed when using iciprint_ev or iciprint_pk in ODB, or the op_ici_print() KP.

Errors

  • Recoverable Error: Field <field name> is not a structure field
  • Recoverable Error: ICI format (<format_name>) is unrecognized.
  • Recoverable Error: Attribute name (<field_name>) is unrecognized in ICI with format (<format_name>).

Reference

  • Use the KP op_ici_print() to print the contents of an ICI on the standard output device

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com