Sending the Packet

Once the information has been processed and stored, the data daemon takes the appropriate action and the packet is sent out.

The sample application does this in the packet loop, which is coded in the jnx_flow_data_process_packet() function (in the file jnx-flow-data_packet.c.) The following is an excerpt from this code:

...
             /*
             * flow entry action stats
             */
            if (flow_entry->flow_action == JNX_FLOW_RULE_ACTION_ALLOW) {

                atomic_add_uint(1, &flow_entry->flow_stats.pkts_out);
                atomic_add_uint(pkt_ctxt->pkt_len,
                                &flow_entry->flow_stats.bytes_out);
                /*
                 * for next hop style svc,
                 * set the egress interface subunit in the jbuf
                 */
                if (flow_entry->flow_key.svc_key.svc_type ==
                    JNX_FLOW_SVC_TYPE_NEXTHOP) {
                    jbuf_set_ointf(pkt_ctxt->pkt_buf, flow_entry->flow_oif);
                }
            } else {
                /*
                 * increment the drop statistics for the flow
                 */
                atomic_add_uint(1, &flow_entry->flow_stats.pkts_dropped);
                atomic_add_uint(pkt_ctxt->pkt_len,
                                &flow_entry->flow_stats.bytes_dropped);
            }

            /*
             * Now send the packet out, with the action applied
             */
            jnx_flow_data_send_packet(pkt_ctxt, flow_entry->flow_action);

            continue;
        }
...

jnx_flow_data_send_packet() sends or drops the packet as follows:

static void
      jnx_flow_data_send_packet(jnx_flow_data_pkt_ctxt_t *pkt_ctxt,
                                jnx_flow_rule_action_type_t action)
      {
          if (action == JNX_FLOW_RULE_ACTION_DROP) {
              jbuf_free(pkt_ctxt->pkt_buf);
              return;
          }
          msp_data_send(pkt_ctxt->thread_handle, pkt_ctxt->pkt_buf,
                        MSP_MSG_TYPE_PACKET);
          return;
      }


2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:26:47 2010 for Juniper Networks Partner Solution Development Platform JUNOS SDK 10.2R1 by Doxygen 1.4.5