Example #1
0
    def get_protocol_id(self, name):
        if sys.version_info >= (3, 0):
            buf = create_string_buffer(name.encode("utf-8"))
        else:
            buf = create_string_buffer(name)

        self.send_cmd(GENL_ID_CTRL, CTRL_CMD_GETFAMILY,
                      CTRL_ATTR_FAMILY_NAME, buf)
        l, msg = self.recv()
        name = nlattr.from_address(addressof(msg.data))
        prid = nlattr.from_address(addressof(msg.data) +
                                   NLMSG_ALIGN(name.nla_len))
        assert prid.nla_type == CTRL_ATTR_FAMILY_ID
        return c_uint16.from_address(addressof(prid) + sizeof(prid)).value
Example #2
0
def csum_complement(x):
    x = c_uint32(x)
    x1 = c_uint16.from_address(addressof(x))
    x2 = c_uint16.from_address(addressof(x) + 2)
    return ~c_uint16(x1.value + x2.value).value
 def readWord(self, address, isLocalAddress=False):
     if not isLocalAddress:
         address = self.remoteAddressToLocalAddress(address)
     return c_uint16.from_address(address).value