Code clean up in NetLib:

1. Add GLOBAL_REMOVE_IF_UNREFERENCED to all globals
2. Update NTOHL and NTOHS to be BaseLib func SwapBytes32/SwapBytes16
3. Remove duplicate NET_SWAP_SHORT (to use NTOHS instead)

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9648 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
xdu2
2009-12-30 13:44:11 +00:00
parent 9ae650ef6c
commit 1204fe8319
13 changed files with 473 additions and 475 deletions

View File

@@ -1857,7 +1857,7 @@ IScsiNewScsiCmdPdu (
CopyMem (ScsiCmd->Cdb, Packet->Cdb, sizeof (ScsiCmd->Cdb));
if (Packet->CdbLength > 16) {
Header->Length = NTOHS (Packet->CdbLength - 15);
Header->Length = NTOHS ((UINT16) (Packet->CdbLength - 15));
Header->Type = ISCSI_AHS_TYPE_EXT_CDB;
CopyMem (Header + 1, (UINT8 *) Packet->Cdb + 16, Packet->CdbLength - 16);

View File

@@ -105,6 +105,8 @@ Ip4ProcessIcmpRedirect (
IP4_ROUTE_CACHE_ENTRY *CacheEntry;
IP4_INTERFACE *IpIf;
IP4_ADDR Gateway;
IP4_ADDR Src;
IP4_ADDR Dst;
//
// Find the interface whose IP address is the source of the
@@ -133,11 +135,9 @@ Ip4ProcessIcmpRedirect (
continue;
}
CacheEntry = Ip4FindRouteCache (
Ip4Instance->RouteTable,
NTOHL (Icmp->IpHead.Dst),
NTOHL (Icmp->IpHead.Src)
);
Dst = NTOHL (Icmp->IpHead.Dst);
Src = NTOHL (Icmp->IpHead.Src);
CacheEntry = Ip4FindRouteCache (Ip4Instance->RouteTable, Dst, Src);
//
// Only update the route cache's gateway if the source of the

View File

@@ -561,6 +561,10 @@ Ip4AutoConfigCallBackDpc (
EFI_STATUS Status;
UINTN Len;
UINT32 Index;
IP4_ADDR StationAddress;
IP4_ADDR SubnetMask;
IP4_ADDR SubnetAddress;
IP4_ADDR GatewayAddress;
IpSb = (IP4_SERVICE *) Context;
NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);
@@ -646,11 +650,9 @@ Ip4AutoConfigCallBackDpc (
// Set the default interface's address, then add a directed
// route for it, that is, the route whose nexthop is zero.
//
Status = Ip4SetAddress (
IpIf,
EFI_NTOHL (Data->StationAddress),
EFI_NTOHL (Data->SubnetMask)
);
StationAddress = EFI_NTOHL (Data->StationAddress);
SubnetMask = EFI_NTOHL (Data->SubnetMask);
Status = Ip4SetAddress (IpIf, StationAddress, SubnetMask);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
@@ -658,8 +660,8 @@ Ip4AutoConfigCallBackDpc (
Ip4AddRoute (
IpSb->DefaultRouteTable,
EFI_NTOHL (Data->StationAddress),
EFI_NTOHL (Data->SubnetMask),
StationAddress,
SubnetMask,
IP4_ALLZERO_ADDRESS
);
@@ -669,12 +671,10 @@ Ip4AutoConfigCallBackDpc (
for (Index = 0; Index < Data->RouteTableSize; Index++) {
RouteEntry = &Data->RouteTable[Index];
Ip4AddRoute (
IpSb->DefaultRouteTable,
EFI_NTOHL (RouteEntry->SubnetAddress),
EFI_NTOHL (RouteEntry->SubnetMask),
EFI_NTOHL (RouteEntry->GatewayAddress)
);
SubnetAddress = EFI_NTOHL (RouteEntry->SubnetAddress);
SubnetMask = EFI_NTOHL (RouteEntry->SubnetMask);
GatewayAddress = EFI_NTOHL (RouteEntry->GatewayAddress);
Ip4AddRoute (IpSb->DefaultRouteTable, SubnetAddress, SubnetMask, GatewayAddress);
}
IpSb->State = IP4_SERVICE_CONFIGED;

View File

@@ -73,7 +73,7 @@ Ip4PrependHead (
PacketHead->Ver = 4;
PacketHead->HeadLen = (UINT8) (HeadLen >> 2);
PacketHead->Tos = Head->Tos;
PacketHead->TotalLen = HTONS (Packet->TotalSize);
PacketHead->TotalLen = HTONS ((UINT16) Packet->TotalSize);
PacketHead->Id = HTONS (Head->Id);
PacketHead->Fragment = HTONS (Head->Fragment);
PacketHead->Checksum = 0;

View File

@@ -799,7 +799,7 @@ TcpInput (
Tcb = TcpCloneTcb (Parent);
if (Tcb == NULL) {
DEBUG ((EFI_D_ERROR, "TcpInput: discard a segment because"
"failed to clone a child for TCB%x\n", Tcb));
" failed to clone a child for TCB%x\n", Tcb));
goto DISCARD;
}

View File

@@ -1090,18 +1090,22 @@ TcpInstallDevicePath (
TCP_CB *Tcb;
IPv4_DEVICE_PATH Ip4DPathNode;
EFI_STATUS Status;
TCP_PORTNO LocalPort;
TCP_PORTNO RemotePort;
TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved;
TcpService = TcpProto->TcpService;
Tcb = TcpProto->TcpPcb;
LocalPort = NTOHS (Tcb->LocalEnd.Port);
RemotePort = NTOHS (Tcb->RemoteEnd.Port);
NetLibCreateIPv4DPathNode (
&Ip4DPathNode,
TcpService->ControllerHandle,
Tcb->LocalEnd.Ip,
NTOHS (Tcb->LocalEnd.Port),
LocalPort,
Tcb->RemoteEnd.Ip,
NTOHS (Tcb->RemoteEnd.Port),
RemotePort,
EFI_IP_PROTO_TCP,
Tcb->UseDefaultAddr
);

View File

@@ -586,7 +586,7 @@ Udp4Transmit (
//
Udp4Header->SrcPort = HTONS (ConfigData->StationPort);
Udp4Header->DstPort = HTONS (ConfigData->RemotePort);
Udp4Header->Length = HTONS (Packet->TotalSize);
Udp4Header->Length = HTONS ((UINT16) Packet->TotalSize);
Udp4Header->Checksum = 0;
UdpSessionData = TxData->UdpSessionData;

View File

@@ -1182,7 +1182,7 @@ PxeBcDiscvBootService (
Xid = NET_RANDOM (NetRandomInitSeed ());
Token.Packet->Dhcp4.Header.Xid = HTONL(Xid);
Token.Packet->Dhcp4.Header.Reserved = HTONS((IsBCast) ? 0x8000 : 0);
Token.Packet->Dhcp4.Header.Reserved = HTONS((UINT16) ((IsBCast) ? 0x8000 : 0));
CopyMem (&Token.Packet->Dhcp4.Header.ClientAddr, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS));
Token.RemotePort = Sport;