blob: d655051fcdc9e75f4851e23997ba166854f7f7a1 [file] [log] [blame]
/**************************************************************************
*
* Copyright (c) 2012 ZTE Corporation.
*
***************************************************************************
* Ä£ ¿é Ãû : P98D_DHCP
* ÎÄ ¼þ Ãû : dhcp_api.h
* Ïà¹ØÎļþ :
* ʵÏÖ¹¦ÄÜ : dhcpÄ£¿é½Ó¿Ú·â×°
* ×÷ Õß : LiuZhengXuan
* °æ ±¾ : V1.0
* Íê³ÉÈÕÆÚ : 2012-08-14
* ÆäËü˵Ã÷ :
**************************************************************************/
/**************************************************************************
* Ð޸ļǼ
**************************************************************************/
#ifndef _DHCP_API_H
#define _DHCP_API_H
/**************************************************************************
* #includeÇø
**************************************************************************/
#include "oss_api.h"
#ifdef __cplusplus
extern "C"
{
#endif
/**************************************************************************
* ³£Á¿¶¨ÒåÇø
**************************************************************************/
/**************************************************************************
* Êý¾Ý½á¹¹¶¨ÒåÇø
**************************************************************************/
typedef struct
{
UINT32 addr;
}T_zDhcp_IPv4Addr;
typedef struct
{
UINT32 addr[4];
}T_zDhcp_IPv6Addr;
typedef union
{
T_zDhcp_IPv4Addr v4Addr;
T_zDhcp_IPv6Addr v6Addr;
}T_zDhcp_IPAddr;
typedef struct
{
UINT8 pdpType; /* IPv4-0x21 IPv6-0x57 IPv4v6-0x8d */
T_zDhcp_IPv4Addr ipv4Addr; /* Íø²àÉϱ¨µÄipv4µØÖ· */
T_zDhcp_IPv4Addr routerIp; /* Íø¹ØipµØÖ· */
T_zDhcp_IPv4Addr snMask; /* ×ÓÍøÑÚÂë */
T_zDhcp_IPv4Addr v4Dns1; /* IPv4 DNS server addresses 1 */
T_zDhcp_IPv4Addr v4Dns2; /* IPv4 DNS server addresses 2 */
T_zDhcp_IPv6Addr ipv6Addr; /* Íø²àÉϱ¨µÄipv6µØÖ·,µ±Ç°Ö»Éϱ¨ÁË8×Ö½ÚµÄID */
T_zDhcp_IPv6Addr v6Dns1; /* IPv6 DNS server addresses 1 */
T_zDhcp_IPv6Addr v6Dns2; /* IPv6 DNS server addresses 2 */
}T_zDhcp_PdpCfgInf; /* PDP¼¤»î»ñÈ¡µÄÉÏÏÂÎÄÐÅÏ¢½á¹¹ */
typedef enum
{
DHCP_FRAMETYPE_IP_V4_TRANS = 0, /* IPv4ÏòÍâÍø´«ÊäÊý¾Ý */
DHCP_FRAMETYPE_IP_V6_TRANS, /* IPv6ÏòÍâÍø´«ÊäÊý¾Ý */
DHCP_FRAMETYPE_IP_V4_DHCP_RSP, /* IPv4µÄDHCPÓ¦´ðÊý¾Ý */
DHCP_FRAMETYPE_IP_V6_DHCP_RSP, /* IPv6µÄDHCPÓ¦´ðÊý¾Ý */
DHCP_FRAMETYPE_ARP_RSP, /* ARPÓ¦´ðÊý¾Ý */
DHCP_FRAMETYPE_NDP_RSP, /* NDPÓ¦´ðÊý¾Ý */
DHCP_FRAMETYPE_INVALID /* ÎÞЧÊý¾Ý */
}T_zDhcp_FrameType; /* ¶ÁÈ¡Çý¶¯Êý¾ÝÖ¡ÀàÐÍ */
/**************************************************************************
* º¯ÊýÉùÃ÷Çø
**************************************************************************/
VOID zDhcp_Init(VOID);
UINT32 zDhcp_OpenSvr(const T_zDhcp_PdpCfgInf *pPdpCfgInf);
T_zDhcp_FrameType zDhcp_ParseEtherFrame(UINT32 handle, const UINT8 *pEtherFrame, UINT16 etherFrameSize, BOOL *pIsRecvRs);
UINT16 zDhcp_GetRspEtherFrame(UINT32 handle,
UINT8 *pReqEtherFrame,
UINT16 reqEtherFrameSize,
UINT8 *pRspEtherFrameBuf,
UINT16 rspEtherFrameBufSize,
BOOL *pIsDhcpOver);
UINT16 zDhcp_GetRspArpFrame(UINT32 handle, UINT8 *pReqEtherFrame, UINT16 reqSize, UINT8 *pRspEtherFrame, UINT16 rspSize, UINT32 addr);
UINT32 zDhcp_GetCfgInfV4addr(UINT32 handle);
BOOL zDhcp_FillEtherFrame(UINT32 handle, UINT8 *pEtherFrame, UINT16 etherFrameSize, BOOL *pIsRecvRa);
VOID zDhcp_CloseSvr(UINT32 handle);
VOID zDhcp_UnInit(VOID);
BOOL zDhcp_StartUfi(VOID);
BOOL zDhcp_RecycleUfiIp(T_zDhcp_IPv4Addr *pIpv4AddrRemoved, T_zDhcp_IPv6Addr *pIpv6AddrRemoved, BOOL isIpv4Addr);
BOOL zDhcp_StaticSetUfiIpv4(UINT8 *pMacAddr, T_zDhcp_IPv4Addr *pSetIpv4Addr);
VOID zDhcp_StopUfi(VOID);
UINT32 zDhcp_GetSrcIpPortType(UINT8 *pPacket, T_zDhcp_IPAddr *pIpAddr, UINT16 *pPort, UINT16 *pPdpType);
UINT32 zDhcp_GetDestIpPortType(UINT8 *pPacket, T_zDhcp_IPAddr *pIpAddr, UINT16 *pPort, UINT16 *pPdpType);
UINT32 zDhcp_UpdatePacketSrcIpv4(UINT8 *pPacket, T_zDhcp_IPv4Addr *pIpAddr);
UINT32 zDhcp_UpdatePacketDestIpv4(UINT8 *pPacket, T_zDhcp_IPv4Addr *pIpAddr);
BOOL zDhcp_IsDnsPacket(UINT8 *pPacket);
/**************************************************************************
* È«¾Ö±äÁ¿ÉùÃ÷Çø
**************************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* _DHCP_API_H */