MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / do_ptp_detect

Function do_ptp_detect

network_diagnostics.py:1793–1825  ·  view source on GitHub ↗

Detect PTP (IEEE-1588 / PTPv2) on a segment by sniffing the PTP event/ general UDP ports and the 802.1AS ethertype. Reports whether a grandmaster is announcing, which message types are present, and the domain(s). Precise clock-offset needs ptp4l running; this is the field 'is PTP here?'

(interface, seconds=8)

Source from the content-addressed store, hash-verified

1791 out.append({'name': name, 'members': _bridge_members(name)})
1792 return out
1793
1794
1795def _wired_nics():
1796 """Physical wired NICs eligible to be bridged (eth*/en*/usb*), excluding the
1797 default-route interface and anything already in a non-snoop bridge."""
1798 names = []
1799 for n in _list_iface_names(include_virtual=False):
1800 if _DHCP_SNOOP_WIRED_RE.match(n) and not _is_wireless(n):
1801 names.append(n)
1802 return names
1803
1804
1805def do_dhcp_snoop_config(trusted=None, untrusted=None):
1806 """Get or set the trusted/untrusted port designation (persisted). Pass both
1807 to set; pass neither to just read."""
1808 with _dhcp_snoop_lock:
1809 cfg = _dhcp_snoop_load()
1810 if trusted is not None and untrusted is not None:
1811 if not _valid_iface(trusted) or not _valid_iface(untrusted):
1812 return {'success': False, 'error': 'invalid interface name'}
1813 if trusted == untrusted:
1814 return {'success': False, 'error': 'trusted and untrusted must differ'}
1815 cfg['trusted'] = trusted
1816 cfg['untrusted'] = untrusted
1817 _dhcp_snoop_save(cfg)
1818 return {'success': True, 'trusted': cfg.get('trusted'),
1819 'untrusted': cfg.get('untrusted')}
1820
1821
1822def do_dhcp_snoop_status():
1823 """Report the inline-snooping setup: bridges present, eligible wired NICs,
1824 the default-route interface (never bridged), and the trusted/untrusted
1825 config — everything the UI needs to guide wiring."""
1826 bridges = _list_bridges()
1827 snoop_bridge = next((b for b in bridges if b['name'] == _DHCP_SNOOP_BRIDGE), None)
1828 with _dhcp_snoop_lock:

Callers 1

net_ptpFunction · 0.85

Calls 6

_haveFunction · 0.85
_list_iface_namesFunction · 0.85
_clamp_intFunction · 0.85
_runFunction · 0.85
addMethod · 0.80
setFunction · 0.50

Tested by

no test coverage detected