Ejemplo n.º 1
0
 def get_traffic_class(self):
     version = self.check_inet(2, 2)
     if version == 4:
         return self.pi.l3p[1]
     elif version == 6:
         return (lib.get_short(self.pi.l3p, 0) >> 4) & 0x00ff
     return None
Ejemplo n.º 2
0
 def set_traffic_class(self, new_val):
     version = self.check_inet(2, 2)
     if version == 4:
         self.pi.l3p[1] = new_val
     elif version == 6:
         val = lib.get_short(self.pi.l3p, 0)
         lib.set_short(self.pi.l3p, 0, (val & 0xF00F) | (new_val << 4))
     else:
         raise PltError("Data too short to set traffic_class")
     return None
Ejemplo n.º 3
0
 def get_dst_port(self):
     if self.check_tcp(4):
         return lib.get_short(self.pi.dp, 2)
     return None
Ejemplo n.º 4
0
 def get_src_port(self):
     if self.check_tcp(2):
         return lib.get_short(self.pi.dp, 0)
     return None
Ejemplo n.º 5
0
 def get_payload_len(self):
     if self.check_ip6(6):
         return lib.get_short(self.pi.l3p, 4)
     return None
Ejemplo n.º 6
0
 def get_checksum(self):
     if self.check_ip(12):
         return lib.get_short(self.pi.l3p, 10)
     return None
Ejemplo n.º 7
0
 def get_frag_offset(self):
     if self.check_ip(8):
         return lib.get_short(self.pi.l3p, 6) & 0x1FFF
     return None
Ejemplo n.º 8
0
 def get_checksum(self):
     if self.check_udp(8):
         return lib.get_short(self.pi.dp, 6)
     return None
Ejemplo n.º 9
0
 def get_checksum(self):
     if self.check_tcp(18):
         return lib.get_short(self.pi.dp, 16)
     return None
Ejemplo n.º 10
0
def get_short(ca, x):  # Get 16-bit integer from cdata uint8_t[]
    return lib.get_short(ca, x)
Ejemplo n.º 11
0
 def get_sequence(self):
     if self.pi.rem >= 8:
         return lib.get_short(self.pi.dp, 6)
     return None
Ejemplo n.º 12
0
 def get_ident(self):
     if self.pi.rem >= 6:
         return lib.get_short(self.pi.dp, 4)
     return None
Ejemplo n.º 13
0
 def get_checksum(self):
     if self.check_icmp6(4):
         return lib.get_short(self.pi.dp, 2)
     return None
Ejemplo n.º 14
0
 def get_flags(self):
     if self.check_tcp(14):
         return lib.get_short(self.pi.dp, 12) & 0x0FFF
     return None
Ejemplo n.º 15
0
 def get_pkt_len(self):
     version = self.check_inet(4, 4)
     if version == 4:
         return lib.get_short(self.pi.l3p, 2)
     return None
Ejemplo n.º 16
0
 def get_window(self):
     if self.check_tcp(16):
         return lib.get_short(self.pi.dp, 14)
     return None
Ejemplo n.º 17
0
 def get_ident(self):
     if self.check_ip(6):
         return lib.get_short(self.pi.l3p, 4)
     return None
Ejemplo n.º 18
0
 def get_urg_ptr(self):
     if self.check_tcp(20):
         return lib.get_short(self.pi.dp, 18)
     return None
Ejemplo n.º 19
0
 def get_len(self):
     if self.check_udp(6):
         return lib.get_short(self.pi.dp, 4)
     return None