blob: d655051fcdc9e75f4851e23997ba166854f7f7a1 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/**************************************************************************
2*
3* Copyright (c) 2012 ZTE Corporation.
4*
5***************************************************************************
6* Ä£ ¿é Ãû : P98D_DHCP
7* ÎÄ ¼þ Ãû : dhcp_api.h
8* Ïà¹ØÎļþ :
9* ʵÏÖ¹¦ÄÜ : dhcpÄ£¿é½Ó¿Ú·â×°
10* ×÷ Õß : LiuZhengXuan
11* °æ ±¾ : V1.0
12* Íê³ÉÈÕÆÚ : 2012-08-14
13* ÆäËü˵Ã÷ :
14**************************************************************************/
15
16/**************************************************************************
17* Ð޸ļǼ
18**************************************************************************/
19#ifndef _DHCP_API_H
20#define _DHCP_API_H
21
22/**************************************************************************
23* #includeÇø
24**************************************************************************/
25#include "oss_api.h"
26
27#ifdef __cplusplus
28extern "C"
29{
30#endif
31
32/**************************************************************************
33* ³£Á¿¶¨ÒåÇø
34**************************************************************************/
35
36/**************************************************************************
37* Êý¾Ý½á¹¹¶¨ÒåÇø
38**************************************************************************/
39typedef struct
40{
41 UINT32 addr;
42}T_zDhcp_IPv4Addr;
43
44typedef struct
45{
46 UINT32 addr[4];
47}T_zDhcp_IPv6Addr;
48
49typedef union
50{
51 T_zDhcp_IPv4Addr v4Addr;
52 T_zDhcp_IPv6Addr v6Addr;
53}T_zDhcp_IPAddr;
54typedef struct
55{
56 UINT8 pdpType; /* IPv4-0x21 IPv6-0x57 IPv4v6-0x8d */
57 T_zDhcp_IPv4Addr ipv4Addr; /* Íø²àÉϱ¨µÄipv4µØÖ· */
58 T_zDhcp_IPv4Addr routerIp; /* Íø¹ØipµØÖ· */
59 T_zDhcp_IPv4Addr snMask; /* ×ÓÍøÑÚÂë */
60 T_zDhcp_IPv4Addr v4Dns1; /* IPv4 DNS server addresses 1 */
61 T_zDhcp_IPv4Addr v4Dns2; /* IPv4 DNS server addresses 2 */
62 T_zDhcp_IPv6Addr ipv6Addr; /* Íø²àÉϱ¨µÄipv6µØÖ·,µ±Ç°Ö»Éϱ¨ÁË8×Ö½ÚµÄID */
63 T_zDhcp_IPv6Addr v6Dns1; /* IPv6 DNS server addresses 1 */
64 T_zDhcp_IPv6Addr v6Dns2; /* IPv6 DNS server addresses 2 */
65}T_zDhcp_PdpCfgInf; /* PDP¼¤»î»ñÈ¡µÄÉÏÏÂÎÄÐÅÏ¢½á¹¹ */
66
67typedef enum
68{
69 DHCP_FRAMETYPE_IP_V4_TRANS = 0, /* IPv4ÏòÍâÍø´«ÊäÊý¾Ý */
70 DHCP_FRAMETYPE_IP_V6_TRANS, /* IPv6ÏòÍâÍø´«ÊäÊý¾Ý */
71 DHCP_FRAMETYPE_IP_V4_DHCP_RSP, /* IPv4µÄDHCPÓ¦´ðÊý¾Ý */
72 DHCP_FRAMETYPE_IP_V6_DHCP_RSP, /* IPv6µÄDHCPÓ¦´ðÊý¾Ý */
73 DHCP_FRAMETYPE_ARP_RSP, /* ARPÓ¦´ðÊý¾Ý */
74 DHCP_FRAMETYPE_NDP_RSP, /* NDPÓ¦´ðÊý¾Ý */
75 DHCP_FRAMETYPE_INVALID /* ÎÞЧÊý¾Ý */
76}T_zDhcp_FrameType; /* ¶ÁÈ¡Çý¶¯Êý¾ÝÖ¡ÀàÐÍ */
77
78/**************************************************************************
79* º¯ÊýÉùÃ÷Çø
80**************************************************************************/
81VOID zDhcp_Init(VOID);
82UINT32 zDhcp_OpenSvr(const T_zDhcp_PdpCfgInf *pPdpCfgInf);
83T_zDhcp_FrameType zDhcp_ParseEtherFrame(UINT32 handle, const UINT8 *pEtherFrame, UINT16 etherFrameSize, BOOL *pIsRecvRs);
84UINT16 zDhcp_GetRspEtherFrame(UINT32 handle,
85 UINT8 *pReqEtherFrame,
86 UINT16 reqEtherFrameSize,
87 UINT8 *pRspEtherFrameBuf,
88 UINT16 rspEtherFrameBufSize,
89 BOOL *pIsDhcpOver);
90UINT16 zDhcp_GetRspArpFrame(UINT32 handle, UINT8 *pReqEtherFrame, UINT16 reqSize, UINT8 *pRspEtherFrame, UINT16 rspSize, UINT32 addr);
91UINT32 zDhcp_GetCfgInfV4addr(UINT32 handle);
92BOOL zDhcp_FillEtherFrame(UINT32 handle, UINT8 *pEtherFrame, UINT16 etherFrameSize, BOOL *pIsRecvRa);
93VOID zDhcp_CloseSvr(UINT32 handle);
94VOID zDhcp_UnInit(VOID);
95
96BOOL zDhcp_StartUfi(VOID);
97BOOL zDhcp_RecycleUfiIp(T_zDhcp_IPv4Addr *pIpv4AddrRemoved, T_zDhcp_IPv6Addr *pIpv6AddrRemoved, BOOL isIpv4Addr);
98BOOL zDhcp_StaticSetUfiIpv4(UINT8 *pMacAddr, T_zDhcp_IPv4Addr *pSetIpv4Addr);
99VOID zDhcp_StopUfi(VOID);
100
101UINT32 zDhcp_GetSrcIpPortType(UINT8 *pPacket, T_zDhcp_IPAddr *pIpAddr, UINT16 *pPort, UINT16 *pPdpType);
102UINT32 zDhcp_GetDestIpPortType(UINT8 *pPacket, T_zDhcp_IPAddr *pIpAddr, UINT16 *pPort, UINT16 *pPdpType);
103UINT32 zDhcp_UpdatePacketSrcIpv4(UINT8 *pPacket, T_zDhcp_IPv4Addr *pIpAddr);
104UINT32 zDhcp_UpdatePacketDestIpv4(UINT8 *pPacket, T_zDhcp_IPv4Addr *pIpAddr);
105BOOL zDhcp_IsDnsPacket(UINT8 *pPacket);
106/**************************************************************************
107* È«¾Ö±äÁ¿ÉùÃ÷Çø
108**************************************************************************/
109
110#ifdef __cplusplus
111}
112#endif
113
114#endif /* _DHCP_API_H */
115