import Player 17.0.1 module sources

This commit is contained in:
Michal Kubecek 2023-02-04 16:36:04 +01:00
parent 26ef6aa460
commit 1e7ce4caf4
2 changed files with 40 additions and 30 deletions

View File

@ -3289,13 +3289,13 @@ ProcessOutgoingIPv4Packet(SMACPacket *packet, // IN: cloned packet to process
*/
dhcpFlags |= 0x8000;
if (!SetPacketByte(packet, ethHeaderLen + ipHeaderLen +
UDP_HEADER_LEN + 11, dhcpFlags & 0xff) ||
!SetPacketByte(packet, ethHeaderLen + ipHeaderLen +
UDP_HEADER_LEN + 10, dhcpFlags >> 8)) {
VNETKdPrint((MODULE_NAME "ProcessOutgoing: couldn't set "
"new UDP flags, non-checksum case\n"));
return;
if (!SetPacketByte(packet, ethHeaderLen + ipHeaderLen +
UDP_HEADER_LEN + 11, dhcpFlags & 0xff) ||
!SetPacketByte(packet, ethHeaderLen + ipHeaderLen +
UDP_HEADER_LEN + 10, dhcpFlags >> 8)) {
VNETKdPrint((MODULE_NAME "ProcessOutgoing: couldn't set "
"new UDP flags, non-checksum case\n"));
return;
}
}
}
@ -3303,7 +3303,7 @@ ProcessOutgoingIPv4Packet(SMACPacket *packet, // IN: cloned packet to process
#ifdef DBG
{
uint32 IPDestAddr;
if (!GetPacketData(packet, ethHeaderLen + IP_HEADER_DEST_ADDR_OFFSET,
if (!GetPacketData(packet, ethHeaderLen + IP_HEADER_DEST_ADDR_OFFSET,
sizeof IPDestAddr, &IPDestAddr)) {
VNETKdPrint((MODULE_NAME "ProcessOutgoing: couldn't get "
"IP dest addr\n"));
@ -4614,11 +4614,16 @@ GetSystemUptime(SMACState *state) // IN: smac state
*----------------------------------------------------------------------
*/
static INLINE uint32
static INLINE uint32
GetPacketLength(SMACPacket *packet) // IN: packet
{
ASSERT(packet);
#ifdef _WIN32
if (packet == NULL) {
return 0;
}
return packet->buf1Len + packet->buf2Len;
#elif defined __linux__
ASSERT(packet->skb);
@ -4682,12 +4687,14 @@ GetPacketData(SMACPacket *packet, // IN: packet to copy from
data = ((uint8*)data) + copyLength;
length -= copyLength;
}
/* copy any remaining data from second buffer */
/* copy any remaining data from second buffer */
if (length) {
copyOffset = offset - packet->buf1Len;
copyLength = length;
MEMCPY(data, ((uint8*)packet->buf2) + copyOffset, copyLength);
}
if (data && packet->buf2) {
MEMCPY(data, ((uint8*)packet->buf2) + copyOffset, copyLength);
}
}
#elif __linux__
@ -4740,8 +4747,8 @@ ClonePacket(SMACPackets *packets) // IN: struct in which to clone packet
if (packets->orig.buf1Len) {
MEMCPY(packetClone->data, packets->orig.buf1, packets->orig.buf1Len);
}
if (packets->orig.buf2Len) {
MEMCPY(packetClone->data + packets->orig.buf1Len, packets->orig.buf2,
if (packets->orig.buf2Len && packets->orig.buf2) {
MEMCPY((uint8 *)packetClone->data + packets->orig.buf1Len, packets->orig.buf2,
packets->orig.buf2Len);
}
@ -4859,15 +4866,19 @@ SetPacketByte(SMACPacket *packet, // IN: packet
uint8 data) // IN: data to set
{
ASSERT(packet);
#ifdef _WIN32
if (packet == NULL || packet->buf1 == NULL || packet->buf2 == NULL) {
return FALSE;
}
/* check length, be sure to handle case where offset = -1, length > 0 */
if (offset > GetPacketLength(packet)) {
/* packet not long enough for data */
return FALSE;
}
/* if offset starts in the first buffer, then copy from first buffer */
/* if offset starts in the first buffer, then copy from first buffer */
if (offset < packet->buf1Len) {
((uint8*)packet->buf1)[offset] = data;
} else {

View File

@ -1,5 +1,5 @@
/*********************************************************
* Copyright (C) 2007 VMware, Inc. All rights reserved.
* Copyright (C) 2007, 2023 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@ -60,10 +60,12 @@ typedef struct VNetEvent_EventNode VNetEvent_EventNode;
struct VNetEvent_EventNode {
VNetEvent_EventNode *nextEvent;
VNet_EventHeader event;
union {
VNet_EventHeader header;
VNet_LinkStateEvent lse;
} event;
};
#define EVENT_NODE_HEADER_SIZE offsetof(struct VNetEvent_EventNode, event)
struct VNetEvent_Mechanism {
VNetKernel_SpinLock lock; /* mechanism lock */
@ -369,6 +371,10 @@ VNetEvent_Send(VNetEvent_Sender *s, // IN: a sender
return VNetKernel_EINVAL;
}
if (e->size > sizeof(p->event)) {
return VNetKernel_EINVAL;
}
/* lock */
VNetKernel_SpinLockAcquire(&m->lock);
m->handlerTask = VNetKernel_ThreadCurrent();
@ -378,22 +384,15 @@ VNetEvent_Send(VNetEvent_Sender *s, // IN: a sender
while (TRUE) {
p = *q;
if (p == NULL ||
(p->event.eventId == e->eventId && p->event.type == e->type)) {
(p->event.header.eventId == e->eventId && p->event.header.type == e->type)) {
break;
}
q = &p->nextEvent;
}
/* remove previously sent event */
if (p != NULL && p->event.size != e->size) {
*q = p->nextEvent;
VNetKernel_MemoryFree(p);
p = NULL;
}
/* insert new event into event list*/
if (p == NULL) {
p = VNetKernel_MemoryAllocate(EVENT_NODE_HEADER_SIZE + e->size);
p = VNetKernel_MemoryAllocate(sizeof(*p));
if (p == NULL) {
m->handlerTask = NULL;
VNetKernel_SpinLockRelease(&m->lock);
@ -485,8 +484,8 @@ VNetEvent_CreateListener(VNetEvent_Mechanism *m, // IN: a mechanism
while (s != NULL) {
e = s->firstEvent;
while (e != NULL) {
if ((e->event.classSet & classMask) != 0) {
h(data, &e->event);
if ((e->event.header.classSet & classMask) != 0) {
h(data, &e->event.header);
}
e = e->nextEvent;
}