Lines Matching refs:self

213   def _NlAttrIPAddress(self, nla_type, family, address):  argument
214 return self._NlAttr(nla_type, socket.inet_pton(family, address))
216 def _NlAttrInterfaceName(self, nla_type, interface): argument
217 return self._NlAttr(nla_type, interface + "\x00")
219 def _GetConstantName(self, value, prefix): argument
220 return super(IPRoute, self)._GetConstantName(__name__, value, prefix)
222 def _Decode(self, command, msg, nla_type, nla_data): argument
252 name = self._GetConstantName(nla_type, "RTAX_")
254 name = self._GetConstantName(nla_type, "IFA_")
256 name = self._GetConstantName(nla_type, "IFLA_")
258 name = self._GetConstantName(nla_type, "FRA_")
260 name = self._GetConstantName(nla_type, "RTA_")
262 name = self._GetConstantName(nla_type, "NDA_")
286 data = self._ParseAttributes(-RTA_METRICS, msg.family, None, nla_data)
300 def __init__(self): argument
301 super(IPRoute, self).__init__()
303 def _AddressFamily(self, version): argument
306 def _SendNlRequest(self, command, data, flags=0): argument
316 super(IPRoute, self)._SendNlRequest(command, data, flags)
318 def _Rule(self, version, is_add, rule_type, table, match_nlattr, priority): argument
335 family = self._AddressFamily(version)
338 rtmsg += self._NlAttrU32(FRA_PRIORITY, priority)
342 rtmsg += self._NlAttrU32(FRA_TABLE, table)
346 self._SendNlRequest(command, rtmsg)
348 def DeleteRulesAtPriority(self, version, priority): argument
349 family = self._AddressFamily(version)
352 rtmsg += self._NlAttrU32(FRA_PRIORITY, priority)
355 self._SendNlRequest(RTM_DELRULE, rtmsg)
362 def FwmarkRule(self, version, is_add, fwmark, table, priority): argument
363 nlattr = self._NlAttrU32(FRA_FWMARK, fwmark)
364 return self._Rule(version, is_add, RTN_UNICAST, table, nlattr, priority)
366 def IifRule(self, version, is_add, iif, table, priority): argument
367 nlattr = self._NlAttrInterfaceName(FRA_IIFNAME, iif)
368 return self._Rule(version, is_add, RTN_UNICAST, table, nlattr, priority)
370 def OifRule(self, version, is_add, oif, table, priority): argument
371 nlattr = self._NlAttrInterfaceName(FRA_OIFNAME, oif)
372 return self._Rule(version, is_add, RTN_UNICAST, table, nlattr, priority)
374 def UidRangeRule(self, version, is_add, start, end, table, priority): argument
375 nlattr = (self._NlAttrInterfaceName(FRA_IIFNAME, "lo") +
376 self._NlAttrU32(FRA_UID_START, start) +
377 self._NlAttrU32(FRA_UID_END, end))
378 return self._Rule(version, is_add, RTN_UNICAST, table, nlattr, priority)
380 def UnreachableRule(self, version, is_add, priority): argument
381 return self._Rule(version, is_add, RTN_UNREACHABLE, None, None, priority)
383 def DefaultRule(self, version, is_add, table, priority): argument
384 return self.FwmarkRule(version, is_add, 0, table, priority)
386 def CommandToString(self, command, data): argument
397 parsed = self._ParseNLMsg(data, struct_type)
402 def MaybeDebugCommand(self, command, data): argument
404 if "ALL" not in self.NL_DEBUG and subject not in self.NL_DEBUG:
406 print self.CommandToString(command, data)
408 def MaybeDebugMessage(self, message): argument
410 self.MaybeDebugCommand(hdr.type, message)
412 def PrintMessage(self, message): argument
414 print self.CommandToString(hdr.type, message)
416 def DumpRules(self, version): argument
419 family = self._AddressFamily(version)
421 return self._Dump(RTM_GETRULE, rtmsg, RTMsg, "")
423 def DumpLinks(self): argument
425 return self._Dump(RTM_GETLINK, ifinfomsg, IfinfoMsg, "")
427 def _Address(self, version, command, addr, prefixlen, flags, scope, ifindex): argument
429 family = self._AddressFamily(version)
431 ifaddrmsg += self._NlAttrIPAddress(IFA_ADDRESS, family, addr)
433 ifaddrmsg += self._NlAttrIPAddress(IFA_LOCAL, family, addr)
434 self._SendNlRequest(command, ifaddrmsg)
436 def AddAddress(self, address, prefixlen, ifindex): argument
437 self._Address(6 if ":" in address else 4,
441 def DelAddress(self, address, prefixlen, ifindex): argument
442 self._Address(6 if ":" in address else 4,
445 def GetAddress(self, address, ifindex=0): argument
452 self._Address(6, RTM_GETADDR, address, 0, 0, RT_SCOPE_UNIVERSE, ifindex)
453 return self._GetMsg(IfAddrMsg)
455 def _Route(self, version, command, table, dest, prefixlen, nexthop, dev, argument
458 family = self._AddressFamily(version)
467 rtmsg += self._NlAttrU32(FRA_TABLE, table)
469 rtmsg += self._NlAttrIPAddress(RTA_DST, family, dest)
471 rtmsg += self._NlAttrIPAddress(RTA_GATEWAY, family, nexthop)
473 rtmsg += self._NlAttrU32(RTA_OIF, dev)
475 rtmsg += self._NlAttrU32(RTA_MARK, mark)
477 rtmsg += self._NlAttrU32(RTA_UID, uid)
478 self._SendNlRequest(command, rtmsg)
480 def AddRoute(self, version, table, dest, prefixlen, nexthop, dev): argument
481 self._Route(version, RTM_NEWROUTE, table, dest, prefixlen, nexthop, dev,
484 def DelRoute(self, version, table, dest, prefixlen, nexthop, dev): argument
485 self._Route(version, RTM_DELROUTE, table, dest, prefixlen, nexthop, dev,
488 def GetRoutes(self, dest, oif, mark, uid): argument
491 self._Route(version, RTM_GETROUTE, 0, dest, prefixlen, None, oif, mark, uid)
492 data = self._Recv()
495 self._ParseAck(data)
496 routes = self._GetMsgList(RTMsg, data, False)
499 def _Neighbour(self, version, is_add, addr, lladdr, dev, state, flags=0): argument
501 family = self._AddressFamily(version)
511 ndmsg += self._NlAttrIPAddress(NDA_DST, family, addr)
513 ndmsg += self._NlAttr(NDA_LLADDR, lladdr)
515 self._SendNlRequest(command, ndmsg, flags)
517 def AddNeighbour(self, version, addr, lladdr, dev): argument
518 self._Neighbour(version, True, addr, lladdr, dev, NUD_PERMANENT)
520 def DelNeighbour(self, version, addr, lladdr, dev): argument
521 self._Neighbour(version, False, addr, lladdr, dev, 0)
523 def UpdateNeighbour(self, version, addr, lladdr, dev, state): argument
524 self._Neighbour(version, True, addr, lladdr, dev, state,
527 def DumpNeighbours(self, version): argument
528 ndmsg = NdMsg((self._AddressFamily(version), 0, 0, 0, 0))
529 return self._Dump(RTM_GETNEIGH, ndmsg, NdMsg, "")
531 def ParseNeighbourMessage(self, msg): argument
532 msg, _ = self._ParseNLMsg(msg, NdMsg)