/* This function is to configure a UDPv6 instance for UdpWrite. */
EFI_STATUS PxeBcConfigUdp6Write(IN EFI_UDP6_PROTOCOL *Udp6, IN EFI_IPv6_ADDRESS *StationIp, IN OUT UINT16 *SrcPort)
/* This function is to configure a UDPv6 instance for UdpWrite. */
EFI_STATUS PxeBcConfigUdp6Write(IN EFI_UDP6_PROTOCOL *Udp6, IN EFI_IPv6_ADDRESS *StationIp, IN OUT UINT16 *SrcPort)
{
  EFI_UDP6_CONFIG_DATA  CfgData;
  EFI_STATUS            Status;
  ZeroMem (&CfgData, sizeof (EFI_UDP6_CONFIG_DATA));
  CfgData.ReceiveTimeout     = PXEBC_DEFAULT_LIFETIME;
  CfgData.TransmitTimeout    = PXEBC_DEFAULT_LIFETIME;
  CfgData.HopLimit           = PXEBC_DEFAULT_HOPLIMIT;
  CfgData.AllowDuplicatePort = TRUE;
  CfgData.StationPort        = *SrcPort;
  CopyMem (&CfgData.StationAddress, StationIp, sizeof (EFI_IPv6_ADDRESS));
  Udp6->Configure (Udp6, NULL);
  Status = Udp6->Configure (Udp6, &CfgData);
  if (EFI_ERROR (Status)) {
    return Status;
  }
  if (!EFI_ERROR (Status) && (*SrcPort == 0)) {
    Udp6->GetModeData (Udp6, &CfgData, NULL, NULL, NULL);
    *SrcPort = CfgData.StationPort;
  }
  return Status;
}