2021-07-03 05:07:57 +01:00
<!DOCTYPE HTML>
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html;charset=US-ASCII" >
2021-12-31 03:21:33 +00:00
< meta name = "generator" content = "ZealOS V1.08" >
2021-07-03 05:07:57 +01:00
< style type = "text/css" >
2021-10-08 07:06:11 +01:00
body {background-color:#1f1f1f;}
.cF0{color:#e3e3e3;background-color:#1f1f1f;}
.cF1{color:#4f84a6;background-color:#1f1f1f;}
.cF2{color:#73a255;background-color:#1f1f1f;}
.cF3{color:#297582;background-color:#1f1f1f;}
.cF4{color:#b34f4b;background-color:#1f1f1f;}
.cF5{color:#8a52c3;background-color:#1f1f1f;}
.cF6{color:#b7822f;background-color:#1f1f1f;}
.cF7{color:#444444;background-color:#1f1f1f;}
.cF8{color:#6d6d6d;background-color:#1f1f1f;}
.cF9{color:#94bfde;background-color:#1f1f1f;}
.cFA{color:#a1ce97;background-color:#1f1f1f;}
.cFB{color:#6db4be;background-color:#1f1f1f;}
.cFC{color:#e88e88;background-color:#1f1f1f;}
.cFD{color:#ca94e8;background-color:#1f1f1f;}
.cFE{color:#d4b475;background-color:#1f1f1f;}
.cFF{color:#1f1f1f;background-color:#1f1f1f;}
2021-07-03 05:07:57 +01:00
< / style >
< / head >
< body >
2021-07-05 01:12:38 +01:00
< pre style = "font-family:monospace;font-size:12pt" >
2021-07-03 05:07:57 +01:00
< a name = "l1" > < / a > < span class = cF2 > /***************************************************< / span > < span class = cF0 >
< a name = "l2" > < / a >
< a name = "l3" > < / a > < / span > < span class = cF2 > TCP Bound/Connected Socket Tree Functions< / span > < span class = cF0 >
< a name = "l4" > < / a >
< a name = "l5" > < / a > < / span > < span class = cF2 > ***************************************************/< / span > < span class = cF0 >
< a name = "l6" > < / a >
< a name = "l7" > < / a > CTCPTreeNode *TCPTreeNodeInit()
< a name = "l8" > < / a > { < / span > < span class = cF2 > // init new empty tree/node. Init socket queue head links.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l9" > < / a > CTCPTreeNode *tree_node = < / span > < span class = cF5 > CAlloc< / span > < span class = cF0 > (< / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF0 > CTCPTreeNode< / span > < span class = cF7 > )< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l10" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l11" > < / a > tree_node-> queue = < / span > < span class = cF5 > CAlloc< / span > < span class = cF0 > (< / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF0 > CTCPTreeQueue< / span > < span class = cF7 > )< / span > < span class = cF0 > ); < / span > < span class = cF2 > // CQueue vs CTCPTreeQueue ?...< / span > < span class = cF0 >
< a name = "l12" > < / a > < / span > < span class = cF5 > QueueInit< / span > < span class = cF0 > (tree_node-> queue);
2021-07-03 05:07:57 +01:00
< a name = "l13" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l14" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > tree_node;
2021-07-03 05:07:57 +01:00
< a name = "l15" > < / a > }
< a name = "l16" > < / a >
< a name = "l17" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > TCPTreeNodeAdd(CTCPTreeNode *node, CTCPTreeNode *tree)
< a name = "l18" > < / a > { < / span > < span class = cF2 > // using temp and last allows avoiding recursion and non-growing stack issues.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l19" > < / a > BSTAdd(node, tree);
2021-07-03 05:07:57 +01:00
< a name = "l20" > < / a > }
< a name = "l21" > < / a >
< a name = "l22" > < / a > CTCPTreeNode *TCPTreeNodeParamAdd(< / span > < span class = cF9 > I64< / span > < span class = cF0 > port, CTCPTreeNode *tree)
< a name = "l23" > < / a > { < / span > < span class = cF2 > // add a node using params, return pointer to the node< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l24" > < / a > CTCPTreeNode *result = TCPTreeNodeInit;
2021-07-03 05:07:57 +01:00
< a name = "l25" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l26" > < / a > result-> value = port;
2021-07-03 05:07:57 +01:00
< a name = "l27" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l28" > < / a > TCPTreeNodeAdd(result, tree);
2021-07-03 05:07:57 +01:00
< a name = "l29" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l30" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > result;
2021-07-03 05:07:57 +01:00
< a name = "l31" > < / a > }
< a name = "l32" > < / a >
< a name = "l33" > < / a > CTCPTreeNode *TCPTreeNodeParamInit(< / span > < span class = cF9 > I64< / span > < span class = cF0 > port)
< a name = "l34" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l35" > < / a > CTCPTreeNode *result = TCPTreeNodeInit;
2021-07-03 05:07:57 +01:00
< a name = "l36" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l37" > < / a > result-> value = port;
2021-07-03 05:07:57 +01:00
< a name = "l38" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l39" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > result;
2021-07-03 05:07:57 +01:00
< a name = "l40" > < / a > }
< a name = "l41" > < / a >
< a name = "l42" > < / a > CTCPTreeNode *TCPTreeNodeFind(< / span > < span class = cF9 > I64< / span > < span class = cF0 > port, CTCPTreeNode *tree)
< a name = "l43" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l44" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > BSTFind(port, tree);
2021-07-03 05:07:57 +01:00
< a name = "l45" > < / a > }
< a name = "l46" > < / a >
< a name = "l47" > < / a > CTCPTreeNode *TCPTreeNodePop(< / span > < span class = cF9 > I64< / span > < span class = cF0 > port, CTCPTreeNode *tree)
< a name = "l48" > < / a > { < / span > < span class = cF2 > // Pops whole sub-tree, original tree loses whole branch.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l49" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > BSTPop(port, tree);
2021-07-03 05:07:57 +01:00
< a name = "l50" > < / a > }
< a name = "l51" > < / a >
< a name = "l52" > < / a > CTCPTreeNode *TCPTreeNodeSinglePop(< / span > < span class = cF9 > I64< / span > < span class = cF0 > port, CTCPTreeNode *tree)
2021-07-04 23:11:34 +01:00
< a name = "l53" > < / a > { < / span > < span class = cF2 > // Pop a tree off, then add back in its sub-trees to main tree.< / span > < span class = cF0 >
< a name = "l54" > < / a > < / span > < span class = cF2 > // Original node sub-tree links are cleared.< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l55" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l56" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > BSTSinglePop(port, tree);
2021-07-03 05:07:57 +01:00
< a name = "l57" > < / a > }
< a name = "l58" > < / a >
< a name = "l59" > < / a > < / span > < span class = cF1 > U0< / span > < span class = cF0 > TCPTreeNodeQueueAdd(CTCPSocket *socket, CTCPTreeNode *node)
< a name = "l60" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l61" > < / a > CTCPTreeQueue *new_entry = < / span > < span class = cF5 > CAlloc< / span > < span class = cF0 > (< / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF0 > CTCPTreeQueue< / span > < span class = cF7 > )< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l62" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l63" > < / a > new_entry-> socket = socket;
2021-07-03 05:07:57 +01:00
< a name = "l64" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l65" > < / a > < / span > < span class = cF5 > QueueInsert< / span > < span class = cF0 > (new_entry, node-> queue-> last);
2021-07-03 05:07:57 +01:00
< a name = "l66" > < / a > }
< a name = "l67" > < / a >
< a name = "l68" > < / a > CTCPTreeQueue *TCPTreeNodeQueueSocketFind(CTCPSocket *socket, CTCPTreeNode *node)
< a name = "l69" > < / a > {
2021-07-04 23:11:34 +01:00
< a name = "l70" > < / a > CTCPTreeQueue *temp_queue;
2021-07-03 05:07:57 +01:00
< a name = "l71" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l72" > < / a > temp_queue = node-> queue-> next;
< a name = "l73" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (temp_queue != node-> queue)
< a name = "l74" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l75" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (temp_queue-> socket == socket)
< a name = "l76" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > temp_queue;
< a name = "l77" > < / a > temp_queue = temp_queue-> next;
< a name = "l78" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l79" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l80" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > < / span > < span class = cF3 > NULL< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l81" > < / a > }
< a name = "l82" > < / a >
< a name = "l83" > < / a > CTCPTreeQueue *TCPTreeNodeQueueSocketSinglePop(CTCPSocket *socket, CTCPTreeNode *node)
< a name = "l84" > < / a > { < / span > < span class = cF2 > // search by socket, pop a single TCPTreeQueue off the node, return popped queue.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l85" > < / a > CTCPTreeQueue *temp_queue = TCPTreeNodeQueueSocketFind(socket, node);
2021-07-03 05:07:57 +01:00
< a name = "l86" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l87" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (temp_queue)
< a name = "l88" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l89" > < / a > < / span > < span class = cF5 > QueueRemove< / span > < span class = cF0 > (temp_queue);
2021-07-03 05:07:57 +01:00
< a name = "l90" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l91" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l92" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l93" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > temp_queue; < / span > < span class = cF2 > // if not found, NULL.< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l94" > < / a > }
< a name = "l95" > < / a >
< a name = "l96" > < / a > CTCPTreeQueue *TCPTreeNodeQueueIPV4Find(< / span > < span class = cF9 > U32< / span > < span class = cF0 > address, CTCPTreeNode *node, < / span > < span class = cF1 > Bool< / span > < span class = cF0 > specific=< / span > < span class = cF3 > FALSE< / span > < span class = cF0 > )
2021-07-04 23:11:34 +01:00
< a name = "l97" > < / a > { < / span > < span class = cF2 > // address should be pulled from an instance of CIPV4Address (TODO... double check what bit order we're in ?)< / span > < span class = cF0 >
< a name = "l98" > < / a > < / span > < span class = cF2 > // use TRUE or FALSE in specific arg to dictate how to handle INADDR_ANY.< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l99" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l100" > < / a > CTCPTreeQueue *temp_queue = node-> queue-> next;
< a name = "l101" > < / a > CSocketAddressIPV4 *temp_ip;
2021-07-03 05:07:57 +01:00
< a name = "l102" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l103" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (temp_queue != node-> queue)
< a name = "l104" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l105" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (temp_queue-> socket-> destination_address.family == AF_INET)
< a name = "l106" > < / a > {
< a name = "l107" > < / a > temp_ip = & temp_queue-> socket-> destination_address;
< a name = "l108" > < / a > NetLog(< / span > < span class = cF6 > " TCPTreeNodeQueueIPV4Find: Comparing: addr, nodequeue addr: %08X, %08X" < / span > < span class = cF0 > ,
< a name = "l109" > < / a > address, temp_ip-> address.address);
2021-07-03 05:07:57 +01:00
< a name = "l110" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l111" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (temp_ip-> address.address == address)
< a name = "l112" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l113" > < / a > NetLog(< / span > < span class = cF6 > " TCPTreeNodeQueueIPV4Find: Address match: addr, nodequeue addr: %08X, %08X " < / span > < span class = cF0 > ,
< a name = "l114" > < / a > address, temp_ip-> address.address);
2021-07-03 05:07:57 +01:00
< a name = "l115" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l116" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > temp_queue;
< a name = "l117" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l118" > < / a > }
< a name = "l119" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l120" > < / a > NetErr(< / span > < span class = cF6 > " TCPTreeNodeQueueIPV4Find: Skipped iteration of a non AF_INET family: %0X" < / span > < span class = cF0 > ,
< a name = "l121" > < / a > temp_queue-> socket-> destination_address.family);
2021-07-03 05:07:57 +01:00
< a name = "l122" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l123" > < / a > temp_queue = temp_queue-> next;
< a name = "l124" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l125" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l126" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!specific)
< a name = "l127" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l128" > < / a > temp_queue = node-> queue-> next;
< a name = "l129" > < / a > NetDebug(< / span > < span class = cF6 > " TCPTreeNodeQueueIPV4Find: Exact match not found, looking for an INADDR_ANY address." < / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l130" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l131" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (temp_queue != node-> queue)
< a name = "l132" > < / a > {
< a name = "l133" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (temp_queue-> socket-> destination_address.family == AF_INET)
< a name = "l134" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l135" > < / a > temp_ip = & temp_queue-> socket-> destination_address;
< a name = "l136" > < / a > NetLog(< / span > < span class = cF6 > " TCPTreeNodeQueueIPV4Find: Comparing: addr, nodequeue addr: %08X, %08X" < / span > < span class = cF0 > ,
< a name = "l137" > < / a > address, temp_ip-> address.address);
2021-07-03 05:07:57 +01:00
< a name = "l138" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l139" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (temp_ip-> address.address == INADDR_ANY)
< a name = "l140" > < / a > {
< a name = "l141" > < / a > NetLog(< / span > < span class = cF6 > " TCPTreeNodeQueueIPV4Find: Address match: addr, nodequeue addr: %08X, %08X " < / span > < span class = cF0 > ,
< a name = "l142" > < / a > address, temp_ip-> address.address);
2021-07-03 05:07:57 +01:00
< a name = "l143" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l144" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > temp_queue;
< a name = "l145" > < / a > }
< a name = "l146" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l147" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l148" > < / a > NetErr(< / span > < span class = cF6 > " TCPTreeNodeQueueIPV4Find: Skipped iteration of a non AF_INET family: %0X" < / span > < span class = cF0 > ,
< a name = "l149" > < / a > temp_queue-> socket-> destination_address.family);
2021-07-03 05:07:57 +01:00
< a name = "l150" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l151" > < / a > temp_queue = temp_queue-> next;
< a name = "l152" > < / a > }
< a name = "l153" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l154" > < / a >
< a name = "l155" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l156" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > < / span > < span class = cF3 > NULL< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l157" > < / a > }
< a name = "l158" > < / a >
< / span > < / pre > < / body >
< / html >