ZealOS/docs/Home/Net/Protocols/UDP/UDP.HH.html
2021-08-17 02:47:37 -04:00

81 lines
4.6 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V1.00">
<style type="text/css">
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF0>#</span><span class=cF1>define</span><span class=cF0> UDP_MAX_PORT </span><span class=cFE>65535</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a></span><span class=cF1>class</span><span class=cF0> CUDPMessageQueue:</span><span class=cF9>CQueue</span><span class=cF0>
<a name="l4"></a>{ </span><span class=cF2>// each bound socket queues data. recv functions &amp; handler use this.</span><span class=cF0>
<a name="l5"></a> </span><span class=cF1>U8</span><span class=cF0> *data; </span><span class=cF2>// contains the UDP payload data.</span><span class=cF0>
<a name="l6"></a> </span><span class=cF9>I64</span><span class=cF0> data_length; </span><span class=cF2>// size of payload data.</span><span class=cF0>
<a name="l7"></a> </span><span class=cF9>I64</span><span class=cF0> received_length; </span><span class=cF2>// amount of the data received so far.</span><span class=cF0>
<a name="l8"></a> CSocketAddressStorage from_address; </span><span class=cF2>// when UDP Handler sees UDP packet, this is filled with where packet came from.</span><span class=cF0>
<a name="l9"></a> </span><span class=cF2>// recvfrom uses this to fill its address_out parameter.</span><span class=cF0>
<a name="l10"></a>};
<a name="l11"></a>
<a name="l12"></a></span><span class=cF1>class</span><span class=cF0> CUDPSocket
<a name="l13"></a>{
<a name="l14"></a> CSocket *socket;
<a name="l15"></a> CUDPMessageQueue *receive_queue;
<a name="l16"></a> CSocketAddressStorage receive_address; </span><span class=cF2>// based on -&gt;family, cast or assign to a var as IPV4/IPV6 CSocketAddress</span><span class=cF0>
<a name="l17"></a> </span><span class=cF9>I64</span><span class=cF0> receive_timeout_ms;
<a name="l18"></a> </span><span class=cF9>I64</span><span class=cF0> receive_max_timeout;
<a name="l19"></a> </span><span class=cF9>U16</span><span class=cF0> bound_to; </span><span class=cF2>// represents the currently bound port</span><span class=cF0>
<a name="l20"></a>};
<a name="l21"></a>
<a name="l22"></a></span><span class=cF1>class</span><span class=cF0> CUDPTreeQueue:</span><span class=cF9>CQueue</span><span class=cF0>
<a name="l23"></a>{
<a name="l24"></a> CUDPSocket *socket;
<a name="l25"></a>};
<a name="l26"></a>
<a name="l27"></a></span><span class=cF1>class</span><span class=cF0> CUDPTreeNode:CBST
<a name="l28"></a>{
<a name="l29"></a> CUDPTreeQueue *queue;
<a name="l30"></a>};
<a name="l31"></a>
<a name="l32"></a></span><span class=cF1>class</span><span class=cF0> CUDPRepEntry:</span><span class=cF9>CQueue</span><span class=cF0>
<a name="l33"></a>{
<a name="l34"></a> CUDPTreeNode *node;
<a name="l35"></a>};
<a name="l36"></a>
<a name="l37"></a></span><span class=cF1>class</span><span class=cF0> CUDPHeader
<a name="l38"></a>{
<a name="l39"></a> </span><span class=cF9>U16</span><span class=cF0> source_port;
<a name="l40"></a> </span><span class=cF9>U16</span><span class=cF0> destination_port;
<a name="l41"></a> </span><span class=cF9>U16</span><span class=cF0> length;
<a name="l42"></a> </span><span class=cF9>U16</span><span class=cF0> checksum;
<a name="l43"></a>};
<a name="l44"></a>
<a name="l45"></a>
<a name="l46"></a></span><span class=cF1>class</span><span class=cF0> CUDPGlobals
<a name="l47"></a>{
<a name="l48"></a>
<a name="l49"></a> CUDPTreeNode *bound_socket_tree;
<a name="l50"></a>
<a name="l51"></a>} udp_globals;
<a name="l52"></a>
</span></pre></body>
</html>