]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Library/NetLib.h
Use Mde library and definition instead of some native definitions in NetLib, to simpl...
[mirror_edk2.git] / MdeModulePkg / Include / Library / NetLib.h
CommitLineData
cbf316f2 1/** @file
2
3Copyright (c) 2005 - 2007, Intel Corporation
4All rights reserved. This program and the accompanying materials
5are licensed and made available under the terms and conditions of the BSD License
6which accompanies this distribution. The full text of the license may be found at
7http://opensource.org/licenses/bsd-license.php
8
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12Module Name:
13
14 NetLib.h
15
16Abstract:
17
18 Library for the UEFI network stack.
19
20
21**/
22
23#ifndef _NET_LIB_H_
24#define _NET_LIB_H_
25
26#include <PiDxe.h>
6a690e23 27#include <Library/BaseMemoryLib.h>
28#include <Library/MemoryAllocationLib.h>
cbf316f2 29#include <Protocol/DriverBinding.h>
30#include <Protocol/ComponentName.h>
31#include <Protocol/DriverConfiguration.h>
32#include <Protocol/DriverDiagnostics.h>
36ee91ca 33#include <Protocol/Dpc.h>
34
36ee91ca 35typedef UINT32 IP4_ADDR;
36typedef UINT32 TCP_SEQNO;
37typedef UINT16 TCP_PORTNO;
38
39enum {
40 NET_ETHER_ADDR_LEN = 6,
41 NET_IFTYPE_ETHERNET = 0x01,
42
43 EFI_IP_PROTO_UDP = 0x11,
44 EFI_IP_PROTO_TCP = 0x06,
45 EFI_IP_PROTO_ICMP = 0x01,
46
47 //
48 // The address classfication
49 //
50 IP4_ADDR_CLASSA = 1,
51 IP4_ADDR_CLASSB,
52 IP4_ADDR_CLASSC,
53 IP4_ADDR_CLASSD,
54 IP4_ADDR_CLASSE,
55
56 IP4_MASK_NUM = 33,
57};
58
59#pragma pack(1)
60
61//
62// Ethernet head definition
63//
64typedef struct {
65 UINT8 DstMac [NET_ETHER_ADDR_LEN];
66 UINT8 SrcMac [NET_ETHER_ADDR_LEN];
67 UINT16 EtherType;
68} ETHER_HEAD;
69
70
71//
72// The EFI_IP4_HEADER is hard to use because the source and
73// destination address are defined as EFI_IPv4_ADDRESS, which
74// is a structure. Two structures can't be compared or masked
75// directly. This is why there is an internal representation.
76//
77typedef struct {
36ee91ca 78 UINT8 HeadLen : 4;
79 UINT8 Ver : 4;
36ee91ca 80 UINT8 Tos;
81 UINT16 TotalLen;
82 UINT16 Id;
83 UINT16 Fragment;
84 UINT8 Ttl;
85 UINT8 Protocol;
86 UINT16 Checksum;
87 IP4_ADDR Src;
88 IP4_ADDR Dst;
89} IP4_HEAD;
90
91
92//
93// ICMP head definition. ICMP message is categoried as either an error
94// message or query message. Two message types have their own head format.
95//
96typedef struct {
97 UINT8 Type;
98 UINT8 Code;
99 UINT16 Checksum;
100} IP4_ICMP_HEAD;
101
102typedef struct {
103 IP4_ICMP_HEAD Head;
104 UINT32 Fourth; // 4th filed of the head, it depends on Type.
105 IP4_HEAD IpHead;
106} IP4_ICMP_ERROR_HEAD;
107
108typedef struct {
109 IP4_ICMP_HEAD Head;
110 UINT16 Id;
111 UINT16 Seq;
112} IP4_ICMP_QUERY_HEAD;
113
114
115//
116// UDP header definition
117//
118typedef struct {
119 UINT16 SrcPort;
120 UINT16 DstPort;
121 UINT16 Length;
122 UINT16 Checksum;
123} EFI_UDP4_HEADER;
124
125
126//
127// TCP header definition
128//
129typedef struct {
130 TCP_PORTNO SrcPort;
131 TCP_PORTNO DstPort;
132 TCP_SEQNO Seq;
133 TCP_SEQNO Ack;
36ee91ca 134 UINT8 Res : 4;
135 UINT8 HeadLen : 4;
36ee91ca 136 UINT8 Flag;
137 UINT16 Wnd;
138 UINT16 Checksum;
139 UINT16 Urg;
140} TCP_HEAD;
141
142#pragma pack()
143
144#define NET_MAC_EQUAL(pMac1, pMac2, Len) \
e48e37fc 145 (CompareMem ((pMac1), (pMac2), Len) == 0)
36ee91ca 146
147#define NET_MAC_IS_MULTICAST(Mac, BMac, Len) \
148 (((*((UINT8 *) Mac) & 0x01) == 0x01) && (!NET_MAC_EQUAL (Mac, BMac, Len)))
149
36ee91ca 150#define NTOHL(x) (UINT32)((((UINT32) (x) & 0xff) << 24) | \
151 (((UINT32) (x) & 0xff00) << 8) | \
152 (((UINT32) (x) & 0xff0000) >> 8) | \
153 (((UINT32) (x) & 0xff000000) >> 24))
154
155#define HTONL(x) NTOHL(x)
156
157#define NTOHS(x) (UINT16)((((UINT16) (x) & 0xff) << 8) | \
158 (((UINT16) (x) & 0xff00) >> 8))
159
160#define HTONS(x) NTOHS(x)
36ee91ca 161
162//
163// Test the IP's attribute, All the IPs are in host byte order.
164//
165#define IP4_IS_MULTICAST(Ip) (((Ip) & 0xF0000000) == 0xE0000000)
166#define IP4_IS_LOCAL_BROADCAST(Ip) ((Ip) == 0xFFFFFFFF)
167#define IP4_NET_EQUAL(Ip1, Ip2, NetMask) (((Ip1) & (NetMask)) == ((Ip2) & (NetMask)))
168#define IP4_IS_VALID_NETMASK(Ip) (NetGetMaskLength (Ip) != IP4_MASK_NUM)
169
170//
171// Convert the EFI_IP4_ADDRESS to plain UINT32 IP4 address.
172//
173#define EFI_IP4(EfiIpAddr) (*(IP4_ADDR *) ((EfiIpAddr).Addr))
174#define EFI_NTOHL(EfiIp) (NTOHL (EFI_IP4 ((EfiIp))))
e48e37fc 175#define EFI_IP4_EQUAL(Ip1, Ip2) (CompareMem ((Ip1), (Ip2), sizeof (EFI_IPv4_ADDRESS)) == 0)
36ee91ca 176
177INTN
178NetGetMaskLength (
179 IN IP4_ADDR Mask
180 );
181
182INTN
183NetGetIpClass (
184 IN IP4_ADDR Addr
185 );
186
187BOOLEAN
188Ip4IsUnicast (
189 IN IP4_ADDR Ip,
190 IN IP4_ADDR NetMask
191 );
cbf316f2 192
cbf316f2 193extern IP4_ADDR mIp4AllMasks [IP4_MASK_NUM];
194
cbf316f2 195
772db4bb 196extern EFI_IPv4_ADDRESS mZeroIp4Addr;
197
c4a62a12 198#define NET_IS_DIGIT(Ch) (('0' <= (Ch)) && ((Ch) <= '9'))
199#define NET_ROUNDUP(size, unit) (((size) + (unit) - 1) & (~((unit) - 1)))
6a690e23 200#define NET_IS_LOWER_CASE_CHAR(Ch) (('a' <= (Ch)) && ((Ch) <= 'z'))
201#define NET_IS_UPPER_CASE_CHAR(Ch) (('A' <= (Ch)) && ((Ch) <= 'Z'))
c4a62a12 202
cbf316f2 203//
204// Lock primitives: the stack implements its lock primitives according
205// to the standard EFI enviornment. It will NOT consider multiprocessor.
206//
e48e37fc 207//#define NET_TPL_LOCK TPL_CALLBACK
208//#define NET_TPL_EVENT TPL_NOTIFY
209//#define NET_TPL_RECYCLE TPL_NOTIFY
210//#define NET_TPL_TIMER NET_TPL_LOCK
cbf316f2 211
e48e37fc 212//#define NET_LOCK EFI_LOCK
213//#define NET_LOCK_INIT(x) EfiInitializeLock (x, NET_TPL_LOCK)
214//#define NET_RECYCLE_LOCK_INIT(x) EfiInitializeLock (x, NET_TPL_RECYCLE)
215//#define NET_TRYLOCK(x) EfiAcquireLockOrFail (x)
216//#define NET_UNLOCK(x) EfiReleaseLock (x)
cbf316f2 217
e48e37fc 218//#define NET_RAISE_TPL(x) (gBS->RaiseTPL (x))
219//#define NET_RESTORE_TPL(x) (gBS->RestoreTPL (x))
cbf316f2 220
221#define TICKS_PER_MS 10000U
222#define TICKS_PER_SECOND 10000000U
223
84b5c78e 224#define NET_RANDOM(Seed) ((UINT32) ((UINT32) (Seed) * 1103515245UL + 12345) % 4294967295UL)
cbf316f2 225
226
227UINT32
228NetGetUint32 (
229 IN UINT8 *Buf
230 );
231
232VOID
233NetPutUint32 (
234 IN UINT8 *Buf,
235 IN UINT32 Data
236 );
237
238UINT32
239NetRandomInitSeed (
240 VOID
241 );
242
243
244//
245// Double linked list entry functions, this extends the
246// EFI list functions.
247//
e48e37fc 248//typedef LIST_ENTRY LIST_ENTRY;
cbf316f2 249
e48e37fc 250//#define NetListInit(Head) InitializeListHead(Head)
251//#define NetListInsertHead(Head, Entry) InsertHeadList((Head), (Entry))
252//#define NetListInsertTail(Head, Entry) InsertTailList((Head), (Entry))
253//#define NetListIsEmpty(List) IsListEmpty(List)
cbf316f2 254
255#define NET_LIST_USER_STRUCT(Entry, Type, Field) \
256 _CR(Entry, Type, Field)
257
258#define NET_LIST_USER_STRUCT_S(Entry, Type, Field, Sig) \
259 CR(Entry, Type, Field, Sig)
260
261//
262// Iterate through the doule linked list. It is NOT delete safe
263//
264#define NET_LIST_FOR_EACH(Entry, ListHead) \
265 for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
266
267//
268// Iterate through the doule linked list. This is delete-safe.
269// Don't touch NextEntry. Also, don't use this macro if list
270// entries other than the Entry may be deleted when processing
271// the current Entry.
272//
273#define NET_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
274 for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink; \
275 Entry != (ListHead); \
276 Entry = NextEntry, NextEntry = Entry->ForwardLink \
277 )
278
279//
280// Make sure the list isn't empty before get the frist/last record.
281//
282#define NET_LIST_HEAD(ListHead, Type, Field) \
283 NET_LIST_USER_STRUCT((ListHead)->ForwardLink, Type, Field)
284
285#define NET_LIST_TAIL(ListHead, Type, Field) \
286 NET_LIST_USER_STRUCT((ListHead)->BackLink, Type, Field)
287
e48e37fc 288//#define NetListRemoveEntry(Entry) RemoveEntryList (Entry)
cbf316f2 289
e48e37fc 290LIST_ENTRY*
cbf316f2 291NetListRemoveHead (
e48e37fc 292 LIST_ENTRY *Head
cbf316f2 293 );
294
e48e37fc 295LIST_ENTRY*
cbf316f2 296NetListRemoveTail (
e48e37fc 297 LIST_ENTRY *Head
cbf316f2 298 );
299
300VOID
301NetListInsertAfter (
e48e37fc 302 IN LIST_ENTRY *PrevEntry,
303 IN LIST_ENTRY *NewEntry
cbf316f2 304 );
305
306VOID
307NetListInsertBefore (
e48e37fc 308 IN LIST_ENTRY *PostEntry,
309 IN LIST_ENTRY *NewEntry
cbf316f2 310 );
311
312
313//
314// Object container: EFI network stack spec defines various kinds of
315// tokens. The drivers can share code to manage those objects.
316//
317typedef struct {
e48e37fc 318 LIST_ENTRY Link;
cbf316f2 319 VOID *Key;
320 VOID *Value;
321} NET_MAP_ITEM;
322
323typedef struct {
e48e37fc 324 LIST_ENTRY Used;
325 LIST_ENTRY Recycled;
cbf316f2 326 UINTN Count;
327} NET_MAP;
328
329#define NET_MAP_INCREAMENT 64
330
331VOID
332NetMapInit (
333 IN NET_MAP *Map
334 );
335
336VOID
337NetMapClean (
338 IN NET_MAP *Map
339 );
340
341BOOLEAN
342NetMapIsEmpty (
343 IN NET_MAP *Map
344 );
345
346UINTN
347NetMapGetCount (
348 IN NET_MAP *Map
349 );
350
351EFI_STATUS
352NetMapInsertHead (
353 IN NET_MAP *Map,
354 IN VOID *Key,
355 IN VOID *Value OPTIONAL
356 );
357
358EFI_STATUS
359NetMapInsertTail (
360 IN NET_MAP *Map,
361 IN VOID *Key,
362 IN VOID *Value OPTIONAL
363 );
364
365NET_MAP_ITEM *
366NetMapFindKey (
367 IN NET_MAP *Map,
368 IN VOID *Key
369 );
370
371VOID *
372NetMapRemoveItem (
373 IN NET_MAP *Map,
374 IN NET_MAP_ITEM *Item,
375 OUT VOID **Value OPTIONAL
376 );
377
378VOID *
379NetMapRemoveHead (
380 IN NET_MAP *Map,
381 OUT VOID **Value OPTIONAL
382 );
383
384VOID *
385NetMapRemoveTail (
386 IN NET_MAP *Map,
387 OUT VOID **Value OPTIONAL
388 );
389
390typedef
391EFI_STATUS
392(*NET_MAP_CALLBACK) (
393 IN NET_MAP *Map,
394 IN NET_MAP_ITEM *Item,
395 IN VOID *Arg
396 );
397
398EFI_STATUS
399NetMapIterate (
400 IN NET_MAP *Map,
401 IN NET_MAP_CALLBACK CallBack,
402 IN VOID *Arg OPTIONAL
403 );
404
405
406//
407// Helper functions to implement driver binding and service binding protocols.
408//
409EFI_STATUS
410NetLibCreateServiceChild (
411 IN EFI_HANDLE ControllerHandle,
412 IN EFI_HANDLE ImageHandle,
413 IN EFI_GUID *ServiceBindingGuid,
414 OUT EFI_HANDLE *ChildHandle
415 );
416
417EFI_STATUS
418NetLibDestroyServiceChild (
419 IN EFI_HANDLE ControllerHandle,
420 IN EFI_HANDLE ImageHandle,
421 IN EFI_GUID *ServiceBindingGuid,
422 IN EFI_HANDLE ChildHandle
423 );
424
425EFI_STATUS
426NetLibGetMacString (
427 IN EFI_HANDLE SnpHandle,
428 IN EFI_HANDLE ImageHandle,
4eb65aff 429 IN OUT CHAR16 **MacString
cbf316f2 430 );
431
e5e12de7 432VOID
433NetLibCreateIPv4DPathNode (
434 IN OUT IPv4_DEVICE_PATH *Node,
435 IN EFI_HANDLE Controller,
436 IN IP4_ADDR LocalIp,
437 IN UINT16 LocalPort,
438 IN IP4_ADDR RemoteIp,
439 IN UINT16 RemotePort,
440 IN UINT16 Protocol,
441 IN BOOLEAN UseDefaultAddress
442 );
443
cbf316f2 444EFI_HANDLE
445NetLibGetNicHandle (
446 IN EFI_HANDLE Controller,
447 IN EFI_GUID *ProtocolGuid
448 );
449
36ee91ca 450EFI_STATUS
451NetLibQueueDpc (
452 IN EFI_TPL DpcTpl,
453 IN EFI_DPC_PROCEDURE DpcProcedure,
454 IN VOID *DpcContext OPTIONAL
455 );
456
457EFI_STATUS
458NetLibDispatchDpc (
459 VOID
460 );
461
cbf316f2 462EFI_STATUS
463EFIAPI
464NetLibDefaultUnload (
465 IN EFI_HANDLE ImageHandle
466 );
467
cbf316f2 468enum {
469 //
470 //Various signatures
471 //
472 NET_BUF_SIGNATURE = EFI_SIGNATURE_32 ('n', 'b', 'u', 'f'),
473 NET_VECTOR_SIGNATURE = EFI_SIGNATURE_32 ('n', 'v', 'e', 'c'),
474 NET_QUE_SIGNATURE = EFI_SIGNATURE_32 ('n', 'b', 'q', 'u'),
475
476
477 NET_PROTO_DATA = 64, // Opaque buffer for protocols
478 NET_BUF_HEAD = 1, // Trim or allocate space from head
479 NET_BUF_TAIL = 0, // Trim or allocate space from tail
480 NET_VECTOR_OWN_FIRST = 0x01, // We allocated the 1st block in the vector
481};
482
483#define NET_CHECK_SIGNATURE(PData, SIGNATURE) \
484 ASSERT (((PData) != NULL) && ((PData)->Signature == (SIGNATURE)))
485
486#define NET_SWAP_SHORT(Value) \
487 ((((Value) & 0xff) << 8) | (((Value) >> 8) & 0xff))
488
489//
490// Single memory block in the vector.
491//
492typedef struct {
493 UINT32 Len; // The block's length
494 UINT8 *Bulk; // The block's Data
495} NET_BLOCK;
496
497typedef VOID (*NET_VECTOR_EXT_FREE) (VOID *Arg);
498
499//
500//NET_VECTOR contains several blocks to hold all packet's
501//fragments and other house-keeping stuff for sharing. It
502//doesn't specify the where actual packet fragment begins.
503//
504typedef struct {
505 UINT32 Signature;
506 INTN RefCnt; // Reference count to share NET_VECTOR.
507 NET_VECTOR_EXT_FREE Free; // external function to free NET_VECTOR
508 VOID *Arg; // opeque argument to Free
509 UINT32 Flag; // Flags, NET_VECTOR_OWN_FIRST
510 UINT32 Len; // Total length of the assocated BLOCKs
511
512 UINT32 BlockNum;
513 NET_BLOCK Block[1];
514} NET_VECTOR;
515
516//
517//NET_BLOCK_OP operate on the NET_BLOCK, It specifies
518//where the actual fragment begins and where it ends
519//
520typedef struct {
521 UINT8 *BlockHead; // Block's head, or the smallest valid Head
522 UINT8 *BlockTail; // Block's tail. BlockTail-BlockHead=block length
523 UINT8 *Head; // 1st byte of the data in the block
524 UINT8 *Tail; // Tail of the data in the block, Tail-Head=Size
525 UINT32 Size; // The size of the data
526} NET_BLOCK_OP;
527
528
529//
530//NET_BUF is the buffer manage structure used by the
531//network stack. Every network packet may be fragmented,
532//and contains multiple fragments. The Vector points to
533//memory blocks used by the each fragment, and BlockOp
534//specifies where each fragment begins and ends.
535//
536//It also contains a opaque area for protocol to store
537//per-packet informations. Protocol must be caution not
538//to overwrite the members after that.
539//
540typedef struct {
541 UINT32 Signature;
542 INTN RefCnt;
e48e37fc 543 LIST_ENTRY List; // The List this NET_BUF is on
cbf316f2 544
545 IP4_HEAD *Ip; // Network layer header, for fast access
546 TCP_HEAD *Tcp; // Transport layer header, for fast access
547 UINT8 ProtoData [NET_PROTO_DATA]; //Protocol specific data
548
549 NET_VECTOR *Vector; // The vector containing the packet
550
551 UINT32 BlockOpNum; // Total number of BlockOp in the buffer
552 UINT32 TotalSize; // Total size of the actual packet
553 NET_BLOCK_OP BlockOp[1]; // Specify the position of actual packet
554} NET_BUF;
555
556
557//
558//A queue of NET_BUFs, It is just a thin extension of
559//NET_BUF functions.
560//
561typedef struct {
562 UINT32 Signature;
563 INTN RefCnt;
e48e37fc 564 LIST_ENTRY List; // The List this buffer queue is on
cbf316f2 565
e48e37fc 566 LIST_ENTRY BufList; // list of queued buffers
cbf316f2 567 UINT32 BufSize; // total length of DATA in the buffers
568 UINT32 BufNum; // total number of buffers on the chain
569} NET_BUF_QUEUE;
570
571//
572// Pseudo header for TCP and UDP checksum
573//
574#pragma pack(1)
575typedef struct {
576 IP4_ADDR SrcIp;
577 IP4_ADDR DstIp;
578 UINT8 Reserved;
579 UINT8 Protocol;
580 UINT16 Len;
581} NET_PSEUDO_HDR;
582#pragma pack()
583
584//
585// The fragment entry table used in network interfaces. This is
586// the same as NET_BLOCK now. Use two different to distinguish
587// the two in case that NET_BLOCK be enhanced later.
588//
589typedef struct {
590 UINT32 Len;
591 UINT8 *Bulk;
592} NET_FRAGMENT;
593
594#define NET_GET_REF(PData) ((PData)->RefCnt++)
595#define NET_PUT_REF(PData) ((PData)->RefCnt--)
596#define NETBUF_FROM_PROTODATA(Info) _CR((Info), NET_BUF, ProtoData)
597
598#define NET_BUF_SHARED(Buf) \
599 (((Buf)->RefCnt > 1) || ((Buf)->Vector->RefCnt > 1))
600
601#define NET_VECTOR_SIZE(BlockNum) \
602 (sizeof (NET_VECTOR) + ((BlockNum) - 1) * sizeof (NET_BLOCK))
603
604#define NET_BUF_SIZE(BlockOpNum) \
605 (sizeof (NET_BUF) + ((BlockOpNum) - 1) * sizeof (NET_BLOCK_OP))
606
607#define NET_HEADSPACE(BlockOp) \
608 (UINTN)((BlockOp)->Head - (BlockOp)->BlockHead)
609
610#define NET_TAILSPACE(BlockOp) \
611 (UINTN)((BlockOp)->BlockTail - (BlockOp)->Tail)
612
613NET_BUF *
614NetbufAlloc (
615 IN UINT32 Len
616 );
617
618VOID
619NetbufFree (
620 IN NET_BUF *Nbuf
621 );
622
623
624UINT8 *
625NetbufGetByte (
626 IN NET_BUF *Nbuf,
627 IN UINT32 Offset,
628 OUT UINT32 *Index OPTIONAL
629 );
630
631NET_BUF *
632NetbufClone (
633 IN NET_BUF *Nbuf
634 );
635
636NET_BUF *
637NetbufDuplicate (
638 IN NET_BUF *Nbuf,
639 IN NET_BUF *Duplicate OPTIONAL,
640 IN UINT32 HeadSpace
641 );
642
643NET_BUF *
644NetbufGetFragment (
645 IN NET_BUF *Nbuf,
646 IN UINT32 Offset,
647 IN UINT32 Len,
648 IN UINT32 HeadSpace
649 );
650
651VOID
652NetbufReserve (
653 IN NET_BUF *Nbuf,
654 IN UINT32 Len
655 );
656
657UINT8 *
658NetbufAllocSpace (
659 IN NET_BUF *Nbuf,
660 IN UINT32 Len,
661 IN BOOLEAN FromHead
662 );
663
664UINT32
665NetbufTrim (
666 IN NET_BUF *Nbuf,
667 IN UINT32 Len,
668 IN BOOLEAN FromHead
669 );
670
671UINT32
672NetbufCopy (
673 IN NET_BUF *Nbuf,
674 IN UINT32 Offset,
675 IN UINT32 Len,
676 IN UINT8 *Dest
677 );
678
679NET_BUF *
680NetbufFromExt (
681 IN NET_FRAGMENT *ExtFragment,
682 IN UINT32 ExtNum,
683 IN UINT32 HeadSpace,
684 IN UINT32 HeadLen,
685 IN NET_VECTOR_EXT_FREE ExtFree,
686 IN VOID *Arg OPTIONAL
687 );
688
689EFI_STATUS
690NetbufBuildExt (
691 IN NET_BUF *Nbuf,
692 IN NET_FRAGMENT *ExtFragment,
693 IN UINT32 *ExtNum
694 );
695
696NET_BUF *
697NetbufFromBufList (
e48e37fc 698 IN LIST_ENTRY *BufList,
cbf316f2 699 IN UINT32 HeadSpace,
700 IN UINT32 HeaderLen,
701 IN NET_VECTOR_EXT_FREE ExtFree,
702 IN VOID *Arg OPTIONAL
703 );
704
705VOID
706NetbufFreeList (
e48e37fc 707 IN LIST_ENTRY *Head
cbf316f2 708 );
709
710VOID
711NetbufQueInit (
712 IN NET_BUF_QUEUE *NbufQue
713 );
714
715NET_BUF_QUEUE *
716NetbufQueAlloc (
717 VOID
718 );
719
720VOID
721NetbufQueFree (
722 IN NET_BUF_QUEUE *NbufQue
723 );
724
725NET_BUF *
726NetbufQueRemove (
727 IN NET_BUF_QUEUE *NbufQue
728 );
729
730VOID
731NetbufQueAppend (
732 IN NET_BUF_QUEUE *NbufQue,
733 IN NET_BUF *Nbuf
734 );
735
736UINT32
737NetbufQueCopy (
738 IN NET_BUF_QUEUE *NbufQue,
739 IN UINT32 Offset,
740 IN UINT32 Len,
741 IN UINT8 *Dest
742 );
743
744UINT32
745NetbufQueTrim (
746 IN NET_BUF_QUEUE *NbufQue,
747 IN UINT32 Len
748 );
749
750VOID
751NetbufQueFlush (
752 IN NET_BUF_QUEUE *NbufQue
753 );
754
755UINT16
756NetblockChecksum (
757 IN UINT8 *Bulk,
758 IN UINT32 Len
759 );
760
761UINT16
762NetAddChecksum (
763 IN UINT16 Checksum1,
764 IN UINT16 Checksum2
765 );
766
767UINT16
768NetbufChecksum (
769 IN NET_BUF *Nbuf
770 );
771
772UINT16
773NetPseudoHeadChecksum (
774 IN IP4_ADDR Src,
775 IN IP4_ADDR Dst,
776 IN UINT8 Proto,
777 IN UINT16 Len
778 );
8a67d61d 779
cbf316f2 780#endif