mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-25 15:10:28 +00:00
Fix loopback crashes.
This commit is contained in:
parent
3bdb731dad
commit
ea9e921b62
6 changed files with 46 additions and 11 deletions
|
@ -24,8 +24,8 @@ U0 ChatMessageTask(I64)
|
|||
while (message = StrGet("> ",, SGF_SHIFT_ESC_EXIT))
|
||||
{
|
||||
DocBottom(chat_display_task->put_doc);
|
||||
DocPrint(chat_display_task->put_doc,
|
||||
"$$BG,BLUE$$$$BLACK$$<local>$$FG$$$$BG$$ %s\n", message);
|
||||
// DocPrint(chat_display_task->put_doc,
|
||||
// "$$BG,BLUE$$$$BLACK$$<local>$$FG$$$$BG$$ %s\n", message);
|
||||
|
||||
TCPSocketSendString(tcp, message);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ U0 ChatServerBroadcast(CTCPSocket *tcp_socket, I64 length)
|
|||
{
|
||||
dest_socket = conn->socket;
|
||||
|
||||
if (dest_socket != tcp_socket)
|
||||
// if (dest_socket != tcp_socket)
|
||||
{
|
||||
addr.address = EndianU32(dest_socket->destination_address(CSocketAddressIPV4).address.address);
|
||||
|
||||
|
@ -51,7 +51,10 @@ U0 ChatServerBroadcast(CTCPSocket *tcp_socket, I64 length)
|
|||
ip_string = NetworkToPresentation(AF_INET, &addr);
|
||||
// TODO: is NetworkToPresentation backwards? or, do socket addrs store BE or LE ?
|
||||
|
||||
message_prefix = MStrPrint("$$BG,PURPLE$$$$BLACK$$<%s>$$FG$$$$BG$$ %%0%dts", ip_string, length);
|
||||
if (dest_socket == tcp_socket)
|
||||
message_prefix = MStrPrint("$$BG,PURPLE$$$$BLACK$$<%s (you)>$$FG$$$$BG$$ %%0%dts", ip_string, length);
|
||||
else
|
||||
message_prefix = MStrPrint("$$BG,PURPLE$$$$BLACK$$<%s>$$FG$$$$BG$$ %%0%dts", ip_string, length);
|
||||
|
||||
message = MStrPrint(message_prefix, buffer);
|
||||
|
||||
|
|
|
@ -54,12 +54,17 @@ U0 EthernetFrameParse(CEthernetFrame *frame_out, U8 *frame, U16 length)
|
|||
|
||||
U0 EthernetFrameFinish(I64 de_index)
|
||||
{//Alias for generic driver Finish TX function.
|
||||
U8 *data = NetDriverPacketBufferGet(de_index);
|
||||
I64 length = NetDriverPacketLengthGet(de_index);
|
||||
U8 *mac = EthernetMACGet();
|
||||
Bool is_loopback = !MemCompare(mac, data, MAC_ADDRESS_LENGTH); // check the TX packet MAC against local MAC
|
||||
|
||||
// check the TX packet MAC against local MAC, if they match: software loopback the TX packet to RX NetQueue
|
||||
if (!MemCompare(EthernetMACGet(), NetDriverPacketBufferGet(de_index), MAC_ADDRESS_LENGTH))
|
||||
NetQueuePush(NetDriverPacketBufferGet(de_index), NetDriverPacketLengthGet(de_index));
|
||||
// software loopback the TX packet to RX NetQueue if it's loopback
|
||||
if (is_loopback)
|
||||
NetQueueLazyPush(data, length);
|
||||
|
||||
NetDriverTransmitPacketFinish(de_index);
|
||||
|
||||
}
|
||||
|
||||
EthernetGlobalsInit;
|
||||
EthernetGlobalsInit;
|
||||
|
|
|
@ -68,5 +68,32 @@ U0 NetQueuePush(U8 *data, I64 length)
|
|||
MPInt(I_NETHANDLER, INT_DEST_CPU);
|
||||
}
|
||||
|
||||
U0 NetQueueLazyPull()
|
||||
{
|
||||
PUSHFD
|
||||
CLI
|
||||
|
||||
if (net_queue->next != net_queue)
|
||||
{
|
||||
NetLog("NETQUEUE LAZY PULL: Generating NetHandler interrupt.");
|
||||
MPInt(I_NETHANDLER, INT_DEST_CPU);
|
||||
}
|
||||
|
||||
POPFD
|
||||
}
|
||||
|
||||
U0 NetQueueLazyPush(U8 *data, I64 length)
|
||||
{ // Push into NetQueue, don't trigger interrupt in this func.
|
||||
// Trigger interrupt by Spawn-ing another Task to check queue.
|
||||
|
||||
CNetQueueEntry *entry = CAlloc(sizeof(CNetQueueEntry));
|
||||
|
||||
entry->packet_length = length;
|
||||
MemCopy(entry->frame, data, length);
|
||||
QueueInsert(entry, net_queue->last);
|
||||
|
||||
Spawn(&NetQueueLazyPull,, "NetQueueLazyPull");
|
||||
}
|
||||
|
||||
NetQueueInit;
|
||||
|
||||
NetQueueInit;
|
|
@ -14,7 +14,7 @@ U8 *rev_bits_table; //Table with U8 bits reversed
|
|||
CDate local_time_offset;
|
||||
F64 *pow10_I64,
|
||||
sys_os_version = 2.03;
|
||||
U64 sys_os_version_sub = 107;
|
||||
U64 sys_os_version_sub = 108;
|
||||
U8 *sys_os_version_str;
|
||||
U8 *sys_os_version_full;
|
||||
U8 *sys_os_version_nice;
|
||||
|
|
|
@ -15,7 +15,7 @@ U0 LoadDocDefines()
|
|||
//$LK,"DD_BOOT_HIGH_LOC_DVD",A="FF:::/System/Boot/BootDVD.ZC,DD_BOOT_HIGH_LOC_DVD"$
|
||||
|
||||
$TR,"LineRep"$
|
||||
$ID,2$DefinePrint("DD_ZEALOS_LOC","98,756");
|
||||
$ID,2$DefinePrint("DD_ZEALOS_LOC","99,737");
|
||||
$ID,-2$
|
||||
DefinePrint("DD_MP_VECT", "%08X", MP_VECT_ADDR);
|
||||
DefinePrint("DD_MP_VECT_END", "%08X", MP_VECT_ADDR + COREAP_16BIT_INIT_END - COREAP_16BIT_INIT - 1);
|
||||
|
|
Loading…
Reference in a new issue