Skip to content

C header generated from YANG model

Amy Buck edited this page Nov 27, 2018 · 5 revisions

This information includes an example which shows the C header file generated from the sFlow YANG model by the CPS object library YANG parser.

The YANG model has two top-level containers:

  • YANG list named entry
  • YANG container named socket-address

See dell-base-sflow.yang for complete information.

The CPS YANG parser generates the C header for this model — the C header generation happens during the build process.

NOTE: The opx-base-model and opx-cps repos must be present in your workplace.

The header includes the C definitions for the YANG entities:

  • Category for the YANG model is cps_api_obj_CAT_BASE_SFLOW
  • Subcategory for each YANG container:
    • BASE_SFLOW_ENTRY_OBJ
    • BASE_SFLOW_SOCKET_ADDRESS_OBJ
  • Attribute IDs for each property in each YANG container:
    • BASE_SFLOW_ENTRY_IFINDEX
    • BASE_SFLOW_ENTRY_DIRECTION
/*
* source file : dell-base-sflow.h
*/

/*
* Copyright (c) 2018 Dell Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* THIS CODE IS PROVIDED ON AN  *AS IS* BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
* LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS
* FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
*
* See the Apache Version 2.0 License for specific language governing
* permissions and limitations under the License.
*/
#ifndef DELL_BASE_SFLOW_H
#define DELL_BASE_SFLOW_H

#include "cps_api_operation.h"
#include "dell-base-common.h"
#include <stdint.h>
#include <stdbool.h>

#define cps_api_obj_CAT_BASE_SFLOW (27)

#define DELL_BASE_SFLOW_MODEL_STR "dell-base-sflow"

/*Enumeration base-sflow:traffic-path */
typedef enum {
  BASE_SFLOW_TRAFFIC_PATH_INGRESS = 1, /*Enable sampling on Ingress packets*/
  BASE_SFLOW_TRAFFIC_PATH_EGRESS = 2, /*Enable sampling of Egress packets*/
  BASE_SFLOW_TRAFFIC_PATH_INGRESS_EGRESS = 3, /*Enable sampling of Ingress and Egress packets*/
} BASE_SFLOW_TRAFFIC_PATH_t;


/*Object base-sflow/entry */
typedef enum {
/*type=uint32*/
/*Session id to uniquely identify a sflow session*/
  BASE_SFLOW_ENTRY_ID = 1769474,

/*type=base-cmn:logical-ifindex*/
/*Interface index which uniquely identifies physical
interface in the switch where packet sampling needs to
to be enabled*/
  BASE_SFLOW_ENTRY_IFINDEX = 1769475,

/*type=base-cmn:traffic-path*/
/*Direction of packets in which sampling needs to be enabled*/
  BASE_SFLOW_ENTRY_DIRECTION = 1769476,

/*type=uint32*/
/*Rate at which packets sampling needs to be enabled*/
  BASE_SFLOW_ENTRY_SAMPLING_RATE = 1769477,

} BASE_SFLOW_ENTRY_t;

/*Object base-sflow/socket-address */
typedef enum {
/*type=base-cmn:ipv4-address*/
  BASE_SFLOW_SOCKET_ADDRESS_IP = 1769479,

/*type=uint16*/
  BASE_SFLOW_SOCKET_ADDRESS_UDP_PORT = 1769480,

} BASE_SFLOW_SOCKET_ADDRESS_t;

/* Object subcategories */
typedef enum{
/*sflow session attributes*/
  BASE_SFLOW_ENTRY = 1769478,
  BASE_SFLOW_ENTRY_OBJ = 1769478,

/*Address that sFlow Applications need to open UDP socket on
to receive sampled packets. Sampled packets from all sFlow
sessions are sent to a single UDP socket.*/
  BASE_SFLOW_SOCKET_ADDRESS = 1769481,
  BASE_SFLOW_SOCKET_ADDRESS_OBJ = 1769481,

} BASE_SFLOW_OBJECTS_t;

#endif
Clone this wiki locally