2007-09-30 05:08:02 +02:00
|
|
|
/** @file
|
|
|
|
|
2009-01-16 01:09:52 +01:00
|
|
|
Copyright (c) 2005 - 2006, Intel Corporation.<BR>
|
2007-09-30 05:08:02 +02:00
|
|
|
All rights reserved. This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef __EFI_IP4_INPUT_H__
|
|
|
|
#define __EFI_IP4_INPUT_H__
|
|
|
|
|
2008-11-11 10:23:25 +01:00
|
|
|
typedef enum {
|
2007-09-30 05:08:02 +02:00
|
|
|
IP4_MIN_HEADLEN = 20,
|
|
|
|
IP4_MAX_HEADLEN = 60,
|
|
|
|
|
|
|
|
IP4_ASSEMLE_HASH_SIZE = 31,
|
|
|
|
IP4_FRAGMENT_LIFE = 120,
|
|
|
|
IP4_MAX_PACKET_SIZE = 65535
|
2008-11-11 10:23:25 +01:00
|
|
|
} IP4_INPUT_ENUM_TYPES;
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Per packet information for input process. LinkFlag specifies whether
|
|
|
|
/// the packet is received as Link layer unicast, multicast or broadcast.
|
|
|
|
/// The CastType is the IP layer cast type, such as IP multicast or unicast.
|
|
|
|
/// Start, End and Length are staffs used to assemble the packets. Start
|
|
|
|
/// is the sequence number of the first byte of data in the packet. Length
|
|
|
|
/// is the number of bytes of data. End = Start + Length, that is, the
|
|
|
|
/// sequence number of last byte + 1. Each assembled packet has a count down
|
|
|
|
/// life. If it isn't consumed before Life reaches zero, the packet is released.
|
|
|
|
///
|
2007-09-30 05:08:02 +02:00
|
|
|
typedef struct {
|
|
|
|
UINTN LinkFlag;
|
|
|
|
INTN CastType;
|
|
|
|
INTN Start;
|
|
|
|
INTN End;
|
|
|
|
INTN Length;
|
|
|
|
UINT32 Life;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
} IP4_CLIP_INFO;
|
|
|
|
|
2008-11-11 10:23:25 +01:00
|
|
|
///
|
|
|
|
/// Structure used to assemble IP packets.
|
|
|
|
///
|
2007-09-30 05:08:02 +02:00
|
|
|
typedef struct {
|
2008-02-14 10:40:22 +01:00
|
|
|
LIST_ENTRY Link;
|
2007-09-30 05:08:02 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Identity of one IP4 packet. Each fragment of a packet has
|
|
|
|
// the same (Dst, Src, Id, Protocol).
|
|
|
|
//
|
|
|
|
IP4_ADDR Dst;
|
|
|
|
IP4_ADDR Src;
|
|
|
|
UINT16 Id;
|
|
|
|
UINT8 Protocol;
|
|
|
|
|
|
|
|
INTN TotalLen;
|
|
|
|
INTN CurLen;
|
2008-02-14 10:40:22 +01:00
|
|
|
LIST_ENTRY Fragments; // List of all the fragments of this packet
|
2007-09-30 05:08:02 +02:00
|
|
|
|
|
|
|
IP4_HEAD *Head; // IP head of the first fragment
|
|
|
|
IP4_CLIP_INFO *Info; // Per packet info of the first fragment
|
|
|
|
INTN Life; // Count down life for the packet.
|
|
|
|
} IP4_ASSEMBLE_ENTRY;
|
|
|
|
|
2008-11-11 10:23:25 +01:00
|
|
|
///
|
|
|
|
/// Each Ip service instance has an assemble table to reassemble
|
|
|
|
/// the packets before delivery to its children. It is organized
|
|
|
|
/// as hash table.
|
|
|
|
///
|
2007-09-30 05:08:02 +02:00
|
|
|
typedef struct {
|
2008-02-14 10:40:22 +01:00
|
|
|
LIST_ENTRY Bucket[IP4_ASSEMLE_HASH_SIZE];
|
2007-09-30 05:08:02 +02:00
|
|
|
} IP4_ASSEMBLE_TABLE;
|
|
|
|
|
|
|
|
#define IP4_GET_CLIP_INFO(Packet) ((IP4_CLIP_INFO *) ((Packet)->ProtoData))
|
|
|
|
|
|
|
|
#define IP4_ASSEMBLE_HASH(Dst, Src, Id, Proto) \
|
|
|
|
(((Dst) + (Src) + ((Id) << 16) + (Proto)) % IP4_ASSEMLE_HASH_SIZE)
|
|
|
|
|
|
|
|
#define IP4_RXDATA_WRAP_SIZE(NumFrag) \
|
|
|
|
(sizeof (IP4_RXDATA_WRAP) + sizeof (EFI_IP4_FRAGMENT_DATA) * ((NumFrag) - 1))
|
|
|
|
|
2008-11-18 10:29:44 +01:00
|
|
|
/**
|
|
|
|
Initialize an already allocated assemble table. This is generally
|
|
|
|
the assemble table embedded in the IP4 service instance.
|
|
|
|
|
2009-01-16 01:09:52 +01:00
|
|
|
@param[in, out] Table The assemble table to initialize.
|
2008-11-18 10:29:44 +01:00
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
Ip4InitAssembleTable (
|
2008-11-18 10:29:44 +01:00
|
|
|
IN OUT IP4_ASSEMBLE_TABLE *Table
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-11-18 10:29:44 +01:00
|
|
|
/**
|
|
|
|
Clean up the assemble table: remove all the fragments
|
|
|
|
and assemble entries.
|
|
|
|
|
2009-01-16 01:09:52 +01:00
|
|
|
@param[in] Table The assemble table to clean up
|
2008-11-18 10:29:44 +01:00
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
Ip4CleanAssembleTable (
|
|
|
|
IN IP4_ASSEMBLE_TABLE *Table
|
|
|
|
);
|
|
|
|
|
2008-11-18 10:29:44 +01:00
|
|
|
/**
|
|
|
|
The IP4 input routine. It is called by the IP4_INTERFACE when a
|
|
|
|
IP4 fragment is received from MNP.
|
|
|
|
|
2009-01-16 01:09:52 +01:00
|
|
|
@param[in] Ip4Instance The IP4 child that request the receive, most like
|
2008-11-18 10:29:44 +01:00
|
|
|
it is NULL.
|
2009-01-16 01:09:52 +01:00
|
|
|
@param[in] Packet The IP4 packet received.
|
|
|
|
@param[in] IoStatus The return status of receive request.
|
|
|
|
@param[in] Flag The link layer flag for the packet received, such
|
2008-11-18 10:29:44 +01:00
|
|
|
as multicast.
|
2009-01-16 01:09:52 +01:00
|
|
|
@param[in] Context The IP4 service instance that own the MNP.
|
2008-11-18 10:29:44 +01:00
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
Ip4AccpetFrame (
|
|
|
|
IN IP4_PROTOCOL *Ip4Instance,
|
|
|
|
IN NET_BUF *Packet,
|
|
|
|
IN EFI_STATUS IoStatus,
|
|
|
|
IN UINT32 Flag,
|
|
|
|
IN VOID *Context
|
|
|
|
);
|
|
|
|
|
2008-11-18 10:29:44 +01:00
|
|
|
/**
|
|
|
|
Demultiple the packet. the packet delivery is processed in two
|
|
|
|
passes. The first pass will enque a shared copy of the packet
|
|
|
|
to each IP4 child that accepts the packet. The second pass will
|
|
|
|
deliver a non-shared copy of the packet to each IP4 child that
|
|
|
|
has pending receive requests. Data is copied if more than one
|
|
|
|
child wants to consume the packet because each IP child needs
|
|
|
|
its own copy of the packet to make changes.
|
|
|
|
|
2009-01-16 01:09:52 +01:00
|
|
|
@param[in] IpSb The IP4 service instance that received the packet
|
|
|
|
@param[in] Head The header of the received packet
|
|
|
|
@param[in] Packet The data of the received packet
|
2008-11-18 10:29:44 +01:00
|
|
|
|
|
|
|
@retval EFI_NOT_FOUND No IP child accepts the packet
|
|
|
|
@retval EFI_SUCCESS The packet is enqueued or delivered to some IP
|
|
|
|
children.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
EFI_STATUS
|
|
|
|
Ip4Demultiplex (
|
2008-11-18 10:29:44 +01:00
|
|
|
IN IP4_SERVICE *IpSb,
|
2007-09-30 05:08:02 +02:00
|
|
|
IN IP4_HEAD *Head,
|
|
|
|
IN NET_BUF *Packet
|
|
|
|
);
|
|
|
|
|
2008-11-18 10:29:44 +01:00
|
|
|
/**
|
|
|
|
Enqueue a received packet to all the IP children that share
|
|
|
|
the same interface.
|
|
|
|
|
2009-01-16 01:09:52 +01:00
|
|
|
@param[in] IpSb The IP4 service instance that receive the packet
|
|
|
|
@param[in] Head The header of the received packet
|
|
|
|
@param[in] Packet The data of the received packet
|
|
|
|
@param[in] IpIf The interface to enqueue the packet to
|
2008-11-18 10:29:44 +01:00
|
|
|
|
|
|
|
@return The number of the IP4 children that accepts the packet
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
INTN
|
|
|
|
Ip4InterfaceEnquePacket (
|
2008-11-18 10:29:44 +01:00
|
|
|
IN IP4_SERVICE *IpSb,
|
2007-09-30 05:08:02 +02:00
|
|
|
IN IP4_HEAD *Head,
|
|
|
|
IN NET_BUF *Packet,
|
2008-11-18 10:29:44 +01:00
|
|
|
IN IP4_INTERFACE *IpIf
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-11-18 10:29:44 +01:00
|
|
|
/**
|
|
|
|
Deliver the received packets to upper layer if there are both received
|
|
|
|
requests and enqueued packets. If the enqueued packet is shared, it will
|
|
|
|
duplicate it to a non-shared packet, release the shared packet, then
|
|
|
|
deliver the non-shared packet up.
|
|
|
|
|
2009-01-16 01:09:52 +01:00
|
|
|
@param[in] IpInstance The IP child to deliver the packet up.
|
2008-11-18 10:29:44 +01:00
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES Failed to allocate resources to deliver the
|
|
|
|
packets.
|
|
|
|
@retval EFI_SUCCESS All the enqueued packets that can be delivered
|
|
|
|
are delivered up.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
EFI_STATUS
|
|
|
|
Ip4InstanceDeliverPacket (
|
2008-11-18 10:29:44 +01:00
|
|
|
IN IP4_PROTOCOL *IpInstance
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-11-18 10:29:44 +01:00
|
|
|
/**
|
|
|
|
Timeout the fragment and enqueued packets.
|
|
|
|
|
2009-01-16 01:09:52 +01:00
|
|
|
@param[in] IpSb The IP4 service instance to timeout
|
2008-11-18 10:29:44 +01:00
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
Ip4PacketTimerTicking (
|
|
|
|
IN IP4_SERVICE *IpSb
|
|
|
|
);
|
|
|
|
|
|
|
|
#endif
|