/** @file
The mian interface of IPsec Protocol.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
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
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "IpSecConfigImpl.h"
#include "IpSecImpl.h"
/**
Handles IPsec packet processing for inbound and outbound IP packets.
The EFI_IPSEC_PROCESS process routine handles each inbound or outbound packet.
The behavior is that it can perform one of the following actions:
bypass the packet, discard the packet, or protect the packet.
@param[in] This Pointer to the EFI_IPSEC2_PROTOCOL instance.
@param[in] NicHandle Instance of the network interface.
@param[in] IpVersion IPV4 or IPV6.
@param[in, out] IpHead Pointer to the IP Header.
@param[in, out] LastHead The protocol of the next layer to be processed by IPsec.
@param[in, out] OptionsBuffer Pointer to the options buffer.
@param[in, out] OptionsLength Length of the options buffer.
@param[in, out] FragmentTable Pointer to a list of fragments.
@param[in, out] FragmentCount Number of fragments.
@param[in] TrafficDirection Traffic direction.
@param[out] RecycleSignal Event for recycling of resources.
@retval EFI_SUCCESS The packet was bypassed and all buffers remain the same.
@retval EFI_SUCCESS The packet was protected.
@retval EFI_ACCESS_DENIED The packet was discarded.
**/
)
{
if (OptionsBuffer == NULL ||
OptionsLength == NULL ||
FragmentTable == NULL ||
) {
return EFI_INVALID_PARAMETER;
}
OldLastHead = *LastHead;
*RecycleSignal = NULL;
if (!IsOutbound) {
//
// For inbound traffic, process the ipsec header of the packet.
//
);
//
// The packet is denied to access.
//
goto ON_EXIT;
}
if (Status == EFI_SUCCESS) {
//
// Check the spd entry if the packet is accessible.
//
if (SpdSelector == NULL) {
goto ON_EXIT;
}
if (IsSubSpdSelector (
)) {
}
}
goto ON_EXIT;
}
}
//
// For outbound and non-ipsec Inbound traffic: check the spd entry.
//
if (EFI_ERROR (IpSecLookupSpdEntry (
))) {
//
// If the related SPD not find
//
continue;
}
switch (Action) {
case EfiIPsecActionProtect:
if (IsOutbound) {
//
// For outbound traffic, lookup the sad entry.
//
);
//
// Process the packet by the found sad entry.
//
);
//
// TODO: if no need return not ready to upper layer, change here.
//
}
//
// For inbound icmpv6 traffic except ping request, accept the packet
// although no sad entry associated with protect spd entry.
//
);
}
}
goto ON_EXIT;
case EfiIPsecActionBypass:
goto ON_EXIT;
case EfiIPsecActionDiscard:
goto ON_EXIT;
}
}
//
// If don't find the related SPD entry, return the EFI_ACCESS_DENIED and discard it.
//
if (OldLastHead == IP6_ICMP &&
){
}
return Status;
}