op_pk_encap_flag_set()
Abstract
Sets a flag on a packet that becomes visible on any packet that encapsulates the original packet.
Syntax
op_pk_encap_flag_set (pkptr, index)
| Argument | Type | Description |
|---|---|---|
pkptr |
Packet* |
pointer to the packet-of-interest [A pointer to a packet can be obtained from many KPs, including op_pk_create(), op_pk_create_fmt(), op_pk_copy(), op_pk_get(), op_subq_pk_access(), and op_subq_pk_remove().] |
index |
int |
the flag to set on the packet [The flag may be an integer from 0 to 31.] |
Return Type
void
No return value.
Example
Excerpts below from ip_basetraf_src.pr.c in the models/std/ip directory
/* We need to set the "hold_time" for the traffic which is used */
/* in other models to set the expiration time of this traffic. */
/* We want traffic to be valid for slightly longer than the duration */
/* specified by the basetraf event to give a margin of safety in case */
/* the bgutil_tracer packet is delayed when traveling the network. */
saftey_margin = HOLD_TIME_SAFETY_FRACTION * traf_event_duration;
op_pk_nfd_set (tracer_pk, "hold_time", saftey_margin + duration);
/* Assign amount of traffic this tracer packet reprsents. */
op_pk_nfd_set (tracer_pk, "bandwidth",
traf_event_ptr->num_bits / traf_event_duration);
op_pk_nfd_set (tracer_pk, "packets_per_sec",
traf_event_ptr->num_packets / traf_event_duration);
/* Tag the tracer packet as special so that we can find it efficiently */
/* in models that need to make use of this traffic information. */
op_pk_encap_flag_set (tracer_pk, OMSC_BGUTIL_ENCAP_FLAG_INDEX);
Details
The number of the flag set by the index argument has no specific meaning; any meaning is determined by the model developer. If another packet then encapsulates the flagged packet, the encapsulating packet also inherits the flag. More than one flag may be set on a packet.
If a flagged packet is segmented by any KPs in the SAR package, each packet containing a segment of the original inherits the flag.
Purpose
Provides a mechanism for flagging packets in such a way that the flag is visible on any packet that encapsulate the original packet.
Errors
- Program Abort: Segmentation violation. (due to an invalid packet pointer or malformed packet)
- Recoverable Error: Encap flag index (
<index>) is out-of-range for packet (<pk_id>). Legal range is from 0 to 31.
Reference
- Use the KP op_pk_encap_pk_get() to retrieve a copy of an encapsulated packet
- Use the KP op_pk_encap_flag_is_set() to see if a flag has been set on an encapsulated packet