/*
 * cfmPktProc.h
 *
 *  Created on: 29 Apr 2016
 *      Author: netconf
 */

#ifndef CFMPKTPROC_H_
#define CFMPKTPROC_H_

#include <sys/socket.h>
//VR#include <linux/netlink.h>
// Not building for Linux
#include "egl_types.h"
#include "gateway_2port_eth.h"

#define NETLINK_USER 	31
#define MAX_PAYLOAD 	1536  /* maximum payload size*/
#define NETLINK_MAC_CMD         0xFE		/* NETLINK_MAC_CMD is to identify the next byte is mac number */
#define MIP_MAC_NO_RESERVED     0xEF		/* 0xEF is reserved mac number for testing and initial dummy message.*/

#define CFM_TASK_STACKSIZE		1024

#define MR_CAPT_REASON_MAC_MATCH		0xF
#define MR_CAPT_REASON_BC_MATCH			0xE
#define MR_CAPT_REASON_LTM				0x5
#define MR_CAPT_REASON_LTR				0x4


struct payloadHdr_s {
	uint8_t		mac_num_cmd;
	uint8_t		mac_num;
	uint8_t		capt_reason_cmd;
	uint8_t		capt_reason;
};

//VR defined twice - use gateway_2port_eth.h
/*typedef struct cfmPktInfo_s {
	uint8_t		port;
	uint8_t		captReason;
	uint16_t	pktLen;
} captPktInfo_t;*/

//VR Reference to netlink data structures
/*
struct mip_sock {
        struct sockaddr_nl src_addr;
        struct sockaddr_nl dest_addr;
        struct nlmsghdr *nlh;
        struct nlmsghdr *nlhRx;
        struct iovec iov;
        struct iovec iovRx;
        int sock_fd;
        struct msghdr msg;
        struct msghdr msgRx;
        int (*ltm_rcv_cb)(captPktInfo_t *cfmPktInfo, uint8_t *ptrbuf);
        int (*ltr_rcv_cb)(captPktInfo_t *cfmPktInfo, uint8_t *ptrbuf);
};
*/
int cfm_register_ltm_recv_callback(int (*ltm_rcv_fn)(captPktInfo_t *cfmPktInfo, uint8_t *ptrbuf));
int cfm_register_ltr_recv_callback(int (*ltr_rcv_fn)(captPktInfo_t *cfmPktInfo, uint8_t *ptrbuf));

void sendPktToPort(uint8_t port, uint8_t *ptrbuf, uint16_t len);

void initCfmPktProc(void);
void shutdownCfmPktProc(void);

#endif /* CFMPKTPROC_H_ */
