]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.h
1. Enable Network stack to pass SCT, currently MNP, ARP, IP4, TCP4 and DHCP4 have...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Input.h
CommitLineData
772db4bb 1/** @file
2
3Copyright (c) 2005 - 2006, 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 Ip4Input.h
15
16Abstract:
17
18
19**/
20
21#ifndef __EFI_IP4_INPUT_H__
22#define __EFI_IP4_INPUT_H__
23
24enum {
25 IP4_MIN_HEADLEN = 20,
26 IP4_MAX_HEADLEN = 60,
27
28 IP4_ASSEMLE_HASH_SIZE = 31,
29 IP4_FRAGMENT_LIFE = 120,
687a2e5f 30 IP4_MAX_PACKET_SIZE = 65535
772db4bb 31};
32
33//
34// Per packet information for input process. LinkFlag specifies whether
35// the packet is received as Link layer unicast, multicast or broadcast.
36// The CastType is the IP layer cast type, such as IP multicast or unicast.
37// Start, End and Length are staffs used to assemble the packets. Start
38// is the sequence number of the first byte of data in the packet. Length
39// is the number of bytes of data. End = Start + Length, that is, the
40// sequence number of last byte + 1. Each assembled packet has a count down
41// life. If it isn't consumed before Life reaches zero, the packet is released.
42//
43typedef struct {
44 UINTN LinkFlag;
45 INTN CastType;
46 INTN Start;
47 INTN End;
48 INTN Length;
49 UINT32 Life;
50 EFI_STATUS Status;
51} IP4_CLIP_INFO;
52
53//
54// Structure used to assemble IP packets.
55//
56typedef struct {
57 NET_LIST_ENTRY Link;
58
59 //
60 // Identity of one IP4 packet. Each fragment of a packet has
61 // the same (Dst, Src, Id, Protocol).
62 //
63 IP4_ADDR Dst;
64 IP4_ADDR Src;
65 UINT16 Id;
66 UINT8 Protocol;
67
68 INTN TotalLen;
69 INTN CurLen;
70 NET_LIST_ENTRY Fragments; // List of all the fragments of this packet
71
72 IP4_HEAD *Head; // IP head of the first fragment
73 IP4_CLIP_INFO *Info; // Per packet info of the first fragment
74 INTN Life; // Count down life for the packet.
75} IP4_ASSEMBLE_ENTRY;
76
77//
78// Each Ip service instance has an assemble table to reassemble
79// the packets before delivery to its children. It is organized
80// as hash table.
81//
82typedef struct {
83 NET_LIST_ENTRY Bucket[IP4_ASSEMLE_HASH_SIZE];
84} IP4_ASSEMBLE_TABLE;
85
86#define IP4_GET_CLIP_INFO(Packet) ((IP4_CLIP_INFO *) ((Packet)->ProtoData))
87
88#define IP4_ASSEMBLE_HASH(Dst, Src, Id, Proto) \
89 (((Dst) + (Src) + ((Id) << 16) + (Proto)) % IP4_ASSEMLE_HASH_SIZE)
90
91#define IP4_RXDATA_WRAP_SIZE(NumFrag) \
92 (sizeof (IP4_RXDATA_WRAP) + sizeof (EFI_IP4_FRAGMENT_DATA) * ((NumFrag) - 1))
93
94VOID
95Ip4InitAssembleTable (
96 IN IP4_ASSEMBLE_TABLE *Table
97 );
98
99VOID
100Ip4CleanAssembleTable (
101 IN IP4_ASSEMBLE_TABLE *Table
102 );
103
104VOID
105Ip4AccpetFrame (
106 IN IP4_PROTOCOL *Ip4Instance,
107 IN NET_BUF *Packet,
108 IN EFI_STATUS IoStatus,
109 IN UINT32 Flag,
110 IN VOID *Context
111 );
112
113EFI_STATUS
114Ip4Demultiplex (
115 IN IP4_SERVICE *SbInstance,
116 IN IP4_HEAD *Head,
117 IN NET_BUF *Packet
118 );
119
120INTN
121Ip4InterfaceEnquePacket (
122 IN IP4_SERVICE *SbInstance,
123 IN IP4_HEAD *Head,
124 IN NET_BUF *Packet,
125 IN IP4_INTERFACE *Interface
126 );
127
128EFI_STATUS
129Ip4InstanceDeliverPacket (
130 IN IP4_PROTOCOL *Ip4Instance
131 );
132
133VOID
134Ip4PacketTimerTicking (
135 IN IP4_SERVICE *IpSb
136 );
137
138#endif