#ifndef _SDOIFACE_H
#define _SDOIFACE_H

#include "ul_gavl.h"

/**
 * struct sdoifc_root_t - structure representing root of SDO interfaces list
 */
typedef struct sdoifc_root_t 
{
    gavl_node_t *my_root;
    int my_info;
} sdoifc_root_t;

typedef unsigned long sdoifc_key_t;

/**
 * struct sdoifc_item_t - structure representing single object in OD
 * @my_node:   structure neccessary for storing node in GAVL tree, is NULL for subindicies
 * @cobid:     cli->srv COBID (client_port:nodeid), port on which SDO FSM will listen
 * @fsm:       SDO FSM which is currently serving SDO communication
 * @data:      buffer to store received/transmitted data
 */
typedef struct sdoifc_item_t
{
    gavl_node_t my_node;
    
    sdoifc_key_t cobid;
    vcasdo_fsm_t fsm;
    ul_dbuff_t data;
} sdoifc_item_t;

GAVL_CUST_NODE_INT_DEC(sdoifc, sdoifc_root_t, sdoifc_item_t, sdoifc_key_t,
	my_root, my_node, cobid, sdoifc_key_t)

inline int sdoifc_cmp_fnc(const sdoifc_key_t *a, const sdoifc_key_t *b)
{
  if (*a>*b) return 1;
  if (*a<*b) return -1;
  return 0;
}

#endif
