mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2025-04-15 04:08:38 +01:00
Remove unnecessary parens in network stack.
This commit is contained in:
parent
c114aeff41
commit
bc30fdc12f
10 changed files with 47 additions and 47 deletions
Binary file not shown.
|
@ -129,7 +129,7 @@ U0 ARPLocalIPV4Set(U32 ip_address)
|
|||
|
||||
ARPSend(ARP_REPLY,
|
||||
ethernet_globals.ethernet_broadcast,
|
||||
EthernetMACGet(),
|
||||
EthernetMACGet,
|
||||
arp_globals.local_ipv4,
|
||||
ethernet_globals.ethernet_broadcast,
|
||||
arp_globals.local_ipv4);
|
||||
|
@ -185,7 +185,7 @@ I64 ARPHandler(CEthernetFrame *ethernet_frame)
|
|||
NetLog("ARP HANDLER: Saw request, sending back reply.");
|
||||
ARPSend(ARP_REPLY,
|
||||
header->sender_hardware_addr,
|
||||
EthernetMACGet(),
|
||||
EthernetMACGet,
|
||||
arp_globals.local_ipv4,
|
||||
header->sender_hardware_addr,
|
||||
header->sender_protocol_addr);
|
||||
|
|
|
@ -74,7 +74,7 @@ class CDHCPRequestOptions
|
|||
|
||||
U32 DHCPTransactionBegin()
|
||||
{
|
||||
return RandU32();
|
||||
return RandU32;
|
||||
}
|
||||
|
||||
I64 DHCPDiscoverSend(U32 xid)
|
||||
|
@ -111,7 +111,7 @@ I64 DHCPDiscoverSend(U32 xid)
|
|||
dhcp->your_ip = 0;
|
||||
dhcp->server_ip = 0;
|
||||
dhcp->gateway_ip = 0;
|
||||
MemCopy(dhcp->client_hw_addr, EthernetMACGet(), MAC_ADDRESS_LENGTH);
|
||||
MemCopy(dhcp->client_hw_addr, EthernetMACGet, MAC_ADDRESS_LENGTH);
|
||||
|
||||
opts = ethernet_frame + sizeof(CDHCPHeader);
|
||||
|
||||
|
@ -163,7 +163,7 @@ I64 DHCPRequestSend(U32 xid, U32 requested_ip, U32 server_ip)
|
|||
dhcp->your_ip = 0;
|
||||
dhcp->server_ip = EndianU32(server_ip);
|
||||
dhcp->gateway_ip = 0;
|
||||
MemCopy(dhcp->client_hw_addr, EthernetMACGet(), MAC_ADDRESS_LENGTH);
|
||||
MemCopy(dhcp->client_hw_addr, EthernetMACGet, MAC_ADDRESS_LENGTH);
|
||||
|
||||
opts = ethernet_frame + sizeof(CDHCPHeader);
|
||||
|
||||
|
@ -286,7 +286,7 @@ I64 DHCPOfferParse(U32 xid, U8 *data, I64 length,
|
|||
NetLog("DHCP PARSE OFFER: Parsed Option, Type DNS.");
|
||||
if (value_length == 4)
|
||||
{
|
||||
*dns_ip_out = EndianU32(*(value(U32 *))); // TODO: this syntax used on last 3 cases is gross, alter it
|
||||
*dns_ip_out = EndianU32(*value(U32 *)); // TODO: this syntax used on last 3 cases is gross, alter it
|
||||
have_dns = TRUE;
|
||||
}
|
||||
break;
|
||||
|
@ -295,7 +295,7 @@ I64 DHCPOfferParse(U32 xid, U8 *data, I64 length,
|
|||
NetLog("DHCP PARSE OFFER: Parsed Option, Type ROUTER.");
|
||||
if (value_length == 4)
|
||||
{
|
||||
*router_ip_out = EndianU32(*(value(U32 *))); //
|
||||
*router_ip_out = EndianU32(*value(U32 *)); //
|
||||
have_router = TRUE;
|
||||
}
|
||||
break;
|
||||
|
@ -304,7 +304,7 @@ I64 DHCPOfferParse(U32 xid, U8 *data, I64 length,
|
|||
NetLog("DHCP PARSE OFFER: Parsed Option, Type SUBNET MASK.");
|
||||
if (value_length == 4)
|
||||
{
|
||||
*subnet_mask_out = EndianU32(*(value(U32 *))); //
|
||||
*subnet_mask_out = EndianU32(*value(U32 *)); //
|
||||
have_subnet = TRUE;
|
||||
}
|
||||
break;
|
||||
|
@ -400,7 +400,7 @@ I64 DHCPInnerConfigure(CUDPSocket *udp_socket,
|
|||
return -1;
|
||||
}
|
||||
|
||||
xid = DHCPTransactionBegin();
|
||||
xid = DHCPTransactionBegin;
|
||||
|
||||
while (state != DHCP_STATE_CLIENT_REQ_ACCEPTED)
|
||||
{
|
||||
|
@ -519,7 +519,7 @@ U0 NetConfigure()
|
|||
I64 error;
|
||||
|
||||
NetLog("\n==== Configuring Network. ====\n");
|
||||
error = DHCPConfigure();
|
||||
error = DHCPConfigure;
|
||||
|
||||
if (error < 0)
|
||||
NetErr("==== Network Configure Failed ====");
|
||||
|
|
|
@ -130,17 +130,17 @@ U0 DNSQuestionSerialize(U8 *buffer, CDNSQuestion *q)
|
|||
{
|
||||
label = q->q_name.labels[i];
|
||||
|
||||
*(buffer++) = StrLen(label);
|
||||
*buffer++ = StrLen(label);
|
||||
|
||||
while (*label)
|
||||
*(buffer++) = *(label++);
|
||||
*buffer++ = *label++;
|
||||
}
|
||||
|
||||
*(buffer++) = 0;
|
||||
*(buffer++) = q->q_type >> 8;
|
||||
*(buffer++) = q->q_type & 0xFF;
|
||||
*(buffer++) = q->q_class >> 8;
|
||||
*(buffer++) = q->q_class & 0xFF;
|
||||
*buffer++ = 0;
|
||||
*buffer++ = q->q_type >> 8;
|
||||
*buffer++ = q->q_type & 0xFF;
|
||||
*buffer++ = q->q_class >> 8;
|
||||
*buffer++ = q->q_class & 0xFF;
|
||||
}
|
||||
|
||||
I64 DNSQuestionSend(U16 id, U16 local_port, CDNSQuestion *q)
|
||||
|
@ -173,7 +173,7 @@ I64 DNSQuestionSend(U16 id, U16 local_port, CDNSQuestion *q)
|
|||
|
||||
// UDPPacketAllocate currently only accepts IPV4 ...
|
||||
de_index = UDPPacketAllocate(&frame,
|
||||
IPV4AddressGet(),
|
||||
IPV4AddressGet,
|
||||
local_port,
|
||||
*ipv4_addr,
|
||||
53,
|
||||
|
@ -184,7 +184,7 @@ I64 DNSQuestionSend(U16 id, U16 local_port, CDNSQuestion *q)
|
|||
return de_index;
|
||||
}
|
||||
|
||||
flags = (DNS_OP_QUERY << 11) | DNS_FLAG_RD;
|
||||
flags = DNS_OP_QUERY << 11 | DNS_FLAG_RD;
|
||||
|
||||
header = frame;
|
||||
|
||||
|
@ -225,7 +225,7 @@ I64 DNSDomainNameParse(U8 *packet_data, I64 packet_length, U8 **data_inout, I64
|
|||
|
||||
while (length)
|
||||
{
|
||||
label_len = *(data++);
|
||||
label_len = *data++;
|
||||
length--;
|
||||
|
||||
if (label_len == 0)
|
||||
|
@ -242,7 +242,7 @@ I64 DNSDomainNameParse(U8 *packet_data, I64 packet_length, U8 **data_inout, I64
|
|||
NetLog("DNS PARSE DOMAIN NAME: Jump taken");
|
||||
}
|
||||
|
||||
data = packet_data + ((label_len << 8) | *data);
|
||||
data = packet_data + (label_len << 8 | *data);
|
||||
length = packet_data + packet_length - data;
|
||||
}
|
||||
else
|
||||
|
@ -287,8 +287,8 @@ I64 DNSQuestionParse(U8 *packet_data, I64 packet_length, U8 **data_inout, I64 *l
|
|||
return -1;
|
||||
|
||||
q_out->next = NULL;
|
||||
q_out->q_type = (data[1] << 8) | data[0];
|
||||
q_out->q_class = (data[3] << 8) | data[2];
|
||||
q_out->q_type = data[1] << 8 | data[0];
|
||||
q_out->q_class = data[3] << 8 | data[2];
|
||||
|
||||
*data_inout = data + 4;
|
||||
*length_inout = length - 4;
|
||||
|
|
|
@ -42,7 +42,7 @@ U0 EthernetFrameParse(CEthernetFrame *frame_out, U8 *frame, U16 length)
|
|||
|
||||
MemCopy(frame_out->source_address, frame + MAC_ADDRESS_LENGTH, MAC_ADDRESS_LENGTH);
|
||||
|
||||
frame_out->ethertype = frame[ETHERNET_ETHERTYPE_OFFSET + 1] | (frame[ETHERNET_ETHERTYPE_OFFSET] << 8);
|
||||
frame_out->ethertype = frame[ETHERNET_ETHERTYPE_OFFSET + 1] | frame[ETHERNET_ETHERTYPE_OFFSET] << 8;
|
||||
|
||||
frame_out->data = frame + ETHERNET_DATA_OFFSET;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ U0 ICMPReplySend(U32 destination_ip_address,
|
|||
|
||||
de_index = IPV4PacketAllocate(&frame,
|
||||
IP_PROTOCOL_ICMP,
|
||||
IPV4AddressGet(),
|
||||
IPV4AddressGet,
|
||||
destination_ip_address,
|
||||
sizeof(CICMPHeader) + length);
|
||||
if (de_index < 0)
|
||||
|
|
|
@ -71,20 +71,20 @@ U16 IPV4Checksum(U8 *header, I64 length)
|
|||
|
||||
while (nleft > 1)
|
||||
{
|
||||
sum += *(w++);
|
||||
sum += *w++;
|
||||
nleft -= 2;
|
||||
}
|
||||
|
||||
// "mop up an odd byte, if necessary"
|
||||
if (nleft == 1)
|
||||
{
|
||||
sum += ((*w) & 0x00FF);
|
||||
sum += *w & 0x00FF;
|
||||
}
|
||||
|
||||
// "add back carry outs from top 16 bits to low 16 bits"
|
||||
sum = (sum >> 16) + (sum & 0xFFFF); // "add hi 16 to low 16"
|
||||
sum += (sum >> 16); // add carry
|
||||
return (~sum) & 0xFFFF;
|
||||
sum = sum >> 16 + sum & 0xFFFF; // "add hi 16 to low 16"
|
||||
sum += sum >> 16; // add carry
|
||||
return ~sum & 0xFFFF;
|
||||
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ I64 IPV4AddressMACGet(U32 ip_address, U8 **mac_out)
|
|||
}
|
||||
|
||||
// "outside this subnet; needs routing"
|
||||
if ((ip_address & ipv4_globals.ipv4_subnet_mask) != (ipv4_globals.local_ip & ipv4_globals.ipv4_subnet_mask))
|
||||
if (ip_address & ipv4_globals.ipv4_subnet_mask != ipv4_globals.local_ip & ipv4_globals.ipv4_subnet_mask)
|
||||
{
|
||||
// TODO: Shrine recurses here... and says FIXME infinite loop if mis-configured...
|
||||
NetWarn("GET MAC FOR IP: TODO: Doing IPV4AddressMACGet recursion, could infinite loop and overflow stack.");
|
||||
|
@ -183,7 +183,7 @@ I64 IPV4PacketAllocate(U8 **frame_out,
|
|||
}
|
||||
|
||||
de_index = EthernetFrameAllocate(ðernet_frame,
|
||||
EthernetMACGet(),
|
||||
EthernetMACGet,
|
||||
destination_mac_address,
|
||||
ETHERTYPE_IPV4,
|
||||
sizeof(CIPV4Header) + length);
|
||||
|
@ -197,7 +197,7 @@ I64 IPV4PacketAllocate(U8 **frame_out,
|
|||
|
||||
header = ethernet_frame;
|
||||
|
||||
header->version_ihl = internet_header_length | (4 << 4);// whaaat the fuck is this? #define!
|
||||
header->version_ihl = internet_header_length | 4 << 4;// ? TODO: needs #define
|
||||
header->dscp_ecn = 0; // a clear define of what this actually means would be good
|
||||
header->total_length = EndianU16(internet_header_length * 4 + length); //...why?
|
||||
header->identification = 0; // define would be clearer
|
||||
|
|
|
@ -71,7 +71,7 @@ interrupt U0 NetHandler()
|
|||
NetLog("$$BD,LTGRAY$$$$FD,WHITE$$"
|
||||
"NET HANDLER: Entering interrupt.");
|
||||
|
||||
while (entry = NetQueuePull())
|
||||
while (entry = NetQueuePull)
|
||||
{
|
||||
NetLog("NET HANDLER: Caught NetQueue Entry, handling.");
|
||||
NetQueueEntryHandle(entry);
|
||||
|
|
|
@ -141,8 +141,8 @@ U0 PCNetReset()
|
|||
which, regardless of which mode the card is in,
|
||||
will reset it back to 16-bit mode. */
|
||||
|
||||
InU32(PCNetIOBaseGet() + PCNET_DW_RESET);
|
||||
InU16(PCNetIOBaseGet() + PCNET_WD_RESET);
|
||||
InU32(PCNetIOBaseGet + PCNET_DW_RESET);
|
||||
InU16(PCNetIOBaseGet + PCNET_WD_RESET);
|
||||
Busy(5); // OSDev says minimum 1 æS
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ U0 PCNet32BitModeEnable()
|
|||
to RDP will cause 16-bit mode exit
|
||||
and immediate enter into 32-bit mode. */
|
||||
|
||||
OutU32(PCNetIOBaseGet() + PCNET_DW_RDP, 0);
|
||||
OutU32(PCNetIOBaseGet + PCNET_DW_RDP, 0);
|
||||
}
|
||||
|
||||
U0 PCNetRAPWrite(U32 value)
|
||||
|
@ -161,7 +161,7 @@ U0 PCNetRAPWrite(U32 value)
|
|||
value will indicate which CSR / BCR register
|
||||
we want to access in RDP / BDP. */
|
||||
|
||||
OutU32(PCNetIOBaseGet() + PCNET_DW_RAP, value);
|
||||
OutU32(PCNetIOBaseGet + PCNET_DW_RAP, value);
|
||||
}
|
||||
|
||||
U0 PCNetCSRWrite(U32 csr, U32 value)
|
||||
|
@ -172,7 +172,7 @@ U0 PCNetCSRWrite(U32 csr, U32 value)
|
|||
in the RAP. */
|
||||
|
||||
PCNetRAPWrite(csr);
|
||||
OutU32(PCNetIOBaseGet() + PCNET_DW_RDP, value);
|
||||
OutU32(PCNetIOBaseGet + PCNET_DW_RDP, value);
|
||||
}
|
||||
|
||||
U32 PCNetCSRRead(U32 csr)
|
||||
|
@ -183,7 +183,7 @@ U32 PCNetCSRRead(U32 csr)
|
|||
in the RAP. */
|
||||
|
||||
PCNetRAPWrite(csr);
|
||||
return InU32(PCNetIOBaseGet() + PCNET_DW_RDP);
|
||||
return InU32(PCNetIOBaseGet + PCNET_DW_RDP);
|
||||
}
|
||||
|
||||
U0 PCNetSWStyleSet()
|
||||
|
@ -214,7 +214,7 @@ U0 PCNetMACGet()
|
|||
NetLog("PCNET GET MAC: Getting VM MAC.");
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
pcnet.mac_address[i] = InU8(PCNetIOBaseGet() + i);
|
||||
pcnet.mac_address[i] = InU8(PCNetIOBaseGet + i);
|
||||
NetLog(" %02X", pcnet.mac_address[i]);
|
||||
}
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ I64 PCNetTransmitPacketAllocate(U8 **packet_buffer_out, I64 length)
|
|||
|
||||
pcnet.current_tx_de_index = (pcnet.current_tx_de_index + 1) & (PCNET_TX_BUFF_COUNT - 1);
|
||||
|
||||
*packet_buffer_out = pcnet.tx_buffer_addr + (de_index * ETHERNET_FRAME_SIZE);
|
||||
*packet_buffer_out = pcnet.tx_buffer_addr + de_index * ETHERNET_FRAME_SIZE;
|
||||
|
||||
MemSet(*packet_buffer_out, 0, ETHERNET_FRAME_SIZE); // Clear buffer contents in advance.
|
||||
|
||||
|
@ -539,7 +539,7 @@ I64 PCNetPacketReceive(U8 **packet_buffer_out, U16 *packet_length_out)
|
|||
|
||||
pcnet.current_rx_de_index = (pcnet.current_rx_de_index + 1) & (PCNET_RX_BUFF_COUNT - 1);
|
||||
|
||||
*packet_buffer_out = pcnet.rx_buffer_addr + (de_index * ETHERNET_FRAME_SIZE);
|
||||
*packet_buffer_out = pcnet.rx_buffer_addr + de_index * ETHERNET_FRAME_SIZE;
|
||||
*packet_length_out = packet_length;
|
||||
|
||||
return de_index;
|
||||
|
@ -666,7 +666,7 @@ U0 PCNetInit()
|
|||
|
||||
PCNetTXAutoPadEnable;
|
||||
|
||||
PCNetCSRWrite(0, PCNetCSRRead(0) | 1 | (1<<6));
|
||||
PCNetCSRWrite(0, PCNetCSRRead(0) | 1 | 1 << 6); // ?
|
||||
|
||||
csr = PCNetCSRRead(PCNET_CSR_CTRLSTATUS);
|
||||
NetLog("PCNET INIT UPLOAD: what is INIT ?: %d", Bt(&csr, PCNET_CTRL_INIT));
|
||||
|
@ -674,7 +674,7 @@ U0 PCNetInit()
|
|||
NetLog("PCNET INIT UPLOAD: what is STOP ?: %d", Bt(&csr, PCNET_CTRL_STOP));
|
||||
NetLog("PCNET INIT UPLOAD: what is RINT ?: %d", Bt(&csr, PCNET_CTRL_RINT));
|
||||
|
||||
while (!(PCNetCSRRead(0) & (1 << 8)))
|
||||
while (!(PCNetCSRRead(0) & 1 << 8)) // ?
|
||||
Yield;
|
||||
|
||||
PCNetConfigModeExit;
|
||||
|
|
|
@ -38,7 +38,7 @@ I64 PCPSendMapRequest(U16 internal_port, U16 external_port=NULL, U32 external_ip
|
|||
I64 i;
|
||||
|
||||
de_index = UDPPacketAllocate(&frame,
|
||||
IPV4AddressGet(),
|
||||
IPV4AddressGet,
|
||||
5351,
|
||||
ipv4_globals.ipv4_router_address,
|
||||
5351,
|
||||
|
@ -62,7 +62,7 @@ I64 PCPSendMapRequest(U16 internal_port, U16 external_port=NULL, U32 external_ip
|
|||
for (; i < 10 + 2; i++) // next 16 bits 1
|
||||
request->header.pcp_client_ip[i] = 0xFF;
|
||||
|
||||
*(&request->header.pcp_client_ip[i](U32 *)) = EndianU32(IPV4AddressGet());
|
||||
*(&request->header.pcp_client_ip[i](U32 *)) = EndianU32(IPV4AddressGet);
|
||||
//
|
||||
|
||||
// set random 'nonce'
|
||||
|
|
Loading…
Reference in a new issue