network: Rename net_buffer::flags to msg_flags.

It contains only the MSG_* flags, not any other kind of flags.

Change-Id: Ia4590d87a1638fcdb848ef2b816b047b72ca2836
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7915
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
This commit is contained in:
Augustin Cavalier
2024-07-30 14:54:49 +00:00
committed by waddlesplash
parent 4c62171e88
commit e864e93949
11 changed files with 46 additions and 46 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ typedef struct net_buffer {
uint32 index;
int32 type;
};
uint32 flags;
uint32 msg_flags;
uint32 size;
uint8 protocol;
} net_buffer;
@@ -605,7 +605,7 @@ handle_arp_request(net_buffer *buffer, arp_header &header)
memcpy(LLADDR((sockaddr_dl *)buffer->destination), header.hardware_target,
ETHER_ADDRESS_LENGTH);
buffer->flags = 0;
buffer->msg_flags = 0;
// make sure this won't be a broadcast message
gBufferModule->trim(buffer, sizeof(arp_header));
@@ -820,7 +820,7 @@ arp_start_resolve(arp_protocol* protocol, in_addr_t address, arp_entry** _entry)
source.sdl_alen = ETHER_ADDRESS_LENGTH;
memcpy(source.sdl_data, device->address.data, ETHER_ADDRESS_LENGTH);
entry->request_buffer->flags = MSG_BCAST;
entry->request_buffer->msg_flags = MSG_BCAST;
// this is a broadcast packet, we don't need to fill in the destination
entry->protocol = protocol;
@@ -1024,13 +1024,13 @@ arp_send_data(net_datalink_protocol *_protocol, net_buffer *buffer)
memcpy(buffer->source, &protocol->hardware_address,
protocol->hardware_address.sdl_len);
if ((buffer->flags & MSG_MCAST) != 0) {
if ((buffer->msg_flags & MSG_MCAST) != 0) {
sockaddr_dl multicastDestination;
ipv4_to_ether_multicast(&multicastDestination,
(sockaddr_in *)buffer->destination);
memcpy(buffer->destination, &multicastDestination,
sizeof(multicastDestination));
} else if ((buffer->flags & MSG_BCAST) == 0) {
} else if ((buffer->msg_flags & MSG_BCAST) == 0) {
// Lookup destination (we may need to wait for this)
arp_entry *entry = arp_entry::Lookup(
((struct sockaddr_in *)buffer->destination)->sin_addr.s_addr);
@@ -68,9 +68,9 @@ ethernet_deframe(net_device* device, net_buffer* buffer)
// Mark buffer if it was a broadcast/multicast packet
if (!memcmp(header.destination, kBroadcastAddress, ETHER_ADDRESS_LENGTH))
buffer->flags |= MSG_BCAST;
buffer->msg_flags |= MSG_BCAST;
else if ((header.destination[0] & 0x01) != 0)
buffer->flags |= MSG_MCAST;
buffer->msg_flags |= MSG_MCAST;
// Translate the ethernet specific type to a generic one if possible
switch (type) {
@@ -154,7 +154,7 @@ ethernet_frame_send_data(net_datalink_protocol* protocol, net_buffer* buffer)
header.type = source.sdl_e_type;
memcpy(header.source, LLADDR(&source), ETHER_ADDRESS_LENGTH);
if ((buffer->flags & MSG_BCAST) != 0)
if ((buffer->msg_flags & MSG_BCAST) != 0)
memcpy(header.destination, kBroadcastAddress, ETHER_ADDRESS_LENGTH);
else
memcpy(header.destination, LLADDR(&destination), ETHER_ADDRESS_LENGTH);
@@ -719,7 +719,7 @@ ndp_receive_solicitation(net_buffer* buffer, bool* reuseBuffer)
memcpy(&destination->sin6_addr, &source->sin6_addr, sizeof(in6_addr));
memcpy(&source->sin6_addr, &header.target_address, sizeof(in6_addr));
buffer->flags = 0;
buffer->msg_flags = 0;
// make sure this won't be a broadcast message
if (sIPv6Protocol == NULL)
@@ -737,7 +737,7 @@ static void
ndp_receive_advertisement(net_buffer* buffer)
{
// TODO: also process unsolicited advertisments?
if ((buffer->flags & MSG_MCAST) != 0)
if ((buffer->msg_flags & MSG_MCAST) != 0)
return;
NetBufferHeaderReader<neighbor_discovery_header> bufferHeader(buffer);
@@ -1026,7 +1026,7 @@ ipv6_datalink_send_data(net_datalink_protocol* _protocol, net_buffer* buffer)
memcpy(buffer->source, &protocol->hardware_address,
protocol->hardware_address.sdl_len);
if ((buffer->flags & MSG_MCAST) != 0) {
if ((buffer->msg_flags & MSG_MCAST) != 0) {
sockaddr_dl multicastDestination;
ipv6_to_ether_multicast(&multicastDestination,
(sockaddr_in6*)buffer->destination);
@@ -562,7 +562,7 @@ icmp_error_reply(net_protocol* protocol, net_buffer* buffer, net_error error,
}
// a datagram to an IP multicast or broadcast address,
if ((buffer->flags & (MSG_BCAST | MSG_MCAST)) != 0)
if ((buffer->msg_flags & (MSG_BCAST | MSG_MCAST)) != 0)
return B_ERROR;
// a non-initial fragment
@@ -757,7 +757,7 @@ raw_receive_data(net_buffer* buffer)
TRACE("RawReceiveData(%i)", buffer->protocol);
if ((buffer->flags & MSG_MCAST) != 0) {
if ((buffer->msg_flags & MSG_MCAST) != 0) {
// we need to call deliver_multicast here separately as
// buffer still has the IP header, and it won't in the
// next call. This isn't very optimized but works for now.
@@ -1493,7 +1493,7 @@ ipv4_send_routed_data(net_protocol* _protocol, struct net_route* route,
if (protocol != NULL)
headerIncluded = (protocol->flags & IP_FLAG_HEADER_INCLUDED) != 0;
buffer->flags &= ~(MSG_BCAST | MSG_MCAST);
buffer->msg_flags &= ~(MSG_BCAST | MSG_MCAST);
if (destination.sin_addr.s_addr == INADDR_ANY)
return EDESTADDRREQ;
@@ -1504,9 +1504,9 @@ ipv4_send_routed_data(net_protocol* _protocol, struct net_route* route,
== broadcastAddress->sin_addr.s_addr))) {
if (protocol && !(protocol->socket->options & SO_BROADCAST))
return B_BAD_VALUE;
buffer->flags |= MSG_BCAST;
buffer->msg_flags |= MSG_BCAST;
} else if (IN_MULTICAST(ntohl(destination.sin_addr.s_addr)))
buffer->flags |= MSG_MCAST;
buffer->msg_flags |= MSG_MCAST;
// Add IP header (if needed)
@@ -1522,10 +1522,10 @@ ipv4_send_routed_data(net_protocol* _protocol, struct net_route* route,
header->id = htons(atomic_add(&sPacketID, 1));
header->fragment_offset = 0;
if (protocol) {
header->time_to_live = (buffer->flags & MSG_MCAST) != 0
header->time_to_live = (buffer->msg_flags & MSG_MCAST) != 0
? protocol->multicast_time_to_live : protocol->time_to_live;
} else {
header->time_to_live = (buffer->flags & MSG_MCAST) != 0
header->time_to_live = (buffer->msg_flags & MSG_MCAST) != 0
? kDefaultMulticastTTL : kDefaultTTL;
}
header->protocol = protocol
@@ -1561,7 +1561,7 @@ ipv4_send_routed_data(net_protocol* _protocol, struct net_route* route,
sizeof(ipv4_header), true);
}
if ((buffer->flags & MSG_MCAST) != 0
if ((buffer->msg_flags & MSG_MCAST) != 0
&& (protocol != NULL && protocol->multicast_loopback)) {
// copy an IP multicast packet to the input queue of the loopback
// interface
@@ -1747,22 +1747,22 @@ ipv4_receive_data(net_buffer* buffer)
// lower layers notion of broadcast or multicast have no relevance to us
// other than deciding whether to send an ICMP error
bool wasMulticast = (buffer->flags & (MSG_BCAST | MSG_MCAST)) != 0;
bool wasMulticast = (buffer->msg_flags & (MSG_BCAST | MSG_MCAST)) != 0;
bool notForUs = false;
buffer->flags &= ~(MSG_BCAST | MSG_MCAST);
buffer->msg_flags &= ~(MSG_BCAST | MSG_MCAST);
sockaddr_in destination;
fill_sockaddr_in(&destination, header.destination);
if (header.destination == INADDR_BROADCAST) {
buffer->flags |= MSG_BCAST;
buffer->msg_flags |= MSG_BCAST;
// Find first interface with a matching family
if (!sDatalinkModule->is_local_link_address(sDomain, true,
buffer->destination, &buffer->interface_address))
notForUs = !wasMulticast;
} else if (IN_MULTICAST(ntohl(header.destination))) {
buffer->flags |= MSG_MCAST;
buffer->msg_flags |= MSG_MCAST;
} else {
uint32 matchedAddressType = 0;
@@ -1774,12 +1774,12 @@ ipv4_receive_data(net_buffer* buffer)
// if the buffer was a link layer multicast, regard it as a
// broadcast, and let the upper levels decide what to do with it
if (wasMulticast)
buffer->flags |= MSG_BCAST;
buffer->msg_flags |= MSG_BCAST;
else
notForUs = true;
} else {
// copy over special address types (MSG_BCAST or MSG_MCAST):
buffer->flags |= matchedAddressType;
buffer->msg_flags |= matchedAddressType;
}
}
@@ -1848,7 +1848,7 @@ ipv4_receive_data(net_buffer* buffer)
return EAFNOSUPPORT;
}
if ((buffer->flags & MSG_MCAST) != 0) {
if ((buffer->msg_flags & MSG_MCAST) != 0) {
// Unfortunately historical reasons dictate that the IP multicast
// model be a little different from the unicast one. We deliver
// this frame directly to all sockets registered with interest
@@ -1898,16 +1898,16 @@ ipv4_error_received(net_error error, net_buffer* buffer)
// lower layers notion of broadcast or multicast have no relevance to us
// TODO: they actually have when deciding whether to send an ICMP error
buffer->flags &= ~(MSG_BCAST | MSG_MCAST);
buffer->msg_flags &= ~(MSG_BCAST | MSG_MCAST);
fill_sockaddr_in((struct sockaddr_in*)buffer->source, header.source);
fill_sockaddr_in((struct sockaddr_in*)buffer->destination,
header.destination);
if (header.destination == INADDR_BROADCAST)
buffer->flags |= MSG_BCAST;
buffer->msg_flags |= MSG_BCAST;
else if (IN_MULTICAST(ntohl(header.destination)))
buffer->flags |= MSG_MCAST;
buffer->msg_flags |= MSG_MCAST;
// test if the packet is really from us
if (!sDatalinkModule->is_local_address(sDomain, buffer->source, NULL,
@@ -792,7 +792,7 @@ raw_receive_data(net_buffer* buffer)
TRACE("RawReceiveData(%i)", buffer->protocol);
if ((buffer->flags & MSG_MCAST) != 0) {
if ((buffer->msg_flags & MSG_MCAST) != 0) {
deliver_multicast(&gIPv6Module, buffer, true);
} else {
RawSocketList::Iterator iterator = sRawSockets.GetIterator();
@@ -1252,7 +1252,7 @@ ip6_select_hoplimit(net_protocol* _protocol, net_buffer* buffer)
// 3. The system default hoplimit.
ipv6_protocol* protocol = (ipv6_protocol*)_protocol;
const bool isMulticast = buffer->flags & MSG_MCAST;
const bool isMulticast = buffer->msg_flags & MSG_MCAST;
if (protocol) {
return isMulticast ? protocol->multicast_time_to_live
@@ -1283,13 +1283,13 @@ ipv6_send_routed_data(net_protocol* _protocol, struct net_route* route,
sockaddr_in6& source = *(sockaddr_in6*)buffer->source;
sockaddr_in6& destination = *(sockaddr_in6*)buffer->destination;
buffer->flags &= ~(MSG_BCAST | MSG_MCAST);
buffer->msg_flags &= ~(MSG_BCAST | MSG_MCAST);
if (IN6_IS_ADDR_UNSPECIFIED(&destination.sin6_addr))
return EDESTADDRREQ;
if (IN6_IS_ADDR_MULTICAST(&destination.sin6_addr))
buffer->flags |= MSG_MCAST;
buffer->msg_flags |= MSG_MCAST;
uint16 dataLength = buffer->size;
@@ -1469,13 +1469,13 @@ ipv6_receive_data(net_buffer* buffer)
return B_BAD_DATA;
// lower layers notion of Broadcast or Multicast have no relevance to us
buffer->flags &= ~(MSG_BCAST | MSG_MCAST);
buffer->msg_flags &= ~(MSG_BCAST | MSG_MCAST);
sockaddr_in6 destination;
fill_sockaddr_in6(&destination, header.Dst());
if (IN6_IS_ADDR_MULTICAST(&destination.sin6_addr)) {
buffer->flags |= MSG_MCAST;
buffer->msg_flags |= MSG_MCAST;
} else {
uint32 matchedAddressType = 0;
@@ -1497,7 +1497,7 @@ ipv6_receive_data(net_buffer* buffer)
}
// copy over special address types (MSG_BCAST or MSG_MCAST):
buffer->flags |= matchedAddressType;
buffer->msg_flags |= matchedAddressType;
}
// set net_buffer's source/destination address
@@ -1547,7 +1547,7 @@ ipv6_receive_data(net_buffer* buffer)
return EAFNOSUPPORT;
}
if ((buffer->flags & MSG_MCAST) != 0) {
if ((buffer->msg_flags & MSG_MCAST) != 0) {
// Unfortunately historical reasons dictate that the IP multicast
// model be a little different from the unicast one. We deliver
// this frame directly to all sockets registered with interest
@@ -813,7 +813,7 @@ TCPEndpoint::SendData(net_buffer *buffer)
buffer->size, buffer->flags, fSendQueue.Size(), fSendQueue.Free());
T(APICall(this, "senddata"));
const uint32 flags = buffer->flags;
const uint32 flags = buffer->msg_flags;
if ((flags & ~(MSG_DONTWAIT | MSG_OOB | MSG_EOF)) != 0)
return EOPNOTSUPP;
@@ -291,9 +291,9 @@ UdpDomainSupport::DemuxIncomingBuffer(net_buffer *buffer)
// NOTE: multicast is delivered directly to the endpoint
MutexLocker _(fLock);
if ((buffer->flags & MSG_BCAST) != 0)
if ((buffer->msg_flags & MSG_BCAST) != 0)
return _DemuxBroadcast(buffer);
if ((buffer->flags & MSG_MCAST) != 0)
if ((buffer->msg_flags & MSG_MCAST) != 0)
return B_ERROR;
return _DemuxUnicast(buffer);
@@ -303,7 +303,7 @@ UdpDomainSupport::DemuxIncomingBuffer(net_buffer *buffer)
status_t
UdpDomainSupport::DeliverError(status_t error, net_buffer* buffer)
{
if ((buffer->flags & (MSG_BCAST | MSG_MCAST)) != 0)
if ((buffer->msg_flags & (MSG_BCAST | MSG_MCAST)) != 0)
return B_ERROR;
MutexLocker _(fLock);
@@ -609,9 +609,9 @@ dump_buffer(net_buffer* _buffer)
{
net_buffer_private* buffer = (net_buffer_private*)_buffer;
dprintf("buffer %p, size %" B_PRIu32 ", flags %" B_PRIx32 ", stored header "
dprintf("buffer %p, size %" B_PRIu32 ", msg_flags %" B_PRIx32 ", stored header "
"%" B_PRIuSIZE ", interface address %p\n", buffer, buffer->size,
buffer->flags, buffer->stored_header_length, buffer->interface_address);
buffer->msg_flags, buffer->stored_header_length, buffer->interface_address);
dump_address("source", buffer->source, buffer->interface_address);
dump_address("destination", buffer->destination, buffer->interface_address);
@@ -1073,7 +1073,7 @@ copy_metadata(net_buffer* destination, const net_buffer* source)
memcpy(destination->destination, source->destination,
min_c(source->destination->sa_len, sizeof(sockaddr_storage)));
destination->flags = source->flags;
destination->msg_flags = source->msg_flags;
destination->interface_address = source->interface_address;
if (destination->interface_address != NULL)
((InterfaceAddress*)destination->interface_address)->AcquireReference();
@@ -1126,7 +1126,7 @@ create_buffer(size_t headerSpace)
buffer->interface_address = NULL;
buffer->offset = 0;
buffer->flags = 0;
buffer->msg_flags = 0;
buffer->size = 0;
CHECK_BUFFER(buffer);
@@ -1394,7 +1394,7 @@ socket_send(net_socket* socket, msghdr* header, const void* data, size_t length,
}
size_t bufferSize = buffer->size;
buffer->flags = flags;
buffer->msg_flags = flags;
memcpy(buffer->source, &socket->address, socket->address.ss_len);
memcpy(buffer->destination, address, addressLength);
buffer->destination->sa_len = addressLength;