297 lines
6.9 KiB
C
297 lines
6.9 KiB
C
#ifndef HOOK_H
|
|
#define HOOK_H
|
|
#include "ucc_geth.h"
|
|
#include <net/sock.h>
|
|
#include <linux/kfifo.h>
|
|
#include <linux/etherdevice.h>
|
|
|
|
#define EN_SIP_SWITCH (1)
|
|
|
|
#define UMB_MAX_CH (192)
|
|
#define UMB_MAX_GETH (3)
|
|
#define UMB_MAX_RTP_CH (UMB_MAX_CH * UMB_MAX_GETH) //384
|
|
|
|
/*
|
|
// 10ms rtp
|
|
struct rtp_tx_buf_t{
|
|
uint16_t status;
|
|
uint16_t len;
|
|
uint8_t data[156]; //156 + 4 == 160
|
|
};
|
|
|
|
struct rtp_rx_buf_t {
|
|
uint16_t status;
|
|
uint16_t len;
|
|
uint8_t data[156]; //156 + 4 == 160
|
|
};
|
|
struct rtp_ch_t {
|
|
struct rtp_tx_buf_t* current_ktx;
|
|
struct rtp_tx_buf_t* current_utx;
|
|
struct rtp_rx_buf_t* current_krx;
|
|
struct rtp_rx_buf_t* current_urx;
|
|
void* netdev; //for out route device
|
|
struct sock *sk;
|
|
struct rtp_tx_buf_t tx[2];
|
|
struct rtp_rx_buf_t rx[4];
|
|
atomic_t hold;
|
|
uint8_t pad0[36];
|
|
}; //160*6 + 4*7 + 36 = 960 + 28 + 36 = 1024;
|
|
*/
|
|
|
|
struct rtp_tx_buf_t{
|
|
uint16_t status;
|
|
uint16_t len;
|
|
uint8_t data[156]; //156 + 4 == 160
|
|
};
|
|
|
|
struct rtp_rx_buf_t {
|
|
uint16_t status;
|
|
uint16_t len;
|
|
char* data;
|
|
void* skb;
|
|
};
|
|
|
|
typedef struct __CPU_TIMER_DBG__
|
|
{
|
|
unsigned int uRTPSendTime;
|
|
unsigned int uIRQTime;
|
|
unsigned int uRTPNetTime;
|
|
unsigned int uIRQHookTime;
|
|
unsigned int uRTPSendCnt;
|
|
unsigned int uIRQCnt;
|
|
unsigned int uRTPNetCnt;
|
|
unsigned int uIRQHookCnt;
|
|
} CPU_TIMER_DBG, *PCPU_TIMER_DBG;
|
|
|
|
typedef struct __RTP_CH_DGBS__
|
|
{
|
|
uint32_t uRecBytes;
|
|
uint32_t uSendBytes;
|
|
uint32_t uUDPRecPackages;
|
|
uint32_t uLostPackages;
|
|
uint32_t uSendSeqLost;
|
|
uint32_t uRecvSeqLost;
|
|
uint32_t uBufStatus;
|
|
} RTP_CH_DBGS, PRTP_CH_DBGS;
|
|
|
|
|
|
struct rtp_ch_t {
|
|
struct rtp_tx_buf_t* current_ktx;
|
|
struct rtp_tx_buf_t* current_utx;
|
|
struct rtp_rx_buf_t* current_krx;
|
|
struct rtp_rx_buf_t* current_urx;
|
|
void* netdev; //for out route device
|
|
struct sock *sk;
|
|
struct rtp_tx_buf_t tx[2];
|
|
struct rtp_rx_buf_t rx[3];
|
|
uint32_t weight;
|
|
//atomic_t hold;
|
|
}; //160*2 + 4*7 + 3*12 = 384
|
|
|
|
|
|
struct g_rtp_t {
|
|
struct rtp_ch_t rtp_ch[UMB_MAX_RTP_CH]; //372 ch 4096*93
|
|
};
|
|
|
|
#define NET_DEBUG_RTP_MAX 20
|
|
|
|
struct net_debug_rtp_t {
|
|
struct rtp_tx_buf_t* current_ktx;
|
|
struct rtp_tx_buf_t* current_utx;
|
|
void* netdev; //for out route device
|
|
struct sock *sk;
|
|
struct rtp_tx_buf_t tx[NET_DEBUG_RTP_MAX];
|
|
uint32_t weight;
|
|
}; //160*10 + 4*5 = 1620
|
|
|
|
|
|
enum {
|
|
SKB_BUFF_TYPE = 0,
|
|
RTP_BUFF_TYPE = 1,
|
|
} ;
|
|
|
|
enum {
|
|
IRQ_STOP = 0x00000001,
|
|
};
|
|
|
|
struct ipstack_hook_t {
|
|
//struct sk_buff_head qtx[UMB_MAX_GETH];
|
|
struct sk_buff_head qtx;
|
|
uint8_t* kmap_addr;
|
|
uint8_t* kmap_end;
|
|
uint32_t kmap_len;
|
|
uintptr_t kmap_phy;
|
|
struct net_device *ucc_ndev;
|
|
atomic_t hold;
|
|
int (*hook_init)(struct ucc_geth_private* );
|
|
int (*hook_exit)(struct ucc_geth_private* );
|
|
int (*xmit_filter)(struct sk_buff*);
|
|
int (*backlog)(struct sk_buff*);
|
|
int (*hook_xmit)(void* data, int tx_type, struct net_device* dev);
|
|
int (*backlog_xmit)(struct ucc_geth_private* );
|
|
int (*gptimer_init)(int);
|
|
int (*gptimer_exit)(void);
|
|
struct g_rtp_t* (*get_grtp)(struct ucc_geth_private* );
|
|
int (*is_rtp_kbuf)(char* );
|
|
int (*do_sock_send)(void* );
|
|
int (*do_sock_recv)(struct sk_buff *skb, int* rlt);
|
|
};
|
|
|
|
#ifdef EN_SIP_SWITCH
|
|
#define MAX_CH_SUBPORT (3)
|
|
|
|
typedef enum __ETH_INTERFACE__
|
|
{
|
|
ETH_INTERFACE_0 = 0,
|
|
ETH_INTERFACE_1 = 1,
|
|
ETH_INTERFACE_2 = 2,
|
|
} ETH_INTERFACE;
|
|
|
|
typedef enum __CH_TYPE__
|
|
{
|
|
CH_TYPE_UNKNOWN = -1,
|
|
CH_TYPE_UMB = 0,
|
|
CH_TYPE_SIP = 1,
|
|
CH_TYPE_TC = 2,
|
|
} CH_TYPE;
|
|
|
|
typedef enum __CH_STATUS__
|
|
{
|
|
CH_STATUS_UNKONWN = -1,
|
|
CH_STATUS_CONFIGUREED = 0,
|
|
CH_STATUS_IDLE = 1,
|
|
CH_STATUS_LINKED = 2,
|
|
} CH_STATUS;
|
|
|
|
typedef enum __PORT_TYPE__
|
|
{
|
|
PORT_TYPE_UNKNOWN = -1,
|
|
PORT_TYPE_RECA = 0,
|
|
PORT_TYPE_RECB = 1,
|
|
PORT_TYPE_SS = 2,
|
|
PORT_TYPE_IPR = 5,
|
|
PORT_TYPE_B2B = 6,
|
|
PORT_TYPE_T38 = 7,
|
|
PORT_TYPE_SIPRTP = 8,
|
|
} PORT_TYPE;
|
|
|
|
typedef struct __IP_ADDR_INFO__
|
|
{
|
|
// ETH_INTERFACE ethId;
|
|
char ethAddr[ETH_ALEN];
|
|
__be16 ipPort;
|
|
__be32 ipAddr;
|
|
} IP_ADDR_INFO, *PIP_ADDR_INFO;
|
|
|
|
#pragma pack(1)
|
|
typedef struct __PACKAGE_HEAD__
|
|
{
|
|
struct ethhdr ethHead;
|
|
struct iphdr ipHead;
|
|
struct udphdr udpHead;
|
|
} __attribute__((packed))
|
|
PACKAGE_HEAD, *PPACKAGE_HEAD;
|
|
|
|
typedef struct __PACKAGE_INFO__
|
|
{
|
|
unsigned int isUpdate;
|
|
PACKAGE_HEAD headValue;
|
|
} PACKAGE_INFO, *PPACKAGE_INFO;
|
|
|
|
typedef struct __CH_LINK_INFO__
|
|
{
|
|
int linkCh;
|
|
IP_ADDR_INFO dstTarget;
|
|
PACKAGE_INFO toRTPCh;
|
|
PACKAGE_INFO fromRTPCh;
|
|
} CH_LINK_INFO, *PCH_LINK_INFO;
|
|
|
|
typedef struct __CH_PORT_INFO__
|
|
{
|
|
PORT_TYPE portType;
|
|
CH_STATUS chStatus;
|
|
__be16 ipPort;
|
|
CH_LINK_INFO chLinkInfo;
|
|
} CH_PORT_INFO, *PCH_PORT_INFO;
|
|
|
|
typedef enum __RFC2833_STATUS__
|
|
{
|
|
RFC2833_SEND_IDLE = 0,
|
|
RFC2833_SEND_BEGING,
|
|
RFC2833_SENDING,
|
|
RFC2833_RECV_IDLE,
|
|
RFC2833_RECVING,
|
|
RFC2833_RECV_UPLOAD,
|
|
} RFC2833_STATUS;
|
|
|
|
#define MAX_DTMF_SEND_BUF (32)
|
|
#define MAX_DTMF_RECV_BUF (64)
|
|
|
|
typedef struct __RFC2833_INFO__
|
|
{
|
|
unsigned int timeStamps;
|
|
unsigned int synIdentifier;
|
|
unsigned short seqNumber;
|
|
char dtmfValue;
|
|
char refCount;
|
|
char payloadType;
|
|
RFC2833_STATUS refStatus;
|
|
} RFC2833_INFO, *PRFC2833_INFO;
|
|
|
|
typedef struct __RFC2833_DTFM_RECV__
|
|
{
|
|
char recvBuf[MAX_DTMF_RECV_BUF];
|
|
} RFC2833_DTFM_RECV, *PRFC2833_DTFM_RECV;
|
|
|
|
typedef struct __CH_DTMF_INFO__
|
|
{
|
|
unsigned int refSendMask;
|
|
unsigned int curSendIndex;
|
|
RFC2833_INFO dtmfSendBuf;
|
|
RFC2833_INFO dtmfRecvBuf[MAX_DTMF_RECV_BUF];
|
|
} CH_DTMF_INFO, *PCH_DTMF_INFO;
|
|
|
|
typedef struct __SIP_CH_DBG__
|
|
{
|
|
unsigned int cnt_eth0_recv;
|
|
unsigned int cnt_eth0_2_ethx;
|
|
unsigned int mask_eth0_2_ethx;
|
|
unsigned int cnt_ethx_recv;
|
|
unsigned int cnt_ethx_2_eth0;
|
|
unsigned int mask_ethx_2_eth0;
|
|
unsigned short eth0_seq_index;
|
|
unsigned short ethx_seq_index;
|
|
unsigned int eth0_seq_error;
|
|
unsigned int ethx_seq_error;
|
|
} SIP_CH_DBG, *PSIP_CH_DBG;
|
|
|
|
typedef struct __SIP_CH_DETIAL__
|
|
{
|
|
int chId;
|
|
ETH_INTERFACE sipETHId;
|
|
CH_PORT_INFO portIPR;
|
|
CH_PORT_INFO portB2B;
|
|
CH_PORT_INFO portT38;
|
|
CH_PORT_INFO portRTP;
|
|
CH_DTMF_INFO rfc2833DTMF;
|
|
SIP_CH_DBG sipDebug;
|
|
struct kfifo dtmfSendFifo;
|
|
struct kfifo dtmfRecvFifo;
|
|
} SIP_CH_DETIAL, *PSIP_CH_DETIAL;
|
|
|
|
typedef struct __SIP_CH_INFO__
|
|
{
|
|
int iTotalCh;
|
|
int iPortStep;
|
|
int iPortBase;
|
|
int iRTPPortBase;
|
|
PSIP_CH_DETIAL pSipChDetial;
|
|
} SIP_CH_INFO, *PSIP_CH_INFO;
|
|
|
|
#endif //#ifdef EN_SIP_SWITCH
|
|
|
|
extern struct ipstack_hook_t* ipstack_hook_get(int ucc_num);
|
|
extern int register_irq_poll(void *( *hooks)(int, void *obj), void* data);
|
|
extern int unregister_irq_poll(int idx,void *( *hooks)(int,void *obj));
|
|
#endif
|