TianoCore EDK2 master
Loading...
Searching...
No Matches
DnsImpl.h
Go to the documentation of this file.
1
9#ifndef __EFI_DNS_IMPL_H_
10#define __EFI_DNS_IMPL_H_
11
12#include <Uefi.h>
13
14//
15// Libraries classes
16//
17#include <Library/BaseLib.h>
18#include <Library/UefiLib.h>
24#include <Library/NetLib.h>
25#include <Library/DebugLib.h>
26#include <Library/DpcLib.h>
27#include <Library/PrintLib.h>
28#include <Library/UdpIoLib.h>
29
30//
31// UEFI Driver Model Protocols
32//
36
37#include <Protocol/Udp4.h>
38#include <Protocol/Dhcp4.h>
39#include <Protocol/Dns4.h>
40
41#include <Protocol/Udp6.h>
42#include <Protocol/Dhcp6.h>
43#include <Protocol/Dns6.h>
44
45#include <Protocol/Ip4Config2.h>
46
47#include "DnsDriver.h"
48#include "DnsDhcp.h"
49
50//
51// Driver Version
52//
53#define DNS_VERSION 0x00000000
54
55//
56// Protocol instances
57//
60extern EFI_UNICODE_STRING_TABLE *gDnsControllerNameTable;
61
62extern EFI_DRIVER_BINDING_PROTOCOL gDns4DriverBinding;
63extern EFI_SERVICE_BINDING_PROTOCOL mDns4ServiceBinding;
64extern EFI_DNS4_PROTOCOL mDns4Protocol;
65
66extern EFI_DRIVER_BINDING_PROTOCOL gDns6DriverBinding;
67extern EFI_SERVICE_BINDING_PROTOCOL mDns6ServiceBinding;
68extern EFI_DNS6_PROTOCOL mDns6Protocol;
69
70//
71// DNS related
72//
73#define DNS_SERVER_PORT 53
74
75#define DNS_PROTOCOL_UDP EFI_IP_PROTO_UDP
76#define DNS_PROTOCOL_TCP EFI_IP_PROTO_TCP
77
78#define DNS_STATE_UNCONFIGED 0
79#define DNS_STATE_CONFIGED 1
80#define DNS_STATE_DESTROY 2
81
82#define DNS_DEFAULT_TIMEOUT 2
83
84#define DNS_TIME_TO_GETMAP 5
85
86#pragma pack(1)
87
88typedef union _DNS_FLAGS DNS_FLAGS;
89
90typedef struct {
91 LIST_ENTRY AllCacheLink;
92 EFI_DNS4_CACHE_ENTRY DnsCache;
94
95typedef struct {
96 LIST_ENTRY AllCacheLink;
97 EFI_DNS6_CACHE_ENTRY DnsCache;
99
100typedef struct {
101 LIST_ENTRY AllServerLink;
102 EFI_IPv4_ADDRESS Dns4ServerIp;
104
105typedef struct {
106 LIST_ENTRY AllServerLink;
107 EFI_IPv6_ADDRESS Dns6ServerIp;
109
110typedef struct {
111 UINT32 RetryCounting;
112 UINT32 PacketToLive;
113 CHAR16 *QueryHostName;
114 EFI_IPv4_ADDRESS QueryIpAddress;
115 BOOLEAN GeneralLookUp;
118
119typedef struct {
120 UINT32 RetryCounting;
121 UINT32 PacketToLive;
122 CHAR16 *QueryHostName;
123 EFI_IPv6_ADDRESS QueryIpAddress;
124 BOOLEAN GeneralLookUp;
127
129 struct {
130 UINT16 RCode : 4;
131 UINT16 Zero : 3;
132 UINT16 RA : 1;
133 UINT16 RD : 1;
134 UINT16 TC : 1;
135 UINT16 AA : 1;
136 UINT16 OpCode : 4;
137 UINT16 QR : 1;
138 } Bits;
139 UINT16 Uint16;
140};
141
142#define DNS_FLAGS_QR_QUERY 0
143#define DNS_FLAGS_QR_RESPONSE 1
144
145#define DNS_FLAGS_OPCODE_STANDARD 0
146#define DNS_FLAGS_OPCODE_INVERSE 1
147#define DNS_FLAGS_OPCODE_SERVER_STATE 2
148
149#define DNS_FLAGS_RCODE_NO_ERROR 0
150#define DNS_FLAGS_RCODE_NAME_ERROR 3
151
152typedef struct {
153 UINT16 Identification;
154 DNS_FLAGS Flags;
155 UINT16 QuestionsNum;
156 UINT16 AnswersNum;
157 UINT16 AuthorityNum;
158 UINT16 AditionalNum;
159} DNS_HEADER;
160
161typedef struct {
162 UINT16 Type;
163 UINT16 Class;
165
166typedef struct {
167 UINT16 Type;
168 UINT16 Class;
169 UINT32 Ttl;
170 UINT16 DataLength;
172
173#define DNS4_DOMAIN L"in-addr.arpa"
174#define DNS6_DOMAIN L"IP6.ARPA"
175
176#pragma pack()
177
190 IN NET_MAP *TokenMap,
191 IN DNS4_TOKEN_ENTRY *TokenEntry
192 );
193
206 IN NET_MAP *TokenMap,
207 IN DNS6_TOKEN_ENTRY *TokenEntry
208 );
209
227EFIAPI
229 IN NET_MAP *Map,
230 IN NET_MAP_ITEM *Item,
231 IN VOID *Arg OPTIONAL
232 );
233
251EFIAPI
253 IN NET_MAP *Map,
254 IN NET_MAP_ITEM *Item,
255 IN VOID *Arg OPTIONAL
256 );
257
270EFIAPI
272 IN NET_MAP *TokensMap,
274 OUT DNS4_TOKEN_ENTRY **TokenEntry
275 );
276
289EFIAPI
291 IN NET_MAP *TokensMap,
293 OUT DNS6_TOKEN_ENTRY **TokenEntry
294 );
295
310 IN DNS_INSTANCE *Instance,
312 );
313
328 IN DNS_INSTANCE *Instance,
330 );
331
338VOID
341 );
342
349VOID
352 );
353
369 );
370
386 );
387
394VOID
395EFIAPI
397 IN VOID *Arg
398 );
399
415BOOLEAN
417 IN DNS_INSTANCE *Instance,
418 IN UDP_IO *UdpIo,
419 IN EFI_UDP4_CONFIG_DATA *UdpCfgData
420 );
421
434BOOLEAN
436 IN DNS_INSTANCE *Instance,
437 IN UDP_IO *UdpIo,
438 IN EFI_UDP6_CONFIG_DATA *UdpCfgData
439 );
440
453 IN DNS_INSTANCE *Instance,
454 IN UDP_IO *UdpIo
455 );
456
469 IN DNS_INSTANCE *Instance,
470 IN UDP_IO *UdpIo
471 );
472
488EFIAPI
490 IN LIST_ENTRY *Dns4CacheList,
491 IN BOOLEAN DeleteFlag,
492 IN BOOLEAN Override,
493 IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry
494 );
495
510EFIAPI
512 IN LIST_ENTRY *Dns6CacheList,
513 IN BOOLEAN DeleteFlag,
514 IN BOOLEAN Override,
515 IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry
516 );
517
529EFIAPI
531 IN LIST_ENTRY *Dns4ServerList,
532 IN EFI_IPv4_ADDRESS ServerIp
533 );
534
546EFIAPI
548 IN LIST_ENTRY *Dns6ServerList,
549 IN EFI_IPv6_ADDRESS ServerIp
550 );
551
565BOOLEAN
567 IN NET_MAP *TokensMap,
568 IN UINT16 Identification,
569 IN UINT16 Type,
570 IN UINT16 Class,
571 OUT NET_MAP_ITEM **Item
572 );
573
588 IN OUT DNS_INSTANCE *Instance,
589 IN UINT8 *RxString,
590 IN UINT32 Length,
591 OUT BOOLEAN *Completed
592 );
593
603VOID
604EFIAPI
606 NET_BUF *Packet,
607 UDP_END_POINT *EndPoint,
608 EFI_STATUS IoStatus,
609 VOID *Context
610 );
611
621VOID
622EFIAPI
624 NET_BUF *Packet,
625 UDP_END_POINT *EndPoint,
626 EFI_STATUS IoStatus,
627 VOID *Context
628 );
629
642 IN DNS_INSTANCE *Instance,
643 IN NET_BUF *Packet
644 );
645
661 IN DNS_INSTANCE *Instance,
662 IN CHAR8 *QueryName,
663 IN UINT16 Type,
664 IN UINT16 Class,
665 OUT NET_BUF **Packet
666 );
667
680 IN DNS_INSTANCE *Instance,
681 IN NET_BUF *Packet
682 );
683
691VOID
692EFIAPI
694 IN EFI_EVENT Event,
695 IN VOID *Context
696 );
697
705VOID
706EFIAPI
708 IN EFI_EVENT Event,
709 IN VOID *Context
710 );
711
728EFIAPI
730 IN EFI_DNS4_PROTOCOL *This,
731 OUT EFI_DNS4_MODE_DATA *DnsModeData
732 );
733
760EFIAPI
762 IN EFI_DNS4_PROTOCOL *This,
763 IN EFI_DNS4_CONFIG_DATA *DnsConfigData
764 );
765
787EFIAPI
789 IN EFI_DNS4_PROTOCOL *This,
790 IN CHAR16 *HostName,
792 );
793
817EFIAPI
819 IN EFI_DNS4_PROTOCOL *This,
820 IN EFI_IPv4_ADDRESS IpAddress,
822 );
823
852EFIAPI
854 IN EFI_DNS4_PROTOCOL *This,
855 IN CHAR8 *QName,
856 IN UINT16 QType,
857 IN UINT16 QClass,
859 );
860
888EFIAPI
890 IN EFI_DNS4_PROTOCOL *This,
891 IN BOOLEAN DeleteFlag,
892 IN BOOLEAN Override,
893 IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry
894 );
895
918EFIAPI
919Dns4Poll (
921 );
922
949EFIAPI
951 IN EFI_DNS4_PROTOCOL *This,
953 );
954
972EFIAPI
974 IN EFI_DNS6_PROTOCOL *This,
975 OUT EFI_DNS6_MODE_DATA *DnsModeData
976 );
977
1002EFIAPI
1004 IN EFI_DNS6_PROTOCOL *This,
1005 IN EFI_DNS6_CONFIG_DATA *DnsConfigData
1006 );
1007
1031EFIAPI
1033 IN EFI_DNS6_PROTOCOL *This,
1034 IN CHAR16 *HostName,
1036 );
1037
1062EFIAPI
1064 IN EFI_DNS6_PROTOCOL *This,
1065 IN EFI_IPv6_ADDRESS IpAddress,
1067 );
1068
1099EFIAPI
1101 IN EFI_DNS6_PROTOCOL *This,
1102 IN CHAR8 *QName,
1103 IN UINT16 QType,
1104 IN UINT16 QClass,
1106 );
1107
1136EFIAPI
1138 IN EFI_DNS6_PROTOCOL *This,
1139 IN BOOLEAN DeleteFlag,
1140 IN BOOLEAN Override,
1141 IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry
1142 );
1143
1168EFIAPI
1169Dns6Poll (
1170 IN EFI_DNS6_PROTOCOL *This
1171 );
1172
1200EFIAPI
1201Dns6Cancel (
1202 IN EFI_DNS6_PROTOCOL *This,
1204 );
1205
1206#endif
EFI_STATUS EFIAPI Dns4Configure(IN EFI_DNS4_PROTOCOL *This, IN EFI_DNS4_CONFIG_DATA *DnsConfigData)
Definition: DnsProtocol.c:177
EFI_STATUS DoDnsQuery(IN DNS_INSTANCE *Instance, IN NET_BUF *Packet)
Definition: DnsImpl.c:1915
EFI_STATUS EFIAPI Dns6IpToHostName(IN EFI_DNS6_PROTOCOL *This, IN EFI_IPv6_ADDRESS IpAddress, IN EFI_DNS6_COMPLETION_TOKEN *Token)
Definition: DnsProtocol.c:1404
EFI_STATUS EFIAPI GetDns4TokenEntry(IN NET_MAP *TokensMap, IN EFI_DNS4_COMPLETION_TOKEN *Token, OUT DNS4_TOKEN_ENTRY **TokenEntry)
Definition: DnsImpl.c:215
EFI_STATUS EFIAPI Dns4CancelTokens(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Arg OPTIONAL)
Definition: DnsImpl.c:100
EFI_STATUS EFIAPI Dns6Cancel(IN EFI_DNS6_PROTOCOL *This, IN EFI_DNS6_COMPLETION_TOKEN *Token)
Definition: DnsProtocol.c:1702
EFI_STATUS EFIAPI Dns4Cancel(IN EFI_DNS4_PROTOCOL *This, IN EFI_DNS4_COMPLETION_TOKEN *Token)
Definition: DnsProtocol.c:849
EFI_STATUS EFIAPI Dns4HostNameToIp(IN EFI_DNS4_PROTOCOL *This, IN CHAR16 *HostName, IN EFI_DNS4_COMPLETION_TOKEN *Token)
Definition: DnsProtocol.c:333
EFI_COMPONENT_NAME2_PROTOCOL gDnsComponentName2
EFI_STATUS DnsRetransmit(IN DNS_INSTANCE *Instance, IN NET_BUF *Packet)
Definition: DnsImpl.c:2054
EFI_STATUS EFIAPI Dns4UpdateDnsCache(IN EFI_DNS4_PROTOCOL *This, IN BOOLEAN DeleteFlag, IN BOOLEAN Override, IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry)
Definition: DnsProtocol.c:747
EFI_STATUS EFIAPI Dns6Configure(IN EFI_DNS6_PROTOCOL *This, IN EFI_DNS6_CONFIG_DATA *DnsConfigData)
Definition: DnsProtocol.c:1028
EFI_STATUS EFIAPI AddDns6ServerIp(IN LIST_ENTRY *Dns6ServerList, IN EFI_IPv6_ADDRESS ServerIp)
Definition: DnsImpl.c:1012
EFI_STATUS ConstructDNSQuery(IN DNS_INSTANCE *Instance, IN CHAR8 *QueryName, IN UINT16 Type, IN UINT16 Class, OUT NET_BUF **Packet)
Definition: DnsImpl.c:1956
EFI_STATUS Dns4InstanceCancelToken(IN DNS_INSTANCE *Instance, IN EFI_DNS4_COMPLETION_TOKEN *Token)
Definition: DnsImpl.c:287
EFI_STATUS ParseDnsResponse(IN OUT DNS_INSTANCE *Instance, IN UINT8 *RxString, IN UINT32 Length, OUT BOOLEAN *Completed)
Definition: DnsImpl.c:1124
VOID Dns6CleanConfigure(IN OUT EFI_DNS6_CONFIG_DATA *Config)
Definition: DnsImpl.c:415
EFI_STATUS Dns6InstanceCancelToken(IN DNS_INSTANCE *Instance, IN EFI_DNS6_COMPLETION_TOKEN *Token)
Definition: DnsImpl.c:345
EFI_STATUS EFIAPI Dns6UpdateDnsCache(IN EFI_DNS6_PROTOCOL *This, IN BOOLEAN DeleteFlag, IN BOOLEAN Override, IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry)
Definition: DnsProtocol.c:1597
EFI_STATUS Dns4CopyConfigure(OUT EFI_DNS4_CONFIG_DATA *Dst, IN EFI_DNS4_CONFIG_DATA *Src)
Definition: DnsImpl.c:438
EFI_COMPONENT_NAME_PROTOCOL gDnsComponentName
Definition: ComponentName.c:99
EFI_STATUS EFIAPI AddDns4ServerIp(IN LIST_ENTRY *Dns4ServerList, IN EFI_IPv4_ADDRESS ServerIp)
Definition: DnsImpl.c:957
EFI_STATUS Dns6CopyConfigure(OUT EFI_DNS6_CONFIG_DATA *Dst, IN EFI_DNS6_CONFIG_DATA *Src)
Definition: DnsImpl.c:480
VOID EFIAPI DnsOnTimerUpdate(IN EFI_EVENT Event, IN VOID *Context)
Definition: DnsImpl.c:2219
VOID EFIAPI DnsOnPacketReceived(NET_BUF *Packet, UDP_END_POINT *EndPoint, EFI_STATUS IoStatus, VOID *Context)
Definition: DnsImpl.c:1804
EFI_STATUS Dns6RemoveTokenEntry(IN NET_MAP *TokenMap, IN DNS6_TOKEN_ENTRY *TokenEntry)
Definition: DnsImpl.c:58
EFI_STATUS EFIAPI Dns6GetModeData(IN EFI_DNS6_PROTOCOL *This, OUT EFI_DNS6_MODE_DATA *DnsModeData)
Definition: DnsProtocol.c:903
EFI_STATUS Dns4ConfigUdp(IN DNS_INSTANCE *Instance, IN UDP_IO *UdpIo)
Definition: DnsImpl.c:666
VOID EFIAPI DnsOnPacketSent(NET_BUF *Packet, UDP_END_POINT *EndPoint, EFI_STATUS IoStatus, VOID *Context)
Definition: DnsImpl.c:1862
VOID Dns4CleanConfigure(IN OUT EFI_DNS4_CONFIG_DATA *Config)
Definition: DnsImpl.c:397
EFI_STATUS EFIAPI Dns6CancelTokens(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Arg OPTIONAL)
Definition: DnsImpl.c:160
BOOLEAN Dns4GetMapping(IN DNS_INSTANCE *Instance, IN UDP_IO *UdpIo, IN EFI_UDP4_CONFIG_DATA *UdpCfgData)
Definition: DnsImpl.c:540
EFI_STATUS EFIAPI Dns4Poll(IN EFI_DNS4_PROTOCOL *This)
Definition: DnsProtocol.c:798
VOID EFIAPI DnsDummyExtFree(IN VOID *Arg)
Definition: DnsImpl.c:518
BOOLEAN IsValidDnsResponse(IN NET_MAP *TokensMap, IN UINT16 Identification, IN UINT16 Type, IN UINT16 Class, OUT NET_MAP_ITEM **Item)
Definition: DnsImpl.c:1069
EFI_STATUS EFIAPI Dns6HostNameToIp(IN EFI_DNS6_PROTOCOL *This, IN CHAR16 *HostName, IN EFI_DNS6_COMPLETION_TOKEN *Token)
Definition: DnsProtocol.c:1179
EFI_STATUS EFIAPI UpdateDns4Cache(IN LIST_ENTRY *Dns4CacheList, IN BOOLEAN DeleteFlag, IN BOOLEAN Override, IN EFI_DNS4_CACHE_ENTRY DnsCacheEntry)
Definition: DnsImpl.c:762
EFI_STATUS EFIAPI Dns6Poll(IN EFI_DNS6_PROTOCOL *This)
Definition: DnsProtocol.c:1650
EFI_STATUS EFIAPI UpdateDns6Cache(IN LIST_ENTRY *Dns6CacheList, IN BOOLEAN DeleteFlag, IN BOOLEAN Override, IN EFI_DNS6_CACHE_ENTRY DnsCacheEntry)
Definition: DnsImpl.c:861
EFI_STATUS EFIAPI Dns4GeneralLookUp(IN EFI_DNS4_PROTOCOL *This, IN CHAR8 *QName, IN UINT16 QType, IN UINT16 QClass, IN EFI_DNS4_COMPLETION_TOKEN *Token)
Definition: DnsProtocol.c:595
EFI_STATUS Dns4RemoveTokenEntry(IN NET_MAP *TokenMap, IN DNS4_TOKEN_ENTRY *TokenEntry)
Definition: DnsImpl.c:23
EFI_STATUS EFIAPI Dns4GetModeData(IN EFI_DNS4_PROTOCOL *This, OUT EFI_DNS4_MODE_DATA *DnsModeData)
Definition: DnsProtocol.c:50
VOID EFIAPI DnsOnTimerRetransmit(IN EFI_EVENT Event, IN VOID *Context)
Definition: DnsImpl.c:2098
EFI_STATUS EFIAPI Dns6GeneralLookUp(IN EFI_DNS6_PROTOCOL *This, IN CHAR8 *QName, IN UINT16 QType, IN UINT16 QClass, IN EFI_DNS6_COMPLETION_TOKEN *Token)
Definition: DnsProtocol.c:1444
EFI_STATUS EFIAPI Dns4IpToHostName(IN EFI_DNS4_PROTOCOL *This, IN EFI_IPv4_ADDRESS IpAddress, IN EFI_DNS4_COMPLETION_TOKEN *Token)
Definition: DnsProtocol.c:557
BOOLEAN Dns6GetMapping(IN DNS_INSTANCE *Instance, IN UDP_IO *UdpIo, IN EFI_UDP6_CONFIG_DATA *UdpCfgData)
Definition: DnsImpl.c:592
EFI_STATUS Dns6ConfigUdp(IN DNS_INSTANCE *Instance, IN UDP_IO *UdpIo)
Definition: DnsImpl.c:714
EFI_STATUS EFIAPI GetDns6TokenEntry(IN NET_MAP *TokensMap, IN EFI_DNS6_COMPLETION_TOKEN *Token, OUT DNS6_TOKEN_ENTRY **TokenEntry)
Definition: DnsImpl.c:251
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37