blob: d7a1df9a2fa6e6683b5ff06e598afe43eafdf8a5 [file] [log] [blame]
#ifndef __TFT_Core_H__
#define __TFT_Core_H__
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <errno.h>
#include "dialer_task.h"
#include "cm_toe.h"
typedef struct {
unsigned int min; //low limit
unsigned int max; //max limit
} NumericRange;
typedef struct _TFTNode{
struct _TFTNode *pre;
struct _TFTNode *next;
}TFTNode;
typedef struct _QoSNode{
unsigned char qfi;
unsigned char psi;
unsigned char priority;
unsigned char tftCnt;
TFTNode tftNode;
struct _QoSNode *pre;
struct _QoSNode *next;
}QoSNode;
#if 0
typedef struct {
unsigned int direction;
UINT8 pIdNextHdr; /**< Protocol number (ipv4) / next header (ipv6) */
bool pIdNextHdrPresent; /**< TRUE: if present \sa CCI API Ref Manual */ //Michal
NumericRange localPortRange;
NumericRange RemotePortRange;
bool localPortRangePresent;
bool RemotePortRangePresent;
unsigned char SecondaryCID;
unsigned char PfIdx; // Packet Filter ID
unsigned char EpIdx; // Evaluation Precedence Index
bool TosPresent;
unsigned char Tos; // Type of Service
unsigned char TosMask; // Type of Service Mask
bool SpiPresent;
bool FlowLablePresent;
unsigned int SPI;
unsigned int FlowLable;
unsigned char IPType;
unsigned int RemoteAddress[4];
bool RemoteAddressPresent;
unsigned int SubnetMask[4];
bool SubnetMaskPresent;
void *next;
bool matchAll;
} PacketFilterInfo;
#endif
typedef struct _PacketFilterInfoNode{
TFTNode header;
TftInfoList info;
}PacketFilterInfoNode;
#if 0
struct ip4_hdr
{
unsigned char ip_pvhl; /* IP protocol version and header length */
unsigned char ip_tos; /* type of service */
unsigned short ip_len; /* total length */
unsigned short ip_id; /* identification */
unsigned short ip_off; /* fragment offset field */
unsigned char ip_ttl; /* time to live */
unsigned char ip_p; /* protocol */
unsigned short ip_sum; /* checksum */
unsigned int ip_src; /* source IP address */
unsigned int ip_dst; /* dest IP address */
}__attribute__((packed)) ;
/** Layout of the IPv6 header (rfc 2460) */
typedef struct ip6_hdr {
unsigned int ip6_vtf; /**< Version (4), Traffic Class (8), Flow Label 20 */
unsigned short ip6_len; /**< Length */
unsigned char ip6_nextheader; /**< Next header */
unsigned char ip6_hoplimit; /**< Hop Limit */
unsigned int ip6_src[4]; /**< Source address */
unsigned int ip6_dst[4]; /**< Destination address */
}__attribute__((packed)) IP6Hdr_t; /**< @see struct ip6_hdr */
typedef struct ip6_frag_hdr {
/* next header */
unsigned char _nexth;
/* reserved */
unsigned char reserved;
/* fragment offset */
unsigned short _fragment_offset;
/* fragmented packet identification */
unsigned int _identification;
} __attribute__((packed)) IP6FragHdr_t;
/** Layout of TCP header (rfc 793) */
struct tcp_hdr {
unsigned short src; /**< source port */
unsigned short dest; /**< destination port */
unsigned int tcp_seq; /**< sequence number */
unsigned int tcp_ack; /**< ack number */
unsigned short tcp_offresflags; /**< 4 bits hdr len +
6 bits reserved +
6 flags */
#define TCP_LEN 0xf000U /**< TCP header lenght bitmask */
#define TCP_REX 0x0fc0U /**< TCP reserved bits bitmask */
#define TCP_FLAGS 0x003fU /**< TCP flags bitmask */
#define TCP_URG 0x0020U /**< TCP urgent pointer bitmask */
#define TCP_ACK 0x0010U /**< TCP flag ACK set */
#define TCP_PSH 0x0008U /**< TCP flag PSH set */
#define TCP_RST 0x0004U /**< TCP flag RST set */
#define TCP_SYN 0x0002U /**< TCP flag SYN set */
#define TCP_FIN 0x0001U /**< TCP flag FIN set */
#define TCP_DEFAULTLEN 5 /**< Usual length of TCP header */
unsigned short tcp_window; /**< advertised window */
unsigned short tcp_chksum; /**< checksum */
unsigned short tcp_urgptr; /**< urgent pointer */
}__attribute__((packed)); /**< @see struct tcp_hdr */
/** Layout of UDP header (rfc 768) */
struct udp_hdr {
unsigned short src; /**< source port */
unsigned short dest; /**< destination port */
unsigned short udp_len; /**< UDP length */
unsigned short udp_chksum; /**< UDP checksum */
}__attribute__((packed)); /**< @see struct udp_hdr */
#endif
struct espid_ip6_info {
unsigned int src_ip[4];
unsigned int dest_ip[4];
unsigned short int src_port;
unsigned short int dest_port;
unsigned int proto;
};
struct espid_ip4_info {
unsigned int src_ip;
unsigned int dest_ip;
unsigned short int src_port;
unsigned short int dest_port;
unsigned int proto;
};
#define MAX_CID_COUNT_FOR_TFT (16)
#ifdef CM_CONFIG_TOE
void cm_tftinfo_init(void);
void cm_qos_update_pf(TftInfoList *pf, BOOL sim2Flag);
void qos_delete_qos(unsigned char PrimCid,unsigned char targetCid, BOOL sim2Flag);
bool cm_ctx_toe_tuple_qos_match(int cid, struct toe_tuple_list *tuple, struct toe_tft_param *toe_param);
#endif
#endif