Files
moslab-code/doc/source/html/classMac__table.html
2025-09-12 15:55:45 +02:00

303 lines
16 KiB
HTML

<!-- HTML header for doxygen 1.9.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.15.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>L4Re Operating System Framework: Mac_table&lt; Size &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
<link href="l4re-awesome.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectlogo"><img alt="Logo" src="L4Re_rgb_logo_quer_hg_h55.png"/></td>
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">L4Re Operating System Framework
</div>
<div id="projectbrief">Interface and Usage Documentation</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.15.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search/",'.html');
</script>
<script type="text/javascript">
$(function() { codefold.init(); });
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(function(){initNavTree('classMac__table.html','',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="headertitle"><div class="title">Mac_table&lt; Size &gt; Class Template Reference<div class="ingroups"><a class="el" href="group__virtio__net__switch.html">Virtio Net Switch</a></div></div></div>
</div><!--header-->
<div class="contents">
<p><a class="el" href="classMac__table.html" title="Mac_table manages a 1:n association between ports and MAC addresses.">Mac_table</a> manages a 1:n association between ports and MAC addresses.
<a href="#details">More...</a></p>
<p><code>#include &lt;<a class="el" href="mac__table_8h_source.html">mac_table.h</a>&gt;</code></p>
<div id="dynsection-0" onclick="return dynsection.toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;"><span class="dynarrow"><span class="arrowhead closed"></span></span>Collaboration diagram for Mac_table&lt; Size &gt;:</div>
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
<div class="center"><iframe scrolling="no" loading="lazy" frameborder="0" src="classMac__table__coll__graph.svg" width="150" height="116"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-pub-methods" class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a6481a7ce121e437f7ccb5ccff51f649e" id="r_a6481a7ce121e437f7ccb5ccff51f649e"><td class="memItemLeft" align="right" valign="top">Port_iface *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a6481a7ce121e437f7ccb5ccff51f649e">lookup</a> (<a class="el" href="classMac__addr.html">Mac_addr</a> dst, <a class="el" href="group__l4__basic__types.html#gae8d67914f723bf843df6f311ad2619a2">l4_uint16_t</a> vlan_id) const</td></tr>
<tr class="memdesc:a6481a7ce121e437f7ccb5ccff51f649e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Find the destination port for a MAC address and VLAN id. <br /></td></tr>
<tr class="memitem:a7a4255cfce83ba656004fd3a34aaaab3" id="r_a7a4255cfce83ba656004fd3a34aaaab3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a7a4255cfce83ba656004fd3a34aaaab3">learn</a> (<a class="el" href="classMac__addr.html">Mac_addr</a> src, Port_iface *port, <a class="el" href="group__l4__basic__types.html#gae8d67914f723bf843df6f311ad2619a2">l4_uint16_t</a> vlan_id)</td></tr>
<tr class="memdesc:a7a4255cfce83ba656004fd3a34aaaab3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Learn a MAC address (add it to the MAC table). <br /></td></tr>
<tr class="memitem:aa81a8de47548581771d85d3f2601c2de" id="r_aa81a8de47548581771d85d3f2601c2de"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa81a8de47548581771d85d3f2601c2de">flush</a> (Port_iface *port)</td></tr>
<tr class="memdesc:aa81a8de47548581771d85d3f2601c2de"><td class="mdescLeft">&#160;</td><td class="mdescRight">Flush all associations with a given port. <br /></td></tr>
</table>
<a name="details" id="details"></a><h2 id="header-details" class="groupheader">Detailed Description</h2>
<div class="textblock"><div class="compoundTemplParams">template&lt;std::size_t Size = 1024U&gt;<br />
class Mac_table&lt; Size &gt;</div><p><a class="el" href="classMac__table.html" title="Mac_table manages a 1:n association between ports and MAC addresses.">Mac_table</a> manages a 1:n association between ports and MAC addresses. </p>
<p>There are different types of devices which might be attached to a port. For a normal device the switch sees exactly one MAC address per port - the MAC address of the device attached to it. But there might be other devices like software bridges attached to the port sending packets with different MAC addresses to the port. Therefore the switch has to manage a 1:n association between ports and MAC addresses. The MAC table manages this association.</p>
<p>When a packet comes in we need to find the destination port for the packet and therefore perform a lookup based on the MAC address.</p>
<p>To prevent unbounded growth of the lookup table, the number of entries is limited. Replacement is done on a round-robin basis. If the capacity was reached, the oldest entry is evicted. </p>
<p class="definition">Definition at line <a class="el" href="mac__table_8h_source.html#l00040">40</a> of file <a class="el" href="mac__table_8h_source.html">mac_table.h</a>.</p>
</div><a name="doc-func-members" id="doc-func-members"></a><h2 id="header-doc-func-members" class="groupheader">Member Function Documentation</h2>
<a id="aa81a8de47548581771d85d3f2601c2de" name="aa81a8de47548581771d85d3f2601c2de"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa81a8de47548581771d85d3f2601c2de">&#9670;&#160;</a></span>flush()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;std::size_t Size = 1024U&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classMac__table.html">Mac_table</a>&lt; Size &gt;::flush </td>
<td>(</td>
<td class="paramtype">Port_iface *</td> <td class="paramname"><span class="paramname"><em>port</em></span></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel inline">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Flush all associations with a given port. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">port</td><td>Pointer to port that is to be flushed</td></tr>
</table>
</dd>
</dl>
<p>This function removes all references to a given port from the MAC table. Since we manage a 1:n association between ports and MAC addresses there might be more than one entry for a given port and we have to iterate over the whole array to delete every reference to the port. </p>
<p class="definition">Definition at line <a class="el" href="mac__table_8h_source.html#l00129">129</a> of file <a class="el" href="mac__table_8h_source.html">mac_table.h</a>.</p>
</div>
</div>
<a id="a7a4255cfce83ba656004fd3a34aaaab3" name="a7a4255cfce83ba656004fd3a34aaaab3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7a4255cfce83ba656004fd3a34aaaab3">&#9670;&#160;</a></span>learn()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;std::size_t Size = 1024U&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classMac__table.html">Mac_table</a>&lt; Size &gt;::learn </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classMac__addr.html">Mac_addr</a></td> <td class="paramname"><span class="paramname"><em>src</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">Port_iface *</td> <td class="paramname"><span class="paramname"><em>port</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__l4__basic__types.html#gae8d67914f723bf843df6f311ad2619a2">l4_uint16_t</a></td> <td class="paramname"><span class="paramname"><em>vlan_id</em></span>&#160;)</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel inline">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Learn a MAC address (add it to the MAC table). </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">src</td><td>MAC address </td></tr>
<tr><td class="paramname">port</td><td>Pointer to the port object that can be used to reach MAC address src </td></tr>
<tr><td class="paramname">vlan_id</td><td>VLAN id of the packet destination.</td></tr>
</table>
</dd>
</dl>
<p>Will evict the oldest learned address from the table if the maximum capacity was reached and if the MAC address was not known yet. The source port of the table entry is always updated to cope with clients that move between ports. </p>
<p class="definition">Definition at line <a class="el" href="mac__table_8h_source.html#l00078">78</a> of file <a class="el" href="mac__table_8h_source.html">mac_table.h</a>.</p>
<p class="reference">References <a class="el" href="compiler_8h_source.html#l00284">L4_UNLIKELY</a>, and <a class="el" href="mac__table_8h_source.html#l00058">lookup()</a>.</p>
<div id="dynsection-1" onclick="return dynsection.toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;"><span class="dynarrow"><span class="arrowhead closed"></span></span>Here is the call graph for this function:</div>
<div id="dynsection-1-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-1-content" class="dyncontent" style="display:none;">
<div class="center"><iframe scrolling="no" loading="lazy" frameborder="0" src="classMac__table_a7a4255cfce83ba656004fd3a34aaaab3_cgraph.svg" width="330" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div>
</div>
<a id="a6481a7ce121e437f7ccb5ccff51f649e" name="a6481a7ce121e437f7ccb5ccff51f649e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6481a7ce121e437f7ccb5ccff51f649e">&#9670;&#160;</a></span>lookup()</h2>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;std::size_t Size = 1024U&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">Port_iface * <a class="el" href="classMac__table.html">Mac_table</a>&lt; Size &gt;::lookup </td>
<td>(</td>
<td class="paramtype"><a class="el" href="classMac__addr.html">Mac_addr</a></td> <td class="paramname"><span class="paramname"><em>dst</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="group__l4__basic__types.html#gae8d67914f723bf843df6f311ad2619a2">l4_uint16_t</a></td> <td class="paramname"><span class="paramname"><em>vlan_id</em></span>&#160;) const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel inline">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Find the destination port for a MAC address and VLAN id. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">dst</td><td>MAC address </td></tr>
<tr><td class="paramname">vlan_id</td><td>VLAN id</td></tr>
</table>
</dd>
</dl>
<dl class="retval"><dt>Return values</dt><dd>
<table class="retval">
<tr><td class="paramname">nullptr</td><td>The MAC address is not known (yet) </td></tr>
<tr><td class="paramname">other</td><td>Pointer to the destination port </td></tr>
</table>
</dd>
</dl>
<p class="definition">Definition at line <a class="el" href="mac__table_8h_source.html#l00058">58</a> of file <a class="el" href="mac__table_8h_source.html">mac_table.h</a>.</p>
<p class="reference">Referenced by <a class="el" href="mac__table_8h_source.html#l00078">learn()</a>.</p>
<div id="dynsection-2" onclick="return dynsection.toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;"><span class="dynarrow"><span class="arrowhead closed"></span></span>Here is the caller graph for this function:</div>
<div id="dynsection-2-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-2-content" class="dyncontent" style="display:none;">
<div class="center"><iframe scrolling="no" loading="lazy" frameborder="0" src="classMac__table_a6481a7ce121e437f7ccb5ccff51f649e_icgraph.svg" width="330" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
</div>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>pkg/virtio-net-switch/server/switch/<a class="el" href="mac__table_8h_source.html">mac_table.h</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="page-nav" class="page-nav-panel">
<div id="page-nav-resize-handle"></div>
<div id="page-nav-tree">
<div id="page-nav-contents">
</div><!-- page-nav-contents -->
</div><!-- page-nav-tree -->
</div><!-- page-nav -->
</div><!-- container -->
<!-- HTML footer for doxygen 1.9.1-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a href="classMac__table.html">Mac_table</a></li>
<li class="footer">Generated on <span class="timestamp"></span> for L4Re Operating System Framework by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.15.0 </li>
</ul>
</div>
</body>
</html>