Ejemplo n.º 1
0
 def __init__(self, *argv, **kwarg):
     if 'family' in kwarg:
         kwarg.pop('family')
     super(IPRSocketMixin, self).__init__(NETLINK_ROUTE, *argv[1:], **kwarg)
     self.marshal = MarshalRtnl()
     self._s_channel = None
     if sys.platform.startswith('linux'):
         self._gate = self._gate_linux
         self.sendto_gate = self._gate_linux
         send_ns = Namespace(self, {'addr_pool': AddrPool(0x10000,
                                                          0x1ffff),
                                    'monitor': False})
         self._sproxy = NetlinkProxy(policy='return', nl=send_ns)
         self._sproxy.pmap = {rtnl.RTM_NEWLINK: proxy_newlink,
                              rtnl.RTM_SETLINK: proxy_setlink}
         if config.kernel < [3, 3, 0]:
             self._recv_ns = Namespace(self,
                                       {'addr_pool': AddrPool(0x20000,
                                                              0x2ffff),
                                        'monitor': False})
             self._sproxy.pmap[rtnl.RTM_DELLINK] = proxy_dellink
             # inject proxy hooks into recv() and...
             self.__recv = self._recv
             self._recv = self._p_recv
             # ... recv_into()
             self._recv_ft = self.recv_ft
             self.recv_ft = self._p_recv_ft
Ejemplo n.º 2
0
 def __init__(self,
              fileno=None,
              sndbuf=1048576,
              rcvbuf=1048576,
              all_ns=False):
     super(IPRSocketMixin, self).__init__(NETLINK_ROUTE,
                                          fileno=fileno,
                                          sndbuf=sndbuf,
                                          rcvbuf=rcvbuf,
                                          all_ns=all_ns)
     self.marshal = MarshalRtnl()
     self._s_channel = None
     send_ns = Namespace(self, {
         'addr_pool': AddrPool(0x10000, 0x1ffff),
         'monitor': False
     })
     self._sproxy = NetlinkProxy(policy='return', nl=send_ns)
     self._sproxy.pmap = {
         rtnl.RTM_NEWLINK: proxy_newlink,
         rtnl.RTM_SETLINK: proxy_setlink
     }
     if config.kernel < [3, 3, 0]:
         self._recv_ns = Namespace(self, {
             'addr_pool': AddrPool(0x20000, 0x2ffff),
             'monitor': False
         })
         self._sproxy.pmap[rtnl.RTM_DELLINK] = proxy_dellink
         # inject proxy hooks into recv() and...
         self.__recv = self._recv
         self._recv = self._p_recv
         # ... recv_into()
         self._recv_ft = self.recv_ft
         self.recv_ft = self._p_recv_ft
Ejemplo n.º 3
0
 def __init__(self, *argv, **kwarg):
     self.marshal = MarshalRtnl()
     send_ns = Namespace(self, {
         'addr_pool': AddrPool(0x10000, 0x1ffff),
         'monitor': False
     })
     self._sproxy = NetlinkProxy(policy='return', nl=send_ns)
Ejemplo n.º 4
0
 def __init__(self, fileno=None):
     super(IPRSocketMixin, self).__init__(NETLINK_ROUTE, fileno=fileno)
     self.marshal = MarshalRtnl()
     self._s_channel = None
     send_ns = Namespace(self, {'addr_pool': AddrPool(0x10000, 0x1ffff),
                                'monitor': False})
     self._sproxy = NetlinkProxy(policy='return', nl=send_ns)
     self._sproxy.pmap = {rtnl.RTM_NEWLINK: proxy_newlink,
                          rtnl.RTM_SETLINK: proxy_setlink}
Ejemplo n.º 5
0
 def __init__(self, *argv, **kwarg):
     self._ifc = Ifconfig()
     self.marshal = MarshalRtnl()
     send_ns = Namespace(self, {'addr_pool': AddrPool(0x10000, 0x1ffff),
                                'monitor': False})
     self._sproxy = NetlinkProxy(policy='return', nl=send_ns)
     self._mon_th = None
     self._rtm = None
     self._pfdr, self._pfdw = os.pipe()  # notify external poll/select
     self._ctlr, self._ctlw = os.pipe()  # notify monitoring thread
     self._outq = queue.Queue()
     self._system_lock = threading.Lock()
Ejemplo n.º 6
0
 def __init__(self, *argv, **kwarg):
     if 'ssh' in kwarg:
         self._ssh = ['ssh', kwarg.pop('ssh')]
     else:
         self._ssh = []
     self._ifc = Ifconfig(cmd=self._ssh + ['ifconfig', '-a'])
     self._arp = ARP(cmd=self._ssh + ['arp', '-an'])
     self._route = Route(cmd=self._ssh + ['netstat', '-rn'])
     self.marshal = MarshalRtnl()
     send_ns = Namespace(self, {'addr_pool': AddrPool(0x10000, 0x1ffff),
                                'monitor': False})
     self._sproxy = NetlinkProxy(policy='return', nl=send_ns)
     self._mon_th = None
     self._rtm = None
     self._pfdr, self._pfdw = os.pipe()  # notify external poll/select
     self._ctlr, self._ctlw = os.pipe()  # notify monitoring thread
     self._outq = queue.Queue()
     self._system_lock = threading.Lock()