コード例 #1
0
ファイル: table.py プロジェクト: chrisvel/py-pf
    def _to_string(self):
        """Return the string representation of the address."""
        s = ("! {!s}" if self.neg else "{!s}").format(self.addr)
        bits = nmtoc(self.mask, self.af)
        if not ((self.af == AF_INET and bits == 32) or (bits == 128)):
            s += "/{}".format(bits)

        return s
コード例 #2
0
ファイル: table.py プロジェクト: sonywork/py-pf
    def _to_string(self):
        """Return the string representation of the address."""
        s = ("! {!s}" if self.neg else "{!s}").format(self.addr)
        bits = nmtoc(self.mask, self.af)
        if not ((self.af == AF_INET and bits == 32) or (bits == 128)):
            s += "/{}".format(bits)

        return s
コード例 #3
0
ファイル: table.py プロジェクト: chrisvel/py-pf
    def _to_struct(self):
        """Convert this instance to a pfr_addr structure."""
        a = pfr_addr()

        addr = inet_pton(self.af, self.addr)
        memmove(a.pfra_ip6addr, c_char_p(addr), len(addr))

        a.pfra_af     = self.af
        a.pfra_net    = nmtoc(self.mask, self.af)
        a.pfra_not    = int(self.neg)
        a.pfra_fback  = self.fback
        a.pfra_ifname = self.ifname
        a.pfra_type   = self.type

        return a
コード例 #4
0
ファイル: table.py プロジェクト: sonywork/py-pf
    def _to_struct(self):
        """Convert this instance to a pfr_addr structure."""
        a = pfr_addr()

        addr = inet_pton(self.af, self.addr)
        memmove(a.pfra_ip6addr, c_char_p(addr), len(addr))

        a.pfra_af = self.af
        a.pfra_net = nmtoc(self.mask, self.af)
        a.pfra_not = int(self.neg)
        a.pfra_fback = self.fback
        a.pfra_ifname = self.ifname
        a.pfra_type = self.type

        return a