Skip to content
Peter V. Saveliev edited this page Aug 21, 2013 · 5 revisions

Simple

Threadless usage with blocking I/O calls:

>>> from pyroute2.netlink.iproute import IPRSocket
>>> from pprint import pprint
>>> s = IPRSocket()
>>> s.bind()
>>> pprint(s.get())
[{'attrs': [('RTA_TABLE', 254),
            ('RTA_DST', '2a00:1450:4009:808::1002'),
            ('RTA_GATEWAY', 'fe80:52:0:2282::1fe'),
            ('RTA_OIF', 2),
            ('RTA_PRIORITY', 0),
            ('RTA_CACHEINFO',
             {'rta_clntref': 0,
              'rta_error': 0,
              'rta_expires': 0,
              'rta_id': 0,
              'rta_lastuse': 5926,
              'rta_ts': 0,
              'rta_tsage': 0,
              'rta_used': 1})],
  'dst_len': 128,
  'event': 'RTM_DELROUTE',
  'family': 10,
  'flags': 512,
  'header': {'error': None,
             'flags': 0,
             'length': 128,
             'pid': 0,
             'sequence_number': 0,
             'type': 25},
  'proto': 9,
  'scope': 0,
  'src_len': 0,
  'table': 254,
  'tos': 0,
  'type': 1}]
>>> 

Clone this wiki locally