{% if filetype_loop == 0 %}Interface,Client,EAP Method,PAE,Status,Session,Auth Bend,Auth SM State,Max Reauth,Max Requests,Last RX MAC,RX Invalid,RX Error,RX Logoff,RX Response,RX Start,RX Total,TX Requests,TX Request ID,TX Total,Quiet Period,Server Timeout,Supplicant Timeout,TX Period{% for interface in to_parse_dot1x.interfaces %}{% if to_parse_dot1x.interfaces[interface].clients is defined %}{% for client in to_parse_dot1x.interfaces[interface].clients %}{% for session in to_parse_dot1x.interfaces[interface].clients[client].session %}
{{ interface }},{{ client }},{{ to_parse_dot1x.interfaces[interface].clients[client].eap_method }},{{ to_parse_dot1x.interfaces[interface].clients[client].pae }},{{ to_parse_dot1x.interfaces[interface].clients[client].status }},{{ session }},{{ to_parse_dot1x.interfaces[interface].clients[client].session[session].auth_bend_sm_state }},{{ to_parse_dot1x.interfaces[interface].clients[client].session[session].auth_sm_state }},{{ to_parse_dot1x.interfaces[interface].max_reauth_req }},{{ to_parse_dot1x.interfaces[interface].max_req }},{{ to_parse_dot1x.interfaces[interface].statistics.lastrxsrcmac }},{{ to_parse_dot1x.interfaces[interface].statistics.rxinvalid }},{{ to_parse_dot1x.interfaces[interface].statistics.rxlenerr }},{{ to_parse_dot1x.interfaces[interface].statistics.rxlogoff }},{{ to_parse_dot1x.interfaces[interface].statistics.rxresp }},{{ to_parse_dot1x.interfaces[interface].statistics.rxstart }},{{ to_parse_dot1x.interfaces[interface].statistics.rxtotal }},{{ to_parse_dot1x.interfaces[interface].statistics.txreq }},{{ to_parse_dot1x.interfaces[interface].statistics.txreqid }},{{ to_parse_dot1x.interfaces[interface].statistics.txtotal }},{{ to_parse_dot1x.interfaces[interface].timeout.quiet_period }},{{ to_parse_dot1x.interfaces[interface].timeout.server_timeout }},{{ to_parse_dot1x.interfaces[interface].timeout.supp_timeout }},{{ to_parse_dot1x.interfaces[interface].timeout.tx_period }}{% endfor %}{% endfor %}{% else %}
{{ interface }},No Client,N/A,N/A,N/A,No Sessions,N/A,N/A,{{ to_parse_dot1x.interfaces[interface].max_reauth_req }},{{ to_parse_dot1x.interfaces[interface].max_req }},{{ to_parse_dot1x.interfaces[interface].statistics.lastrxsrcmac }},{{ to_parse_dot1x.interfaces[interface].statistics.rxinvalid }},{{ to_parse_dot1x.interfaces[interface].statistics.rxlenerr }},{{ to_parse_dot1x.interfaces[interface].statistics.rxlogoff }},{{ to_parse_dot1x.interfaces[interface].statistics.rxresp }},{{ to_parse_dot1x.interfaces[interface].statistics.rxstart }},{{ to_parse_dot1x.interfaces[interface].statistics.rxtotal }},{{ to_parse_dot1x.interfaces[interface].statistics.txreq }},{{ to_parse_dot1x.interfaces[interface].statistics.txreqid }},{{ to_parse_dot1x.interfaces[interface].statistics.txtotal }},{{ to_parse_dot1x.interfaces[interface].timeout.quiet_period }},{{ to_parse_dot1x.interfaces[interface].timeout.server_timeout }},{{ to_parse_dot1x.interfaces[interface].timeout.supp_timeout }},{{ to_parse_dot1x.interfaces[interface].timeout.tx_period }}{% endif %}{% endfor %}{% else %}{% if filetype_loop == 1 %}
# Learn Dot1x
| Interface | Client | EAP Method | PAE | Status | Session | Auth Bend | Auth SM State | Max Reauth | Max Requests | Last RX MAC | RX Invalid | RX Error | RX Logoff | RX Response | RX Start | RX Total | TX Requests | TX Request ID | TX Total | Quiet Period | Server Timeout | Supplicant Timeout | TX Period |
| --------- | ------ | ---------- | --- | ------ | ------- | --------- | ------------- | ---------- | ------------ | ----------- | ---------- | -------- | --------- | ----------- | -------- | -------- | ----------- | ------------- | -------- | ------------ | -------------- | ------------------ | --------- |  {% for interface in to_parse_dot1x.interfaces %}{% if to_parse_dot1x.interfaces[interface].clients is defined %}{% for client in to_parse_dot1x.interfaces[interface].clients %}{% for session in to_parse_dot1x.interfaces[interface].clients[client].session %}
| {{ interface }} | {{ client }} | {{ to_parse_dot1x.interfaces[interface].clients[client].eap_method }} | {{ to_parse_dot1x.interfaces[interface].clients[client].pae }} | {{ to_parse_dot1x.interfaces[interface].clients[client].status }} | {{ session }} | {{ to_parse_dot1x.interfaces[interface].clients[client].session[session].auth_bend_sm_state }} | {{ to_parse_dot1x.interfaces[interface].clients[client].session[session].auth_sm_state }} | {{ to_parse_dot1x.interfaces[interface].max_reauth_req }} | {{ to_parse_dot1x.interfaces[interface].max_req }} | {{ to_parse_dot1x.interfaces[interface].statistics.lastrxsrcmac }} | {{ to_parse_dot1x.interfaces[interface].statistics.rxinvalid }} | {{ to_parse_dot1x.interfaces[interface].statistics.rxlenerr }} | {{ to_parse_dot1x.interfaces[interface].statistics.rxlogoff }} | {{ to_parse_dot1x.interfaces[interface].statistics.rxresp }} | {{ to_parse_dot1x.interfaces[interface].statistics.rxstart }} | {{ to_parse_dot1x.interfaces[interface].statistics.rxtotal }} | {{ to_parse_dot1x.interfaces[interface].statistics.txreq }} | {{ to_parse_dot1x.interfaces[interface].statistics.txreqid }} | {{ to_parse_dot1x.interfaces[interface].statistics.txtotal }} | {{ to_parse_dot1x.interfaces[interface].timeout.quiet_period }} | {{ to_parse_dot1x.interfaces[interface].timeout.server_timeout }} | {{ to_parse_dot1x.interfaces[interface].timeout.supp_timeout }} | {{ to_parse_dot1x.interfaces[interface].timeout.tx_period }} |{% endfor %}{% endfor %}{% else %}
| {{ interface }} | No Client | N/A | N/A | N/A | No Sessions | N/A | N/A | {{ to_parse_dot1x.interfaces[interface].max_reauth_req }} | {{ to_parse_dot1x.interfaces[interface].max_req }} | {{ to_parse_dot1x.interfaces[interface].statistics.lastrxsrcmac }} | {{ to_parse_dot1x.interfaces[interface].statistics.rxinvalid }} | {{ to_parse_dot1x.interfaces[interface].statistics.rxlenerr }} | {{ to_parse_dot1x.interfaces[interface].statistics.rxlogoff }} | {{ to_parse_dot1x.interfaces[interface].statistics.rxresp }} | {{ to_parse_dot1x.interfaces[interface].statistics.rxstart }} | {{ to_parse_dot1x.interfaces[interface].statistics.rxtotal }} | {{ to_parse_dot1x.interfaces[interface].statistics.txreq }} | {{ to_parse_dot1x.interfaces[interface].statistics.txreqid }} | {{ to_parse_dot1x.interfaces[interface].statistics.txtotal }} | {{ to_parse_dot1x.interfaces[interface].timeout.quiet_period }} | {{ to_parse_dot1x.interfaces[interface].timeout.server_timeout }} | {{ to_parse_dot1x.interfaces[interface].timeout.supp_timeout }} | {{ to_parse_dot1x.interfaces[interface].timeout.tx_period }} |{% endif %}{% endfor %}{% else %}{% if filetype_loop == 2 %}
<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.0.0/js/dataTables.buttons.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.0.0/js/buttons.html5.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.0.0/js/buttons.print.min.js"></script>
    <script src="https://cdn.datatables.net/colreorder/1.5.4/js/dataTables.colReorder.min.js"></script>
    <script src="https://cdn.datatables.net/buttons/2.0.0/js/buttons.colVis.min.js"></script>
    <script src="https://cdn.datatables.net/keytable/2.6.4/js/dataTables.keyTable.min.js"></script>
    <script src="https://cdn.datatables.net/select/1.3.3/js/dataTables.select.min.js"></script>
    <script src="https://cdn.datatables.net/fixedheader/3.1.9/js/dataTables.fixedHeader.min.js"></script>
    <link rel="stylesheet" href="https://cdn.datatables.net/fixedheader/3.1.9/css/fixedHeader.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/select/1.3.3/css/select.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/keytable/2.6.4/css/keyTable.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.min.css">
</head>
<body>
<h1>Learn Dot1x/h1>
<table id = "dot1x">
  <thead>
  <tr>
    <th>Interface</th>
    <th>Client</th>
    <th>EAP Method</th>
    <th>PAE</th>
    <th>Status</th>
    <th>Session</th>
    <th>Auth Bend</th>
    <th>Auth SM State</th>
    <th>Max Reauth</th>
    <th>Max Requests</th>
    <th>Last RX MAC</th>
    <th>RX Invalid</th>
    <th>RX Error</th>
    <th>RX Logoff</th>
    <th>RX Response</th>
    <th>RX Start</th>
    <th>RX Total</th>
    <th>TX Requests</th>
    <th>TX Request ID</th>
    <th>TX Total</th>
    <th>Quiet Period</th>
    <th>Server Timeout</th>
    <th>Supplicant Timeout</th>
    <th>TX Period</th>  
  </tr>
  </thead>
  <tbody>{% for interface in to_parse_dot1x.interfaces %}{% if to_parse_dot1x.interfaces[interface].clients is defined %}{% for client in to_parse_dot1x.interfaces[interface].clients %}{% for session in to_parse_dot1x.interfaces[interface].clients[client].session %}
<tr>
    <td>{{ interface }}</td>
    <td>{{ client }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].clients[client].eap_method }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].clients[client].pae }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].clients[client].status }}</td>
    <td>{{ session }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].clients[client].session[session].auth_bend_sm_state }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].clients[client].session[session].auth_sm_state }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].max_reauth_req }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].max_req }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.lastrxsrcmac }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.rxinvalid }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.rxlenerr }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.rxlogoff }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.rxresp }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.rxstart }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.rxtotal }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.txreq }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.txreqid }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.txtotal }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].timeout.quiet_period }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].timeout.server_timeout }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].timeout.supp_timeout }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].timeout.tx_period }}</td>{% endfor %}{% endfor %}{% else %}
    <td>{{ interface }}</td>
    <td>No Client</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>No Sessions</td>
    <td>N/A</td>
    <td>N/A</td>
    <td>{{ to_parse_dot1x.interfaces[interface].max_reauth_req }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].max_req }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.lastrxsrcmac }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.rxinvalid }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.rxlenerr }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.rxlogoff }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.rxresp }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.rxstart }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.rxtotal }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.txreq }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.txreqid }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].statistics.txtotal }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].timeout.quiet_period }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].timeout.server_timeout }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].timeout.supp_timeout }}</td>
    <td>{{ to_parse_dot1x.interfaces[interface].timeout.tx_period }}</td>    
  </tr>{% endif %}{% endfor %}
  </tbody>  
</table>
<script type = "text/javascript">
  $(document).ready(function(){
    $('#dot1x thead tr')
    .clone(true)
    .addClass('filters')
    .appendTo('#dot1x thead');

    var table = $('#dot1x').DataTable({
        keys: true,
        dom: 'Bfrtip',
        lengthMenu: [
            [ 10, 25, 50, -1 ],
            [ '10 rows', '25 rows', '50 rows', 'Show all' ]
        ],
        buttons: [
        'pageLength','colvis','copy', 'csv', 'excel', 'pdf', 'print'
        ],
        colReorder: true,
        select: true,            
        orderCellsTop: true,
        fixedHeader: true,
        initComplete: function () {
        var api = this.api();

        // For each column
        api
            .columns()
            .eq(0)
            .each(function (colIdx) {
                // Set the header cell to contain the input element
                var cell = $('.filters th').eq(
                    $(api.column(colIdx).header()).index()
                );
                var title = $(cell).text();
                $(cell).html('<input type="text" placeholder="' + title + '" />');

                // On every keypress in this input
                $(
                    'input',
                    $('.filters th').eq($(api.column(colIdx).header()).index())
                )
                    .off('keyup change')
                    .on('keyup change', function (e) {
                        e.stopPropagation();

                        // Get the search value
                        $(this).attr('title', $(this).val());
                        var regexr = '({search})'; //$(this).parents('th').find('select').val();

                        var cursorPosition = this.selectionStart;
                        // Search the column for that value
                        api
                            .column(colIdx)
                            .search(
                                this.value != ''
                                    ? regexr.replace('{search}', '(((' + this.value + ')))')
                                    : '',
                                this.value != '',
                                this.value == ''
                            )
                            .draw();

                        $(this)
                            .focus()[0]
                            .setSelectionRange(cursorPosition, cursorPosition);
                    });
            });
    },
});
});        
</script>
</body></html>{% else %}
# Learn dot1x
{%- for interface in to_parse_dot1x.interfaces %}
## {{ interface }}
{%-     if to_parse_dot1x.interfaces[interface].clients is defined %}
{%-         for client in to_parse_dot1x.interfaces[interface].clients %}
### Client: {{ client }}
#### EAP Method: {{ to_parse_dot1x.interfaces[interface].clients[client].eap_method }}
#### PAE: {{ to_parse_dot1x.interfaces[interface].clients[client].pae }}
#### Status: {{ to_parse_dot1x.interfaces[interface].clients[client].status }}
{%-             for session in to_parse_dot1x.interfaces[interface].clients[client].session %}
#### Session: {{ session }}
##### Auth Bend State: {{ to_parse_dot1x.interfaces[interface].clients[client].session[session].auth_bend_sm_state }}
##### Auth SM State: {{ to_parse_dot1x.interfaces[interface].clients[client].session[session].auth_sm_state }}
{%-             endfor %}
#### Max
##### Reauth: {{ to_parse_dot1x.interfaces[interface].max_reauth_req }}
##### Requests: {{ to_parse_dot1x.interfaces[interface].max_req }}
#### RX
##### Last MAC: {{ to_parse_dot1x.interfaces[interface].statistics.lastrxsrcmac }}
##### Invalid: {{ to_parse_dot1x.interfaces[interface].statistics.rxinvalid }}
##### Error: {{ to_parse_dot1x.interfaces[interface].statistics.rxlenerr }}
##### Logoff: {{ to_parse_dot1x.interfaces[interface].statistics.rxlogoff }}
##### Response: {{ to_parse_dot1x.interfaces[interface].statistics.rxresp }}
##### Start: {{ to_parse_dot1x.interfaces[interface].statistics.rxstart }}
##### Total: {{ to_parse_dot1x.interfaces[interface].statistics.rxtotal }}
#### TX
##### Requests: {{ to_parse_dot1x.interfaces[interface].statistics.txreq }}
##### Request ID: {{ to_parse_dot1x.interfaces[interface].statistics.txreqid }}
##### Total: {{ to_parse_dot1x.interfaces[interface].statistics.txtotal }}
##### Period: {{ to_parse_dot1x.interfaces[interface].timeout.tx_period }}
#### Quiet Period: {{ to_parse_dot1x.interfaces[interface].timeout.quiet_period }}
#### Timeout
##### Server: {{ to_parse_dot1x.interfaces[interface].timeout.server_timeout }}
##### Supplicant: {{ to_parse_dot1x.interfaces[interface].timeout.supp_timeout }}
{%-         endfor %}
{%-     endif %}
{%- endfor %}
{% endif %}{% endif %}{% endif %}