repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
siznax/wptools | wptools/utils.py | template_to_dict_iter_debug | def template_to_dict_iter_debug(elm):
"""
Print expanded element on stdout for debugging
"""
if elm.text is not None:
print(" <%s>%s</%s>" % (elm.tag, elm.text, elm.tag), end='')
if elm.tail is not None:
print(elm.tail)
else:
print()
else:
i... | python | def template_to_dict_iter_debug(elm):
"""
Print expanded element on stdout for debugging
"""
if elm.text is not None:
print(" <%s>%s</%s>" % (elm.tag, elm.text, elm.tag), end='')
if elm.tail is not None:
print(elm.tail)
else:
print()
else:
i... | [
"def",
"template_to_dict_iter_debug",
"(",
"elm",
")",
":",
"if",
"elm",
".",
"text",
"is",
"not",
"None",
":",
"print",
"(",
"\" <%s>%s</%s>\"",
"%",
"(",
"elm",
".",
"tag",
",",
"elm",
".",
"text",
",",
"elm",
".",
"tag",
")",
",",
"end",
"=",
... | Print expanded element on stdout for debugging | [
"Print",
"expanded",
"element",
"on",
"stdout",
"for",
"debugging"
] | train | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/utils.py#L280-L294 |
siznax/wptools | wptools/utils.py | template_to_text | def template_to_text(tmpl, debug=0):
"""
convert parse tree template to text
"""
tarr = []
for item in tmpl.itertext():
tarr.append(item)
text = "{{%s}}" % "|".join(tarr).strip()
if debug > 1:
print("+ template_to_text:")
print(" %s" % text)
return text | python | def template_to_text(tmpl, debug=0):
"""
convert parse tree template to text
"""
tarr = []
for item in tmpl.itertext():
tarr.append(item)
text = "{{%s}}" % "|".join(tarr).strip()
if debug > 1:
print("+ template_to_text:")
print(" %s" % text)
return text | [
"def",
"template_to_text",
"(",
"tmpl",
",",
"debug",
"=",
"0",
")",
":",
"tarr",
"=",
"[",
"]",
"for",
"item",
"in",
"tmpl",
".",
"itertext",
"(",
")",
":",
"tarr",
".",
"append",
"(",
"item",
")",
"text",
"=",
"\"{{%s}}\"",
"%",
"\"|\"",
".",
"... | convert parse tree template to text | [
"convert",
"parse",
"tree",
"template",
"to",
"text"
] | train | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/utils.py#L297-L311 |
siznax/wptools | wptools/utils.py | text_with_children | def text_with_children(node, debug=0):
"""
DEPRECATED: return text content with children (#62), sub-elements (#66)
Only used by deprecated template_to_dict_find(), and suffers from
copypasta code smell.
"""
# https://stackoverflow.com/questions/4624062/get-all-text-inside-a-tag-in-lxml
if... | python | def text_with_children(node, debug=0):
"""
DEPRECATED: return text content with children (#62), sub-elements (#66)
Only used by deprecated template_to_dict_find(), and suffers from
copypasta code smell.
"""
# https://stackoverflow.com/questions/4624062/get-all-text-inside-a-tag-in-lxml
if... | [
"def",
"text_with_children",
"(",
"node",
",",
"debug",
"=",
"0",
")",
":",
"# https://stackoverflow.com/questions/4624062/get-all-text-inside-a-tag-in-lxml",
"if",
"sys",
".",
"version",
".",
"startswith",
"(",
"'3'",
")",
":",
"# py3 needs encoding=str",
"parts",
"=",... | DEPRECATED: return text content with children (#62), sub-elements (#66)
Only used by deprecated template_to_dict_find(), and suffers from
copypasta code smell. | [
"DEPRECATED",
":",
"return",
"text",
"content",
"with",
"children",
"(",
"#62",
")",
"sub",
"-",
"elements",
"(",
"#66",
")"
] | train | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/utils.py#L314-L343 |
phaethon/kamene | kamene/contrib/igmpv3.py | IGMPv3gr.post_build | def post_build(self, p, pay):
"""Called implicitly before a packet is sent.
"""
p += pay
if self.auxdlen != 0:
print("NOTICE: A properly formatted and complaint V3 Group Record should have an Auxiliary Data length of zero (0).")
print(" Subsequent Group Records are lost!")
return ... | python | def post_build(self, p, pay):
"""Called implicitly before a packet is sent.
"""
p += pay
if self.auxdlen != 0:
print("NOTICE: A properly formatted and complaint V3 Group Record should have an Auxiliary Data length of zero (0).")
print(" Subsequent Group Records are lost!")
return ... | [
"def",
"post_build",
"(",
"self",
",",
"p",
",",
"pay",
")",
":",
"p",
"+=",
"pay",
"if",
"self",
".",
"auxdlen",
"!=",
"0",
":",
"print",
"(",
"\"NOTICE: A properly formatted and complaint V3 Group Record should have an Auxiliary Data length of zero (0).\"",
")",
"pr... | Called implicitly before a packet is sent. | [
"Called",
"implicitly",
"before",
"a",
"packet",
"is",
"sent",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/igmpv3.py#L55-L62 |
phaethon/kamene | kamene/contrib/igmpv3.py | IGMPv3.float_encode | def float_encode(self, value):
"""Convert the integer value to its IGMPv3 encoded time value if needed.
If value < 128, return the value specified. If >= 128, encode as a floating
point value. Value can be 0 - 31744.
"""
if value < 128:
code = value
elif value > 31743:
code = 25... | python | def float_encode(self, value):
"""Convert the integer value to its IGMPv3 encoded time value if needed.
If value < 128, return the value specified. If >= 128, encode as a floating
point value. Value can be 0 - 31744.
"""
if value < 128:
code = value
elif value > 31743:
code = 25... | [
"def",
"float_encode",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"<",
"128",
":",
"code",
"=",
"value",
"elif",
"value",
">",
"31743",
":",
"code",
"=",
"255",
"else",
":",
"exp",
"=",
"0",
"value",
">>=",
"3",
"while",
"(",
"value",
">... | Convert the integer value to its IGMPv3 encoded time value if needed.
If value < 128, return the value specified. If >= 128, encode as a floating
point value. Value can be 0 - 31744. | [
"Convert",
"the",
"integer",
"value",
"to",
"its",
"IGMPv3",
"encoded",
"time",
"value",
"if",
"needed",
".",
"If",
"value",
"<",
"128",
"return",
"the",
"value",
"specified",
".",
"If",
">",
"=",
"128",
"encode",
"as",
"a",
"floating",
"point",
"value",... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/igmpv3.py#L123-L141 |
phaethon/kamene | kamene/contrib/igmpv3.py | IGMPv3.post_build | def post_build(self, p, pay):
"""Called implicitly before a packet is sent to compute and place IGMPv3 checksum.
Parameters:
self The instantiation of an IGMPv3 class
p The IGMPv3 message in hex in network byte order
pay Additional payload for the IGMPv3 message
"""
p += ... | python | def post_build(self, p, pay):
"""Called implicitly before a packet is sent to compute and place IGMPv3 checksum.
Parameters:
self The instantiation of an IGMPv3 class
p The IGMPv3 message in hex in network byte order
pay Additional payload for the IGMPv3 message
"""
p += ... | [
"def",
"post_build",
"(",
"self",
",",
"p",
",",
"pay",
")",
":",
"p",
"+=",
"pay",
"if",
"self",
".",
"type",
"in",
"[",
"0",
",",
"0x31",
",",
"0x32",
",",
"0x22",
"]",
":",
"# for these, field is reserved (0)",
"p",
"=",
"p",
"[",
":",
"1",
"]... | Called implicitly before a packet is sent to compute and place IGMPv3 checksum.
Parameters:
self The instantiation of an IGMPv3 class
p The IGMPv3 message in hex in network byte order
pay Additional payload for the IGMPv3 message | [
"Called",
"implicitly",
"before",
"a",
"packet",
"is",
"sent",
"to",
"compute",
"and",
"place",
"IGMPv3",
"checksum",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/igmpv3.py#L144-L158 |
phaethon/kamene | kamene/contrib/igmpv3.py | IGMPv3.mysummary | def mysummary(self):
"""Display a summary of the IGMPv3 object."""
if isinstance(self.underlayer, IP):
return self.underlayer.sprintf("IGMPv3: %IP.src% > %IP.dst% %IGMPv3.type% %IGMPv3.gaddr%")
else:
return self.sprintf("IGMPv3 %IGMPv3.type% %IGMPv3.gaddr%") | python | def mysummary(self):
"""Display a summary of the IGMPv3 object."""
if isinstance(self.underlayer, IP):
return self.underlayer.sprintf("IGMPv3: %IP.src% > %IP.dst% %IGMPv3.type% %IGMPv3.gaddr%")
else:
return self.sprintf("IGMPv3 %IGMPv3.type% %IGMPv3.gaddr%") | [
"def",
"mysummary",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"underlayer",
",",
"IP",
")",
":",
"return",
"self",
".",
"underlayer",
".",
"sprintf",
"(",
"\"IGMPv3: %IP.src% > %IP.dst% %IGMPv3.type% %IGMPv3.gaddr%\"",
")",
"else",
":",
"retur... | Display a summary of the IGMPv3 object. | [
"Display",
"a",
"summary",
"of",
"the",
"IGMPv3",
"object",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/igmpv3.py#L161-L167 |
phaethon/kamene | kamene/contrib/igmpv3.py | IGMPv3.adjust_ether | def adjust_ether (self, ip=None, ether=None):
"""Called to explicitely fixup an associated Ethernet header
The function adjusts the ethernet header destination MAC address based on
the destination IP address.
"""
# The rules are:
# 1. send to the group mac address address corresponding to the IP.dst... | python | def adjust_ether (self, ip=None, ether=None):
"""Called to explicitely fixup an associated Ethernet header
The function adjusts the ethernet header destination MAC address based on
the destination IP address.
"""
# The rules are:
# 1. send to the group mac address address corresponding to the IP.dst... | [
"def",
"adjust_ether",
"(",
"self",
",",
"ip",
"=",
"None",
",",
"ether",
"=",
"None",
")",
":",
"# The rules are:",
"# 1. send to the group mac address address corresponding to the IP.dst",
"if",
"ip",
"!=",
"None",
"and",
"ip",
".",
"haslayer",
"(",
"IP",
")",... | Called to explicitely fixup an associated Ethernet header
The function adjusts the ethernet header destination MAC address based on
the destination IP address. | [
"Called",
"to",
"explicitely",
"fixup",
"an",
"associated",
"Ethernet",
"header"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/igmpv3.py#L208-L222 |
phaethon/kamene | kamene/contrib/igmpv3.py | IGMPv3.adjust_ip | def adjust_ip (self, ip=None):
"""Called to explicitely fixup an associated IP header
The function adjusts the IP header based on conformance rules
and the group address encoded in the IGMP message.
The rules are:
1. Send General Group Query to 224.0.0.1 (all systems)
2. Send Leave Group to 22... | python | def adjust_ip (self, ip=None):
"""Called to explicitely fixup an associated IP header
The function adjusts the IP header based on conformance rules
and the group address encoded in the IGMP message.
The rules are:
1. Send General Group Query to 224.0.0.1 (all systems)
2. Send Leave Group to 22... | [
"def",
"adjust_ip",
"(",
"self",
",",
"ip",
"=",
"None",
")",
":",
"if",
"ip",
"!=",
"None",
"and",
"ip",
".",
"haslayer",
"(",
"IP",
")",
":",
"if",
"(",
"self",
".",
"type",
"==",
"0x11",
")",
":",
"if",
"(",
"self",
".",
"gaddr",
"==",
"\"... | Called to explicitely fixup an associated IP header
The function adjusts the IP header based on conformance rules
and the group address encoded in the IGMP message.
The rules are:
1. Send General Group Query to 224.0.0.1 (all systems)
2. Send Leave Group to 224.0.0.2 (all routers)
3a.Otherwise... | [
"Called",
"to",
"explicitely",
"fixup",
"an",
"associated",
"IP",
"header"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/igmpv3.py#L225-L264 |
phaethon/kamene | kamene/contrib/ospf.py | ospf_lsa_checksum | def ospf_lsa_checksum(lsa):
""" Fletcher checksum for OSPF LSAs, returned as a 2 byte string.
Give the whole LSA packet as argument.
For details on the algorithm, see RFC 2328 chapter 12.1.7 and RFC 905 Annex B.
"""
# This is based on the GPLed C implementation in Zebra <http://www.zebra.org/>
... | python | def ospf_lsa_checksum(lsa):
""" Fletcher checksum for OSPF LSAs, returned as a 2 byte string.
Give the whole LSA packet as argument.
For details on the algorithm, see RFC 2328 chapter 12.1.7 and RFC 905 Annex B.
"""
# This is based on the GPLed C implementation in Zebra <http://www.zebra.org/>
... | [
"def",
"ospf_lsa_checksum",
"(",
"lsa",
")",
":",
"# This is based on the GPLed C implementation in Zebra <http://www.zebra.org/>",
"CHKSUM_OFFSET",
"=",
"16",
"if",
"len",
"(",
"lsa",
")",
"<",
"CHKSUM_OFFSET",
":",
"raise",
"Exception",
"(",
"\"LSA Packet too short (%s by... | Fletcher checksum for OSPF LSAs, returned as a 2 byte string.
Give the whole LSA packet as argument.
For details on the algorithm, see RFC 2328 chapter 12.1.7 and RFC 905 Annex B. | [
"Fletcher",
"checksum",
"for",
"OSPF",
"LSAs",
"returned",
"as",
"a",
"2",
"byte",
"string",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/ospf.py#L208-L243 |
phaethon/kamene | kamene/contrib/ospf.py | _LSAGuessPayloadClass | def _LSAGuessPayloadClass(p, **kargs):
""" Guess the correct LSA class for a given payload """
# This is heavily based on scapy-cdp.py by Nicolas Bareil and Arnaud Ebalard
# XXX: This only works if all payload
cls = conf.raw_layer
if len(p) >= 4:
typ = p[3]
clsname = _OSPF_LSclasses.... | python | def _LSAGuessPayloadClass(p, **kargs):
""" Guess the correct LSA class for a given payload """
# This is heavily based on scapy-cdp.py by Nicolas Bareil and Arnaud Ebalard
# XXX: This only works if all payload
cls = conf.raw_layer
if len(p) >= 4:
typ = p[3]
clsname = _OSPF_LSclasses.... | [
"def",
"_LSAGuessPayloadClass",
"(",
"p",
",",
"*",
"*",
"kargs",
")",
":",
"# This is heavily based on scapy-cdp.py by Nicolas Bareil and Arnaud Ebalard",
"# XXX: This only works if all payload",
"cls",
"=",
"conf",
".",
"raw_layer",
"if",
"len",
"(",
"p",
")",
">=",
"... | Guess the correct LSA class for a given payload | [
"Guess",
"the",
"correct",
"LSA",
"class",
"for",
"a",
"given",
"payload"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/ospf.py#L283-L292 |
phaethon/kamene | kamene/layers/dot11.py | airpwn | def airpwn(iffrom, ifto, replace, pattern="", ignorepattern=""):
"""Before using this, initialize "iffrom" and "ifto" interfaces:
iwconfig iffrom mode monitor
iwpriv orig_ifto hostapd 1
ifconfig ifto up
note: if ifto=wlan0ap then orig_ifto=wlan0
note: ifto and iffrom must be set on the same channel
ex:
ifconfig eth... | python | def airpwn(iffrom, ifto, replace, pattern="", ignorepattern=""):
"""Before using this, initialize "iffrom" and "ifto" interfaces:
iwconfig iffrom mode monitor
iwpriv orig_ifto hostapd 1
ifconfig ifto up
note: if ifto=wlan0ap then orig_ifto=wlan0
note: ifto and iffrom must be set on the same channel
ex:
ifconfig eth... | [
"def",
"airpwn",
"(",
"iffrom",
",",
"ifto",
",",
"replace",
",",
"pattern",
"=",
"\"\"",
",",
"ignorepattern",
"=",
"\"\"",
")",
":",
"ptrn",
"=",
"re",
".",
"compile",
"(",
"pattern",
")",
"iptrn",
"=",
"re",
".",
"compile",
"(",
"ignorepattern",
"... | Before using this, initialize "iffrom" and "ifto" interfaces:
iwconfig iffrom mode monitor
iwpriv orig_ifto hostapd 1
ifconfig ifto up
note: if ifto=wlan0ap then orig_ifto=wlan0
note: ifto and iffrom must be set on the same channel
ex:
ifconfig eth1 up
iwconfig eth1 mode monitor
iwconfig eth1 channel 11
iwpriv wlan0 ho... | [
"Before",
"using",
"this",
"initialize",
"iffrom",
"and",
"ifto",
"interfaces",
":",
"iwconfig",
"iffrom",
"mode",
"monitor",
"iwpriv",
"orig_ifto",
"hostapd",
"1",
"ifconfig",
"ifto",
"up",
"note",
":",
"if",
"ifto",
"=",
"wlan0ap",
"then",
"orig_ifto",
"=",
... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/dot11.py#L647-L703 |
phaethon/kamene | kamene/modules/geoip.py | locate_ip | def locate_ip(ip):
"""Get geographic coordinates from IP using geoip database"""
ip=map(int,ip.split("."))
ip = ip[3]+(ip[2]<<8)+(ip[1]<<16)+(ip[0]<<24)
cloc = country_loc_kdb.get_base()
db = IP_country_kdb.get_base()
d=0
f=len(db)-1
while (f-d) > 1:
guess = (d+f)/2
if ... | python | def locate_ip(ip):
"""Get geographic coordinates from IP using geoip database"""
ip=map(int,ip.split("."))
ip = ip[3]+(ip[2]<<8)+(ip[1]<<16)+(ip[0]<<24)
cloc = country_loc_kdb.get_base()
db = IP_country_kdb.get_base()
d=0
f=len(db)-1
while (f-d) > 1:
guess = (d+f)/2
if ... | [
"def",
"locate_ip",
"(",
"ip",
")",
":",
"ip",
"=",
"map",
"(",
"int",
",",
"ip",
".",
"split",
"(",
"\".\"",
")",
")",
"ip",
"=",
"ip",
"[",
"3",
"]",
"+",
"(",
"ip",
"[",
"2",
"]",
"<<",
"8",
")",
"+",
"(",
"ip",
"[",
"1",
"]",
"<<",
... | Get geographic coordinates from IP using geoip database | [
"Get",
"geographic",
"coordinates",
"from",
"IP",
"using",
"geoip",
"database"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/modules/geoip.py#L52-L70 |
phaethon/kamene | kamene/layers/inet6.py | getmacbyip6 | def getmacbyip6(ip6, chainCC=0):
"""
Returns the mac address to be used for provided 'ip6' peer.
neighborCache.get() method is used on instantiated neighbor cache.
Resolution mechanism is described in associated doc string.
(chainCC parameter value ends up being passed to sending function
use... | python | def getmacbyip6(ip6, chainCC=0):
"""
Returns the mac address to be used for provided 'ip6' peer.
neighborCache.get() method is used on instantiated neighbor cache.
Resolution mechanism is described in associated doc string.
(chainCC parameter value ends up being passed to sending function
use... | [
"def",
"getmacbyip6",
"(",
"ip6",
",",
"chainCC",
"=",
"0",
")",
":",
"if",
"in6_ismaddr",
"(",
"ip6",
")",
":",
"# Multicast ",
"mac",
"=",
"in6_getnsmac",
"(",
"inet_pton",
"(",
"socket",
".",
"AF_INET6",
",",
"ip6",
")",
")",
"return",
"mac",
"iff",... | Returns the mac address to be used for provided 'ip6' peer.
neighborCache.get() method is used on instantiated neighbor cache.
Resolution mechanism is described in associated doc string.
(chainCC parameter value ends up being passed to sending function
used to perform the resolution, if needed) | [
"Returns",
"the",
"mac",
"address",
"to",
"be",
"used",
"for",
"provided",
"ip6",
"peer",
".",
"neighborCache",
".",
"get",
"()",
"method",
"is",
"used",
"on",
"instantiated",
"neighbor",
"cache",
".",
"Resolution",
"mechanism",
"is",
"described",
"in",
"ass... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet6.py#L86-L122 |
phaethon/kamene | kamene/layers/inet6.py | defragment6 | def defragment6(pktlist):
"""
Performs defragmentation of a list of IPv6 packets. Packets are reordered.
Crap is dropped. What lacks is completed by 'X' characters.
"""
l = [ x for x in pktlist if IPv6ExtHdrFragment in x ] # remove non fragments
if not l:
return []
id = l[0][IP... | python | def defragment6(pktlist):
"""
Performs defragmentation of a list of IPv6 packets. Packets are reordered.
Crap is dropped. What lacks is completed by 'X' characters.
"""
l = [ x for x in pktlist if IPv6ExtHdrFragment in x ] # remove non fragments
if not l:
return []
id = l[0][IP... | [
"def",
"defragment6",
"(",
"pktlist",
")",
":",
"l",
"=",
"[",
"x",
"for",
"x",
"in",
"pktlist",
"if",
"IPv6ExtHdrFragment",
"in",
"x",
"]",
"# remove non fragments",
"if",
"not",
"l",
":",
"return",
"[",
"]",
"id",
"=",
"l",
"[",
"0",
"]",
"[",
"I... | Performs defragmentation of a list of IPv6 packets. Packets are reordered.
Crap is dropped. What lacks is completed by 'X' characters. | [
"Performs",
"defragmentation",
"of",
"a",
"list",
"of",
"IPv6",
"packets",
".",
"Packets",
"are",
"reordered",
".",
"Crap",
"is",
"dropped",
".",
"What",
"lacks",
"is",
"completed",
"by",
"X",
"characters",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet6.py#L907-L956 |
phaethon/kamene | kamene/layers/inet6.py | names2dnsrepr | def names2dnsrepr(x):
"""
Take as input a list of DNS names or a single DNS name
and encode it in DNS format (with possible compression)
If a string that is already a DNS name in DNS format
is passed, it is returned unmodified. Result is a string.
!!! At the moment, compression is not implement... | python | def names2dnsrepr(x):
"""
Take as input a list of DNS names or a single DNS name
and encode it in DNS format (with possible compression)
If a string that is already a DNS name in DNS format
is passed, it is returned unmodified. Result is a string.
!!! At the moment, compression is not implement... | [
"def",
"names2dnsrepr",
"(",
"x",
")",
":",
"if",
"type",
"(",
"x",
")",
"is",
"str",
":",
"if",
"x",
"and",
"x",
"[",
"-",
"1",
"]",
"==",
"'\\x00'",
":",
"# stupid heuristic",
"return",
"x",
".",
"encode",
"(",
"'ascii'",
")",
"x",
"=",
"[",
... | Take as input a list of DNS names or a single DNS name
and encode it in DNS format (with possible compression)
If a string that is already a DNS name in DNS format
is passed, it is returned unmodified. Result is a string.
!!! At the moment, compression is not implemented !!! | [
"Take",
"as",
"input",
"a",
"list",
"of",
"DNS",
"names",
"or",
"a",
"single",
"DNS",
"name",
"and",
"encode",
"it",
"in",
"DNS",
"format",
"(",
"with",
"possible",
"compression",
")",
"If",
"a",
"string",
"that",
"is",
"already",
"a",
"DNS",
"name",
... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet6.py#L1899-L1926 |
phaethon/kamene | kamene/layers/inet6.py | dnsrepr2names | def dnsrepr2names(x):
"""
Take as input a DNS encoded string (possibly compressed)
and returns a list of DNS names contained in it.
If provided string is already in printable format
(does not end with a null character, a one element list
is returned). Result is a list.
"""
res = []
... | python | def dnsrepr2names(x):
"""
Take as input a DNS encoded string (possibly compressed)
and returns a list of DNS names contained in it.
If provided string is already in printable format
(does not end with a null character, a one element list
is returned). Result is a list.
"""
res = []
... | [
"def",
"dnsrepr2names",
"(",
"x",
")",
":",
"res",
"=",
"[",
"]",
"cur",
"=",
"b\"\"",
"if",
"type",
"(",
"x",
")",
"is",
"str",
":",
"x",
"=",
"x",
".",
"encode",
"(",
"'ascii'",
")",
"while",
"x",
":",
"#l = ord(x[0])",
"l",
"=",
"x",
"[",
... | Take as input a DNS encoded string (possibly compressed)
and returns a list of DNS names contained in it.
If provided string is already in printable format
(does not end with a null character, a one element list
is returned). Result is a list. | [
"Take",
"as",
"input",
"a",
"DNS",
"encoded",
"string",
"(",
"possibly",
"compressed",
")",
"and",
"returns",
"a",
"list",
"of",
"DNS",
"names",
"contained",
"in",
"it",
".",
"If",
"provided",
"string",
"is",
"already",
"in",
"printable",
"format",
"(",
... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet6.py#L1929-L1959 |
phaethon/kamene | kamene/layers/inet6.py | traceroute6 | def traceroute6(target, dport=80, minttl=1, maxttl=30, sport=RandShort(),
l4 = None, timeout=2, verbose=None, **kargs):
"""
Instant TCP traceroute using IPv6 :
traceroute6(target, [maxttl=30], [dport=80], [sport=80]) -> None
"""
if verbose is None:
verbose = conf.verb
i... | python | def traceroute6(target, dport=80, minttl=1, maxttl=30, sport=RandShort(),
l4 = None, timeout=2, verbose=None, **kargs):
"""
Instant TCP traceroute using IPv6 :
traceroute6(target, [maxttl=30], [dport=80], [sport=80]) -> None
"""
if verbose is None:
verbose = conf.verb
i... | [
"def",
"traceroute6",
"(",
"target",
",",
"dport",
"=",
"80",
",",
"minttl",
"=",
"1",
",",
"maxttl",
"=",
"30",
",",
"sport",
"=",
"RandShort",
"(",
")",
",",
"l4",
"=",
"None",
",",
"timeout",
"=",
"2",
",",
"verbose",
"=",
"None",
",",
"*",
... | Instant TCP traceroute using IPv6 :
traceroute6(target, [maxttl=30], [dport=80], [sport=80]) -> None | [
"Instant",
"TCP",
"traceroute",
"using",
"IPv6",
":",
"traceroute6",
"(",
"target",
"[",
"maxttl",
"=",
"30",
"]",
"[",
"dport",
"=",
"80",
"]",
"[",
"sport",
"=",
"80",
"]",
")",
"-",
">",
"None"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet6.py#L2943-L2964 |
phaethon/kamene | kamene/layers/inet6.py | AS_resolver6._resolve_one | def _resolve_one(self, ip):
"""
overloaded version to provide a Whois resolution on the
embedded IPv4 address if the address is 6to4 or Teredo.
Otherwise, the native IPv6 address is passed.
"""
if in6_isaddr6to4(ip): # for 6to4, use embedded @
tmp = inet_pto... | python | def _resolve_one(self, ip):
"""
overloaded version to provide a Whois resolution on the
embedded IPv4 address if the address is 6to4 or Teredo.
Otherwise, the native IPv6 address is passed.
"""
if in6_isaddr6to4(ip): # for 6to4, use embedded @
tmp = inet_pto... | [
"def",
"_resolve_one",
"(",
"self",
",",
"ip",
")",
":",
"if",
"in6_isaddr6to4",
"(",
"ip",
")",
":",
"# for 6to4, use embedded @",
"tmp",
"=",
"inet_pton",
"(",
"socket",
".",
"AF_INET6",
",",
"ip",
")",
"addr",
"=",
"inet_ntop",
"(",
"socket",
".",
"AF... | overloaded version to provide a Whois resolution on the
embedded IPv4 address if the address is 6to4 or Teredo.
Otherwise, the native IPv6 address is passed. | [
"overloaded",
"version",
"to",
"provide",
"a",
"Whois",
"resolution",
"on",
"the",
"embedded",
"IPv4",
"address",
"if",
"the",
"address",
"is",
"6to4",
"or",
"Teredo",
".",
"Otherwise",
"the",
"native",
"IPv6",
"address",
"is",
"passed",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet6.py#L2882-L2899 |
phaethon/kamene | kamene/arch/linux.py | in6_getifaddr | def in6_getifaddr():
"""
Returns a list of 3-tuples of the form (addr, scope, iface) where
'addr' is the address of scope 'scope' associated to the interface
'ifcace'.
This is the list of all addresses of all interfaces available on
the system.
"""
ret = []
try:
f = open("/p... | python | def in6_getifaddr():
"""
Returns a list of 3-tuples of the form (addr, scope, iface) where
'addr' is the address of scope 'scope' associated to the interface
'ifcace'.
This is the list of all addresses of all interfaces available on
the system.
"""
ret = []
try:
f = open("/p... | [
"def",
"in6_getifaddr",
"(",
")",
":",
"ret",
"=",
"[",
"]",
"try",
":",
"f",
"=",
"open",
"(",
"\"/proc/net/if_inet6\"",
",",
"\"rb\"",
")",
"except",
"IOError",
"as",
"err",
":",
"return",
"ret",
"l",
"=",
"f",
".",
"readlines",
"(",
")",
"for",
... | Returns a list of 3-tuples of the form (addr, scope, iface) where
'addr' is the address of scope 'scope' associated to the interface
'ifcace'.
This is the list of all addresses of all interfaces available on
the system. | [
"Returns",
"a",
"list",
"of",
"3",
"-",
"tuples",
"of",
"the",
"form",
"(",
"addr",
"scope",
"iface",
")",
"where",
"addr",
"is",
"the",
"address",
"of",
"scope",
"scope",
"associated",
"to",
"the",
"interface",
"ifcace",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/linux.py#L209-L231 |
phaethon/kamene | kamene/utils6.py | construct_source_candidate_set | def construct_source_candidate_set(addr, plen, laddr, loname):
"""
Given all addresses assigned to a specific interface ('laddr' parameter),
this function returns the "candidate set" associated with 'addr/plen'.
Basically, the function filters all interface addresses to keep only those
that hav... | python | def construct_source_candidate_set(addr, plen, laddr, loname):
"""
Given all addresses assigned to a specific interface ('laddr' parameter),
this function returns the "candidate set" associated with 'addr/plen'.
Basically, the function filters all interface addresses to keep only those
that hav... | [
"def",
"construct_source_candidate_set",
"(",
"addr",
",",
"plen",
",",
"laddr",
",",
"loname",
")",
":",
"def",
"cset_sort",
"(",
"x",
",",
"y",
")",
":",
"x_global",
"=",
"0",
"if",
"in6_isgladdr",
"(",
"x",
")",
":",
"x_global",
"=",
"1",
"y_global"... | Given all addresses assigned to a specific interface ('laddr' parameter),
this function returns the "candidate set" associated with 'addr/plen'.
Basically, the function filters all interface addresses to keep only those
that have the same scope as provided prefix.
This is on this list of addre... | [
"Given",
"all",
"addresses",
"assigned",
"to",
"a",
"specific",
"interface",
"(",
"laddr",
"parameter",
")",
"this",
"function",
"returns",
"the",
"candidate",
"set",
"associated",
"with",
"addr",
"/",
"plen",
".",
"Basically",
"the",
"function",
"filters",
"a... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils6.py#L39-L86 |
phaethon/kamene | kamene/utils6.py | in6_ifaceidtomac | def in6_ifaceidtomac(ifaceid): # TODO: finish commenting function behavior
"""
Extract the mac address from provided iface ID. Iface ID is provided
in printable format ("XXXX:XXFF:FEXX:XXXX", eventually compressed). None
is returned on error.
"""
try:
ifaceid = inet_pton(socket.AF_INET... | python | def in6_ifaceidtomac(ifaceid): # TODO: finish commenting function behavior
"""
Extract the mac address from provided iface ID. Iface ID is provided
in printable format ("XXXX:XXFF:FEXX:XXXX", eventually compressed). None
is returned on error.
"""
try:
ifaceid = inet_pton(socket.AF_INET... | [
"def",
"in6_ifaceidtomac",
"(",
"ifaceid",
")",
":",
"# TODO: finish commenting function behavior",
"try",
":",
"ifaceid",
"=",
"inet_pton",
"(",
"socket",
".",
"AF_INET6",
",",
"\"::\"",
"+",
"ifaceid",
")",
"[",
"8",
":",
"16",
"]",
"except",
":",
"return",
... | Extract the mac address from provided iface ID. Iface ID is provided
in printable format ("XXXX:XXFF:FEXX:XXXX", eventually compressed). None
is returned on error. | [
"Extract",
"the",
"mac",
"address",
"from",
"provided",
"iface",
"ID",
".",
"Iface",
"ID",
"is",
"provided",
"in",
"printable",
"format",
"(",
"XXXX",
":",
"XXFF",
":",
"FEXX",
":",
"XXXX",
"eventually",
"compressed",
")",
".",
"None",
"is",
"returned",
... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils6.py#L264-L283 |
phaethon/kamene | kamene/utils6.py | in6_get6to4Prefix | def in6_get6to4Prefix(addr):
"""
Returns the /48 6to4 prefix associated with provided IPv4 address
On error, None is returned. No check is performed on public/private
status of the address
"""
try:
addr = inet_pton(socket.AF_INET, addr)
addr = inet_ntop(socket.AF_INET6, b'\x20\x0... | python | def in6_get6to4Prefix(addr):
"""
Returns the /48 6to4 prefix associated with provided IPv4 address
On error, None is returned. No check is performed on public/private
status of the address
"""
try:
addr = inet_pton(socket.AF_INET, addr)
addr = inet_ntop(socket.AF_INET6, b'\x20\x0... | [
"def",
"in6_get6to4Prefix",
"(",
"addr",
")",
":",
"try",
":",
"addr",
"=",
"inet_pton",
"(",
"socket",
".",
"AF_INET",
",",
"addr",
")",
"addr",
"=",
"inet_ntop",
"(",
"socket",
".",
"AF_INET6",
",",
"b'\\x20\\x02'",
"+",
"addr",
"+",
"b'\\x00'",
"*",
... | Returns the /48 6to4 prefix associated with provided IPv4 address
On error, None is returned. No check is performed on public/private
status of the address | [
"Returns",
"the",
"/",
"48",
"6to4",
"prefix",
"associated",
"with",
"provided",
"IPv4",
"address",
"On",
"error",
"None",
"is",
"returned",
".",
"No",
"check",
"is",
"performed",
"on",
"public",
"/",
"private",
"status",
"of",
"the",
"address"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils6.py#L373-L384 |
phaethon/kamene | kamene/utils6.py | in6_6to4ExtractAddr | def in6_6to4ExtractAddr(addr):
"""
Extract IPv4 address embbeded in 6to4 address. Passed address must be
a 6to4 addrees. None is returned on error.
"""
try:
addr = inet_pton(socket.AF_INET6, addr)
except:
return None
if addr[:2] != b" \x02":
return None
return ine... | python | def in6_6to4ExtractAddr(addr):
"""
Extract IPv4 address embbeded in 6to4 address. Passed address must be
a 6to4 addrees. None is returned on error.
"""
try:
addr = inet_pton(socket.AF_INET6, addr)
except:
return None
if addr[:2] != b" \x02":
return None
return ine... | [
"def",
"in6_6to4ExtractAddr",
"(",
"addr",
")",
":",
"try",
":",
"addr",
"=",
"inet_pton",
"(",
"socket",
".",
"AF_INET6",
",",
"addr",
")",
"except",
":",
"return",
"None",
"if",
"addr",
"[",
":",
"2",
"]",
"!=",
"b\" \\x02\"",
":",
"return",
"None",
... | Extract IPv4 address embbeded in 6to4 address. Passed address must be
a 6to4 addrees. None is returned on error. | [
"Extract",
"IPv4",
"address",
"embbeded",
"in",
"6to4",
"address",
".",
"Passed",
"address",
"must",
"be",
"a",
"6to4",
"addrees",
".",
"None",
"is",
"returned",
"on",
"error",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils6.py#L386-L397 |
phaethon/kamene | kamene/utils6.py | in6_getLocalUniquePrefix | def in6_getLocalUniquePrefix():
"""
Returns a pseudo-randomly generated Local Unique prefix. Function
follows recommandation of Section 3.2.2 of RFC 4193 for prefix
generation.
"""
# Extracted from RFC 1305 (NTP) :
# NTP timestamps are represented as a 64-bit unsigned fixed-point number,
... | python | def in6_getLocalUniquePrefix():
"""
Returns a pseudo-randomly generated Local Unique prefix. Function
follows recommandation of Section 3.2.2 of RFC 4193 for prefix
generation.
"""
# Extracted from RFC 1305 (NTP) :
# NTP timestamps are represented as a 64-bit unsigned fixed-point number,
... | [
"def",
"in6_getLocalUniquePrefix",
"(",
")",
":",
"# Extracted from RFC 1305 (NTP) :",
"# NTP timestamps are represented as a 64-bit unsigned fixed-point number, ",
"# in seconds relative to 0h on 1 January 1900. The integer part is in the ",
"# first 32 bits and the fraction part in the last 32 bit... | Returns a pseudo-randomly generated Local Unique prefix. Function
follows recommandation of Section 3.2.2 of RFC 4193 for prefix
generation. | [
"Returns",
"a",
"pseudo",
"-",
"randomly",
"generated",
"Local",
"Unique",
"prefix",
".",
"Function",
"follows",
"recommandation",
"of",
"Section",
"3",
".",
"2",
".",
"2",
"of",
"RFC",
"4193",
"for",
"prefix",
"generation",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils6.py#L400-L428 |
phaethon/kamene | kamene/utils6.py | in6_getRandomizedIfaceId | def in6_getRandomizedIfaceId(ifaceid, previous=None):
"""
Implements the interface ID generation algorithm described in RFC 3041.
The function takes the Modified EUI-64 interface identifier generated
as described in RFC 4291 and an optional previous history value (the
first element of the output of ... | python | def in6_getRandomizedIfaceId(ifaceid, previous=None):
"""
Implements the interface ID generation algorithm described in RFC 3041.
The function takes the Modified EUI-64 interface identifier generated
as described in RFC 4291 and an optional previous history value (the
first element of the output of ... | [
"def",
"in6_getRandomizedIfaceId",
"(",
"ifaceid",
",",
"previous",
"=",
"None",
")",
":",
"s",
"=",
"[",
"]",
"if",
"previous",
"is",
"None",
":",
"#d = b\"\".join(map(chr, range(256)))",
"d",
"=",
"list",
"(",
"range",
"(",
"256",
")",
")",
"for",
"i",
... | Implements the interface ID generation algorithm described in RFC 3041.
The function takes the Modified EUI-64 interface identifier generated
as described in RFC 4291 and an optional previous history value (the
first element of the output of this function). If no previous interface
identifier is provide... | [
"Implements",
"the",
"interface",
"ID",
"generation",
"algorithm",
"described",
"in",
"RFC",
"3041",
".",
"The",
"function",
"takes",
"the",
"Modified",
"EUI",
"-",
"64",
"interface",
"identifier",
"generated",
"as",
"described",
"in",
"RFC",
"4291",
"and",
"a... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils6.py#L430-L466 |
phaethon/kamene | kamene/utils6.py | in6_ctop | def in6_ctop(addr):
"""
Convert an IPv6 address in Compact Representation Notation
(RFC 1924) to printable representation ;-)
Returns None on error.
"""
#if len(addr) != 20 or not reduce(lambda x,y: x and y, map(lambda x: x in _rfc1924map, addr)):
if len(addr) != 20 or not all(map(lambda x:... | python | def in6_ctop(addr):
"""
Convert an IPv6 address in Compact Representation Notation
(RFC 1924) to printable representation ;-)
Returns None on error.
"""
#if len(addr) != 20 or not reduce(lambda x,y: x and y, map(lambda x: x in _rfc1924map, addr)):
if len(addr) != 20 or not all(map(lambda x:... | [
"def",
"in6_ctop",
"(",
"addr",
")",
":",
"#if len(addr) != 20 or not reduce(lambda x,y: x and y, map(lambda x: x in _rfc1924map, addr)):",
"if",
"len",
"(",
"addr",
")",
"!=",
"20",
"or",
"not",
"all",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
"in",
"_rfc1924map",
... | Convert an IPv6 address in Compact Representation Notation
(RFC 1924) to printable representation ;-)
Returns None on error. | [
"Convert",
"an",
"IPv6",
"address",
"in",
"Compact",
"Representation",
"Notation",
"(",
"RFC",
"1924",
")",
"to",
"printable",
"representation",
";",
"-",
")",
"Returns",
"None",
"on",
"error",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils6.py#L476-L494 |
phaethon/kamene | kamene/utils6.py | in6_cidr2mask | def in6_cidr2mask(m):
"""
Return the mask (bitstring) associated with provided length
value. For instance if function is called on 48, return value is
'\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'.
"""
if m > 128 or m < 0:
raise Kamene_Exception("value provided... | python | def in6_cidr2mask(m):
"""
Return the mask (bitstring) associated with provided length
value. For instance if function is called on 48, return value is
'\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'.
"""
if m > 128 or m < 0:
raise Kamene_Exception("value provided... | [
"def",
"in6_cidr2mask",
"(",
"m",
")",
":",
"if",
"m",
">",
"128",
"or",
"m",
"<",
"0",
":",
"raise",
"Kamene_Exception",
"(",
"\"value provided to in6_cidr2mask outside [0, 128] domain (%d)\"",
"%",
"m",
")",
"t",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
... | Return the mask (bitstring) associated with provided length
value. For instance if function is called on 48, return value is
'\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'. | [
"Return",
"the",
"mask",
"(",
"bitstring",
")",
"associated",
"with",
"provided",
"length",
"value",
".",
"For",
"instance",
"if",
"function",
"is",
"called",
"on",
"48",
"return",
"value",
"is",
"\\",
"xff",
"\\",
"xff",
"\\",
"xff",
"\\",
"xff",
"\\",
... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils6.py#L618-L633 |
phaethon/kamene | kamene/utils6.py | in6_getnsmac | def in6_getnsmac(a): # return multicast Ethernet address associated with multicast v6 destination
"""
Return the multicast mac address associated with provided
IPv6 address. Passed address must be in network format.
"""
a = struct.unpack('16B', a)[-4:]
mac = '33:33:'
mac += (':'.join(map(l... | python | def in6_getnsmac(a): # return multicast Ethernet address associated with multicast v6 destination
"""
Return the multicast mac address associated with provided
IPv6 address. Passed address must be in network format.
"""
a = struct.unpack('16B', a)[-4:]
mac = '33:33:'
mac += (':'.join(map(l... | [
"def",
"in6_getnsmac",
"(",
"a",
")",
":",
"# return multicast Ethernet address associated with multicast v6 destination",
"a",
"=",
"struct",
".",
"unpack",
"(",
"'16B'",
",",
"a",
")",
"[",
"-",
"4",
":",
"]",
"mac",
"=",
"'33:33:'",
"mac",
"+=",
"(",
"':'",... | Return the multicast mac address associated with provided
IPv6 address. Passed address must be in network format. | [
"Return",
"the",
"multicast",
"mac",
"address",
"associated",
"with",
"provided",
"IPv6",
"address",
".",
"Passed",
"address",
"must",
"be",
"in",
"network",
"format",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils6.py#L646-L655 |
phaethon/kamene | kamene/contrib/bgp.py | BGPIPField.h2i | def h2i(self, pkt, h):
"""human x.x.x.x/y to internal"""
ip,mask = re.split( '/', h)
return int(mask), ip | python | def h2i(self, pkt, h):
"""human x.x.x.x/y to internal"""
ip,mask = re.split( '/', h)
return int(mask), ip | [
"def",
"h2i",
"(",
"self",
",",
"pkt",
",",
"h",
")",
":",
"ip",
",",
"mask",
"=",
"re",
".",
"split",
"(",
"'/'",
",",
"h",
")",
"return",
"int",
"(",
"mask",
")",
",",
"ip"
] | human x.x.x.x/y to internal | [
"human",
"x",
".",
"x",
".",
"x",
".",
"x",
"/",
"y",
"to",
"internal"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/bgp.py#L18-L21 |
phaethon/kamene | kamene/arch/windows/__init__.py | _where | def _where(filename, dirs=[], env="PATH"):
"""Find file in current dir or system path"""
if not isinstance(dirs, list):
dirs = [dirs]
if glob(filename):
return filename
paths = [os.curdir] + os.environ[env].split(os.path.pathsep) + dirs
for path in paths:
for match in glob(os... | python | def _where(filename, dirs=[], env="PATH"):
"""Find file in current dir or system path"""
if not isinstance(dirs, list):
dirs = [dirs]
if glob(filename):
return filename
paths = [os.curdir] + os.environ[env].split(os.path.pathsep) + dirs
for path in paths:
for match in glob(os... | [
"def",
"_where",
"(",
"filename",
",",
"dirs",
"=",
"[",
"]",
",",
"env",
"=",
"\"PATH\"",
")",
":",
"if",
"not",
"isinstance",
"(",
"dirs",
",",
"list",
")",
":",
"dirs",
"=",
"[",
"dirs",
"]",
"if",
"glob",
"(",
"filename",
")",
":",
"return",
... | Find file in current dir or system path | [
"Find",
"file",
"in",
"current",
"dir",
"or",
"system",
"path"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/windows/__init__.py#L30-L41 |
phaethon/kamene | kamene/arch/windows/__init__.py | win_find_exe | def win_find_exe(filename, installsubdir=None, env="ProgramFiles"):
"""Find executable in current dir, system path or given ProgramFiles subdir"""
for fn in [filename, filename+".exe"]:
try:
if installsubdir is None:
path = _where(fn)
else:
path = ... | python | def win_find_exe(filename, installsubdir=None, env="ProgramFiles"):
"""Find executable in current dir, system path or given ProgramFiles subdir"""
for fn in [filename, filename+".exe"]:
try:
if installsubdir is None:
path = _where(fn)
else:
path = ... | [
"def",
"win_find_exe",
"(",
"filename",
",",
"installsubdir",
"=",
"None",
",",
"env",
"=",
"\"ProgramFiles\"",
")",
":",
"for",
"fn",
"in",
"[",
"filename",
",",
"filename",
"+",
"\".exe\"",
"]",
":",
"try",
":",
"if",
"installsubdir",
"is",
"None",
":"... | Find executable in current dir, system path or given ProgramFiles subdir | [
"Find",
"executable",
"in",
"current",
"dir",
"system",
"path",
"or",
"given",
"ProgramFiles",
"subdir"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/windows/__init__.py#L43-L55 |
phaethon/kamene | kamene/arch/windows/__init__.py | sniff | def sniff(count=0, store=1, offline=None, prn = None, lfilter=None, L2socket=None, timeout=None, stop_callback=None, *arg, **karg):
"""Sniff packets
sniff([count=0,] [prn=None,] [store=1,] [offline=None,] [lfilter=None,] + L2ListenSocket args) -> list of packets
Select interface to sniff by setting conf.iface. Use ... | python | def sniff(count=0, store=1, offline=None, prn = None, lfilter=None, L2socket=None, timeout=None, stop_callback=None, *arg, **karg):
"""Sniff packets
sniff([count=0,] [prn=None,] [store=1,] [offline=None,] [lfilter=None,] + L2ListenSocket args) -> list of packets
Select interface to sniff by setting conf.iface. Use ... | [
"def",
"sniff",
"(",
"count",
"=",
"0",
",",
"store",
"=",
"1",
",",
"offline",
"=",
"None",
",",
"prn",
"=",
"None",
",",
"lfilter",
"=",
"None",
",",
"L2socket",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"stop_callback",
"=",
"None",
",",
... | Sniff packets
sniff([count=0,] [prn=None,] [store=1,] [offline=None,] [lfilter=None,] + L2ListenSocket args) -> list of packets
Select interface to sniff by setting conf.iface. Use show_interfaces() to see interface names.
count: number of packets to capture. 0 means infinity
store: wether to store sniffed packets ... | [
"Sniff",
"packets",
"sniff",
"(",
"[",
"count",
"=",
"0",
"]",
"[",
"prn",
"=",
"None",
"]",
"[",
"store",
"=",
"1",
"]",
"[",
"offline",
"=",
"None",
"]",
"[",
"lfilter",
"=",
"None",
"]",
"+",
"L2ListenSocket",
"args",
")",
"-",
">",
"list",
... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/windows/__init__.py#L445-L506 |
phaethon/kamene | kamene/arch/windows/__init__.py | NetworkInterface.init_loopback | def init_loopback(self, data):
"""Just initialize the object for our Pseudo Loopback"""
self.name = data["name"]
self.description = data['description']
self.win_index = data['win_index']
self.mac = data["mac"]
self.guid = data["guid"]
self.ip = "127.0.0.1" | python | def init_loopback(self, data):
"""Just initialize the object for our Pseudo Loopback"""
self.name = data["name"]
self.description = data['description']
self.win_index = data['win_index']
self.mac = data["mac"]
self.guid = data["guid"]
self.ip = "127.0.0.1" | [
"def",
"init_loopback",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"name",
"=",
"data",
"[",
"\"name\"",
"]",
"self",
".",
"description",
"=",
"data",
"[",
"'description'",
"]",
"self",
".",
"win_index",
"=",
"data",
"[",
"'win_index'",
"]",
"sel... | Just initialize the object for our Pseudo Loopback | [
"Just",
"initialize",
"the",
"object",
"for",
"our",
"Pseudo",
"Loopback"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/windows/__init__.py#L120-L127 |
phaethon/kamene | kamene/arch/windows/__init__.py | NetworkInterface.update | def update(self, data):
"""Update info about network interface according to given dnet dictionary"""
self.name = data["name"]
self.description = data['description']
self.win_index = data['win_index']
# Other attributes are optional
if conf.use_winpcapy:
self._... | python | def update(self, data):
"""Update info about network interface according to given dnet dictionary"""
self.name = data["name"]
self.description = data['description']
self.win_index = data['win_index']
# Other attributes are optional
if conf.use_winpcapy:
self._... | [
"def",
"update",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"name",
"=",
"data",
"[",
"\"name\"",
"]",
"self",
".",
"description",
"=",
"data",
"[",
"'description'",
"]",
"self",
".",
"win_index",
"=",
"data",
"[",
"'win_index'",
"]",
"# Other at... | Update info about network interface according to given dnet dictionary | [
"Update",
"info",
"about",
"network",
"interface",
"according",
"to",
"given",
"dnet",
"dictionary"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/windows/__init__.py#L129-L144 |
phaethon/kamene | kamene/arch/windows/__init__.py | NetworkInterfaceDict.pcap_name | def pcap_name(self, devname):
"""Return pcap device name for given Windows device name."""
try:
pcap_name = self.data[devname].pcap_name
except KeyError:
raise ValueError("Unknown network interface %r" % devname)
else:
return pcap_name | python | def pcap_name(self, devname):
"""Return pcap device name for given Windows device name."""
try:
pcap_name = self.data[devname].pcap_name
except KeyError:
raise ValueError("Unknown network interface %r" % devname)
else:
return pcap_name | [
"def",
"pcap_name",
"(",
"self",
",",
"devname",
")",
":",
"try",
":",
"pcap_name",
"=",
"self",
".",
"data",
"[",
"devname",
"]",
".",
"pcap_name",
"except",
"KeyError",
":",
"raise",
"ValueError",
"(",
"\"Unknown network interface %r\"",
"%",
"devname",
")... | Return pcap device name for given Windows device name. | [
"Return",
"pcap",
"device",
"name",
"for",
"given",
"Windows",
"device",
"name",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/windows/__init__.py#L175-L183 |
phaethon/kamene | kamene/arch/windows/__init__.py | NetworkInterfaceDict.devname | def devname(self, pcap_name):
"""Return Windows device name for given pcap device name."""
for devname, iface in self.items():
if iface.pcap_name == pcap_name:
return iface.name
raise ValueError("Unknown pypcap network interface %r" % pcap_name) | python | def devname(self, pcap_name):
"""Return Windows device name for given pcap device name."""
for devname, iface in self.items():
if iface.pcap_name == pcap_name:
return iface.name
raise ValueError("Unknown pypcap network interface %r" % pcap_name) | [
"def",
"devname",
"(",
"self",
",",
"pcap_name",
")",
":",
"for",
"devname",
",",
"iface",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"iface",
".",
"pcap_name",
"==",
"pcap_name",
":",
"return",
"iface",
".",
"name",
"raise",
"ValueError",
"(",
... | Return Windows device name for given pcap device name. | [
"Return",
"Windows",
"device",
"name",
"for",
"given",
"pcap",
"device",
"name",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/windows/__init__.py#L185-L191 |
phaethon/kamene | kamene/arch/windows/__init__.py | NetworkInterfaceDict.devname_from_index | def devname_from_index(self, if_index):
"""Return interface name from interface index"""
for devname, iface in self.items():
if iface.win_index == if_index:
return iface.name
raise ValueError("Unknown network interface index %r" % if_index) | python | def devname_from_index(self, if_index):
"""Return interface name from interface index"""
for devname, iface in self.items():
if iface.win_index == if_index:
return iface.name
raise ValueError("Unknown network interface index %r" % if_index) | [
"def",
"devname_from_index",
"(",
"self",
",",
"if_index",
")",
":",
"for",
"devname",
",",
"iface",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"iface",
".",
"win_index",
"==",
"if_index",
":",
"return",
"iface",
".",
"name",
"raise",
"ValueError",... | Return interface name from interface index | [
"Return",
"interface",
"name",
"from",
"interface",
"index"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/windows/__init__.py#L193-L198 |
phaethon/kamene | kamene/arch/windows/__init__.py | NetworkInterfaceDict.show | def show(self, resolve_mac=True):
"""Print list of available network interfaces in human readable form"""
print("%s %s %s %s" % ("INDEX".ljust(5), "IFACE".ljust(35), "IP".ljust(15), "MAC"))
for iface_name in sorted(self.data.keys()):
dev = self.data[iface_name]
mac = ... | python | def show(self, resolve_mac=True):
"""Print list of available network interfaces in human readable form"""
print("%s %s %s %s" % ("INDEX".ljust(5), "IFACE".ljust(35), "IP".ljust(15), "MAC"))
for iface_name in sorted(self.data.keys()):
dev = self.data[iface_name]
mac = ... | [
"def",
"show",
"(",
"self",
",",
"resolve_mac",
"=",
"True",
")",
":",
"print",
"(",
"\"%s %s %s %s\"",
"%",
"(",
"\"INDEX\"",
".",
"ljust",
"(",
"5",
")",
",",
"\"IFACE\"",
".",
"ljust",
"(",
"35",
")",
",",
"\"IP\"",
".",
"ljust",
"(",
"15",
"... | Print list of available network interfaces in human readable form | [
"Print",
"list",
"of",
"available",
"network",
"interfaces",
"in",
"human",
"readable",
"form"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/windows/__init__.py#L200-L209 |
phaethon/kamene | kamene/modules/p0f.py | p0f | def p0f(pkt):
"""Passive OS fingerprinting: which OS emitted this TCP packet ?
p0f(packet) -> accuracy, [list of guesses]
"""
db, sig = packet2p0f(pkt)
if db:
pb = db.get_base()
else:
pb = []
if not pb:
warning("p0f base empty.")
return []
#s = len(pb[0][0])
r... | python | def p0f(pkt):
"""Passive OS fingerprinting: which OS emitted this TCP packet ?
p0f(packet) -> accuracy, [list of guesses]
"""
db, sig = packet2p0f(pkt)
if db:
pb = db.get_base()
else:
pb = []
if not pb:
warning("p0f base empty.")
return []
#s = len(pb[0][0])
r... | [
"def",
"p0f",
"(",
"pkt",
")",
":",
"db",
",",
"sig",
"=",
"packet2p0f",
"(",
"pkt",
")",
"if",
"db",
":",
"pb",
"=",
"db",
".",
"get_base",
"(",
")",
"else",
":",
"pb",
"=",
"[",
"]",
"if",
"not",
"pb",
":",
"warning",
"(",
"\"p0f base empty.\... | Passive OS fingerprinting: which OS emitted this TCP packet ?
p0f(packet) -> accuracy, [list of guesses] | [
"Passive",
"OS",
"fingerprinting",
":",
"which",
"OS",
"emitted",
"this",
"TCP",
"packet",
"?",
"p0f",
"(",
"packet",
")",
"-",
">",
"accuracy",
"[",
"list",
"of",
"guesses",
"]"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/modules/p0f.py#L264-L283 |
phaethon/kamene | kamene/modules/p0f.py | p0f_impersonate | def p0f_impersonate(pkt, osgenre=None, osdetails=None, signature=None,
extrahops=0, mtu=1500, uptime=None):
"""Modifies pkt so that p0f will think it has been sent by a
specific OS. If osdetails is None, then we randomly pick up a
personality matching osgenre. If osgenre and signature are also ... | python | def p0f_impersonate(pkt, osgenre=None, osdetails=None, signature=None,
extrahops=0, mtu=1500, uptime=None):
"""Modifies pkt so that p0f will think it has been sent by a
specific OS. If osdetails is None, then we randomly pick up a
personality matching osgenre. If osgenre and signature are also ... | [
"def",
"p0f_impersonate",
"(",
"pkt",
",",
"osgenre",
"=",
"None",
",",
"osdetails",
"=",
"None",
",",
"signature",
"=",
"None",
",",
"extrahops",
"=",
"0",
",",
"mtu",
"=",
"1500",
",",
"uptime",
"=",
"None",
")",
":",
"pkt",
"=",
"pkt",
".",
"cop... | Modifies pkt so that p0f will think it has been sent by a
specific OS. If osdetails is None, then we randomly pick up a
personality matching osgenre. If osgenre and signature are also None,
we use a local signature (using p0f_getlocalsigs). If signature is
specified (as a tuple), we use the signature.
For now, only T... | [
"Modifies",
"pkt",
"so",
"that",
"p0f",
"will",
"think",
"it",
"has",
"been",
"sent",
"by",
"a",
"specific",
"OS",
".",
"If",
"osdetails",
"is",
"None",
"then",
"we",
"randomly",
"pick",
"up",
"a",
"personality",
"matching",
"osgenre",
".",
"If",
"osgenr... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/modules/p0f.py#L329-L497 |
phaethon/kamene | kamene/modules/p0f.py | p0f_getlocalsigs | def p0f_getlocalsigs():
"""This function returns a dictionary of signatures indexed by p0f
db (e.g., p0f_kdb, p0fa_kdb, ...) for the local TCP/IP stack.
You need to have your firewall at least accepting the TCP packets
from/to a high port (30000 <= x <= 40000) on your loopback interface.
Please note that the gene... | python | def p0f_getlocalsigs():
"""This function returns a dictionary of signatures indexed by p0f
db (e.g., p0f_kdb, p0fa_kdb, ...) for the local TCP/IP stack.
You need to have your firewall at least accepting the TCP packets
from/to a high port (30000 <= x <= 40000) on your loopback interface.
Please note that the gene... | [
"def",
"p0f_getlocalsigs",
"(",
")",
":",
"pid",
"=",
"os",
".",
"fork",
"(",
")",
"port",
"=",
"random",
".",
"randint",
"(",
"30000",
",",
"40000",
")",
"if",
"pid",
">",
"0",
":",
"# parent: sniff",
"result",
"=",
"{",
"}",
"def",
"addresult",
"... | This function returns a dictionary of signatures indexed by p0f
db (e.g., p0f_kdb, p0fa_kdb, ...) for the local TCP/IP stack.
You need to have your firewall at least accepting the TCP packets
from/to a high port (30000 <= x <= 40000) on your loopback interface.
Please note that the generated signatures come from the ... | [
"This",
"function",
"returns",
"a",
"dictionary",
"of",
"signatures",
"indexed",
"by",
"p0f",
"db",
"(",
"e",
".",
"g",
".",
"p0f_kdb",
"p0fa_kdb",
"...",
")",
"for",
"the",
"local",
"TCP",
"/",
"IP",
"stack",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/modules/p0f.py#L499-L548 |
phaethon/kamene | kamene/layers/dns.py | bitmap2RRlist | def bitmap2RRlist(bitmap):
"""
Decode the 'Type Bit Maps' field of the NSEC Resource Record into an
integer list.
"""
# RFC 4034, 4.1.2. The Type Bit Maps Field
RRlist = []
while bitmap:
if len(bitmap) < 2:
warning("bitmap too short (%i)" % len(bitmap))
re... | python | def bitmap2RRlist(bitmap):
"""
Decode the 'Type Bit Maps' field of the NSEC Resource Record into an
integer list.
"""
# RFC 4034, 4.1.2. The Type Bit Maps Field
RRlist = []
while bitmap:
if len(bitmap) < 2:
warning("bitmap too short (%i)" % len(bitmap))
re... | [
"def",
"bitmap2RRlist",
"(",
"bitmap",
")",
":",
"# RFC 4034, 4.1.2. The Type Bit Maps Field",
"RRlist",
"=",
"[",
"]",
"while",
"bitmap",
":",
"if",
"len",
"(",
"bitmap",
")",
"<",
"2",
":",
"warning",
"(",
"\"bitmap too short (%i)\"",
"%",
"len",
"(",
"bitma... | Decode the 'Type Bit Maps' field of the NSEC Resource Record into an
integer list. | [
"Decode",
"the",
"Type",
"Bit",
"Maps",
"field",
"of",
"the",
"NSEC",
"Resource",
"Record",
"into",
"an",
"integer",
"list",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/dns.py#L376-L416 |
phaethon/kamene | kamene/layers/dns.py | RRlist2bitmap | def RRlist2bitmap(lst):
"""
Encode a list of integers representing Resource Records to a bitmap field
used in the NSEC Resource Record.
"""
# RFC 4034, 4.1.2. The Type Bit Maps Field
import math
bitmap = b""
lst = list(set(lst))
lst.sort()
#lst = filter(lambda x: x <= 655... | python | def RRlist2bitmap(lst):
"""
Encode a list of integers representing Resource Records to a bitmap field
used in the NSEC Resource Record.
"""
# RFC 4034, 4.1.2. The Type Bit Maps Field
import math
bitmap = b""
lst = list(set(lst))
lst.sort()
#lst = filter(lambda x: x <= 655... | [
"def",
"RRlist2bitmap",
"(",
"lst",
")",
":",
"# RFC 4034, 4.1.2. The Type Bit Maps Field",
"import",
"math",
"bitmap",
"=",
"b\"\"",
"lst",
"=",
"list",
"(",
"set",
"(",
"lst",
")",
")",
"lst",
".",
"sort",
"(",
")",
"#lst = filter(lambda x: x <= 65535, lst)",
... | Encode a list of integers representing Resource Records to a bitmap field
used in the NSEC Resource Record. | [
"Encode",
"a",
"list",
"of",
"integers",
"representing",
"Resource",
"Records",
"to",
"a",
"bitmap",
"field",
"used",
"in",
"the",
"NSEC",
"Resource",
"Record",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/dns.py#L419-L480 |
phaethon/kamene | kamene/contrib/gtp.py | IE_Dispatcher | def IE_Dispatcher(s):
"""Choose the correct Information Element class."""
if len(s) < 1:
return Raw(s)
# Get the IE type
ietype = ord(s[0])
cls = ietypecls.get(ietype, Raw)
# if ietype greater than 128 are TLVs
if cls == Raw and ietype & 128 == 128:
cls = IE_NotImplementedTLV
return cls(s) | python | def IE_Dispatcher(s):
"""Choose the correct Information Element class."""
if len(s) < 1:
return Raw(s)
# Get the IE type
ietype = ord(s[0])
cls = ietypecls.get(ietype, Raw)
# if ietype greater than 128 are TLVs
if cls == Raw and ietype & 128 == 128:
cls = IE_NotImplementedTLV
return cls(s) | [
"def",
"IE_Dispatcher",
"(",
"s",
")",
":",
"if",
"len",
"(",
"s",
")",
"<",
"1",
":",
"return",
"Raw",
"(",
"s",
")",
"# Get the IE type",
"ietype",
"=",
"ord",
"(",
"s",
"[",
"0",
"]",
")",
"cls",
"=",
"ietypecls",
".",
"get",
"(",
"ietype",
... | Choose the correct Information Element class. | [
"Choose",
"the",
"correct",
"Information",
"Element",
"class",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gtp.py#L399-L413 |
phaethon/kamene | kamene/plist.py | PacketList.nsummary | def nsummary(self,prn=None, lfilter=None):
"""prints a summary of each packet with the packet's number
prn: function to apply to each packet instead of lambda x:x.summary()
lfilter: truth function to apply to each packet to decide whether it will be displayed"""
for i, p in enumerate(self.res):
... | python | def nsummary(self,prn=None, lfilter=None):
"""prints a summary of each packet with the packet's number
prn: function to apply to each packet instead of lambda x:x.summary()
lfilter: truth function to apply to each packet to decide whether it will be displayed"""
for i, p in enumerate(self.res):
... | [
"def",
"nsummary",
"(",
"self",
",",
"prn",
"=",
"None",
",",
"lfilter",
"=",
"None",
")",
":",
"for",
"i",
",",
"p",
"in",
"enumerate",
"(",
"self",
".",
"res",
")",
":",
"if",
"lfilter",
"is",
"not",
"None",
":",
"if",
"not",
"lfilter",
"(",
... | prints a summary of each packet with the packet's number
prn: function to apply to each packet instead of lambda x:x.summary()
lfilter: truth function to apply to each packet to decide whether it will be displayed | [
"prints",
"a",
"summary",
"of",
"each",
"packet",
"with",
"the",
"packet",
"s",
"number",
"prn",
":",
"function",
"to",
"apply",
"to",
"each",
"packet",
"instead",
"of",
"lambda",
"x",
":",
"x",
".",
"summary",
"()",
"lfilter",
":",
"truth",
"function",
... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L113-L125 |
phaethon/kamene | kamene/plist.py | PacketList.filter | def filter(self, func):
"""Returns a packet list filtered by a truth function"""
return self.__class__(list(filter(func,self.res)),
name="filtered %s"%self.listname) | python | def filter(self, func):
"""Returns a packet list filtered by a truth function"""
return self.__class__(list(filter(func,self.res)),
name="filtered %s"%self.listname) | [
"def",
"filter",
"(",
"self",
",",
"func",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"list",
"(",
"filter",
"(",
"func",
",",
"self",
".",
"res",
")",
")",
",",
"name",
"=",
"\"filtered %s\"",
"%",
"self",
".",
"listname",
")"
] | Returns a packet list filtered by a truth function | [
"Returns",
"a",
"packet",
"list",
"filtered",
"by",
"a",
"truth",
"function"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L133-L136 |
phaethon/kamene | kamene/plist.py | PacketList.plot | def plot(self, f, lfilter=None,**kargs):
"""Applies a function to each packet to get a value that will be plotted with matplotlib. A matplotlib object is returned
lfilter: a truth function that decides whether a packet must be ploted"""
return plt.plot([ f(i) for i in self.res if not lfilter or... | python | def plot(self, f, lfilter=None,**kargs):
"""Applies a function to each packet to get a value that will be plotted with matplotlib. A matplotlib object is returned
lfilter: a truth function that decides whether a packet must be ploted"""
return plt.plot([ f(i) for i in self.res if not lfilter or... | [
"def",
"plot",
"(",
"self",
",",
"f",
",",
"lfilter",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"return",
"plt",
".",
"plot",
"(",
"[",
"f",
"(",
"i",
")",
"for",
"i",
"in",
"self",
".",
"res",
"if",
"not",
"lfilter",
"or",
"lfilter",
"(... | Applies a function to each packet to get a value that will be plotted with matplotlib. A matplotlib object is returned
lfilter: a truth function that decides whether a packet must be ploted | [
"Applies",
"a",
"function",
"to",
"each",
"packet",
"to",
"get",
"a",
"value",
"that",
"will",
"be",
"plotted",
"with",
"matplotlib",
".",
"A",
"matplotlib",
"object",
"is",
"returned",
"lfilter",
":",
"a",
"truth",
"function",
"that",
"decides",
"whether",
... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L138-L142 |
phaethon/kamene | kamene/plist.py | PacketList.diffplot | def diffplot(self, f, delay=1, lfilter=None, **kargs):
"""diffplot(f, delay=1, lfilter=None)
Applies a function to couples (l[i],l[i+delay])"""
return plt.plot([ f(i, j) for i in self.res[:-delay] for j in self.res[delay:] if not lfilter or (lfilter(i) and lfilter(j))],
**kargs) | python | def diffplot(self, f, delay=1, lfilter=None, **kargs):
"""diffplot(f, delay=1, lfilter=None)
Applies a function to couples (l[i],l[i+delay])"""
return plt.plot([ f(i, j) for i in self.res[:-delay] for j in self.res[delay:] if not lfilter or (lfilter(i) and lfilter(j))],
**kargs) | [
"def",
"diffplot",
"(",
"self",
",",
"f",
",",
"delay",
"=",
"1",
",",
"lfilter",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"return",
"plt",
".",
"plot",
"(",
"[",
"f",
"(",
"i",
",",
"j",
")",
"for",
"i",
"in",
"self",
".",
"res",
"["... | diffplot(f, delay=1, lfilter=None)
Applies a function to couples (l[i],l[i+delay]) | [
"diffplot",
"(",
"f",
"delay",
"=",
"1",
"lfilter",
"=",
"None",
")",
"Applies",
"a",
"function",
"to",
"couples",
"(",
"l",
"[",
"i",
"]",
"l",
"[",
"i",
"+",
"delay",
"]",
")"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L144-L149 |
phaethon/kamene | kamene/plist.py | PacketList.multiplot | def multiplot(self, f, lfilter=None, **kargs):
"""Uses a function that returns a label and a value for this label, then plots all the values label by label"""
d = defaultdict(list)
for i in self.res:
if lfilter and not lfilter(i):
continue
k, v = f(i)
... | python | def multiplot(self, f, lfilter=None, **kargs):
"""Uses a function that returns a label and a value for this label, then plots all the values label by label"""
d = defaultdict(list)
for i in self.res:
if lfilter and not lfilter(i):
continue
k, v = f(i)
... | [
"def",
"multiplot",
"(",
"self",
",",
"f",
",",
"lfilter",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"d",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"i",
"in",
"self",
".",
"res",
":",
"if",
"lfilter",
"and",
"not",
"lfilter",
"(",
"i",
... | Uses a function that returns a label and a value for this label, then plots all the values label by label | [
"Uses",
"a",
"function",
"that",
"returns",
"a",
"label",
"and",
"a",
"value",
"for",
"this",
"label",
"then",
"plots",
"all",
"the",
"values",
"label",
"by",
"label"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L151-L165 |
phaethon/kamene | kamene/plist.py | PacketList.conversations | def conversations(self, getsrcdst=None, draw = True, **kargs):
"""Graphes a conversations between sources and destinations and display it
(using graphviz)
getsrcdst: a function that takes an element of the list and return the source and dest
by defaults, return source and dest... | python | def conversations(self, getsrcdst=None, draw = True, **kargs):
"""Graphes a conversations between sources and destinations and display it
(using graphviz)
getsrcdst: a function that takes an element of the list and return the source and dest
by defaults, return source and dest... | [
"def",
"conversations",
"(",
"self",
",",
"getsrcdst",
"=",
"None",
",",
"draw",
"=",
"True",
",",
"*",
"*",
"kargs",
")",
":",
"if",
"getsrcdst",
"is",
"None",
":",
"getsrcdst",
"=",
"lambda",
"x",
":",
"(",
"x",
"[",
"'IP'",
"]",
".",
"src",
",... | Graphes a conversations between sources and destinations and display it
(using graphviz)
getsrcdst: a function that takes an element of the list and return the source and dest
by defaults, return source and destination IP
if networkx library is available returns a DiGraph, or ... | [
"Graphes",
"a",
"conversations",
"between",
"sources",
"and",
"destinations",
"and",
"display",
"it",
"(",
"using",
"graphviz",
")",
"getsrcdst",
":",
"a",
"function",
"that",
"takes",
"an",
"element",
"of",
"the",
"list",
"and",
"return",
"the",
"source",
"... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L224-L262 |
phaethon/kamene | kamene/plist.py | PacketList.afterglow | def afterglow(self, src=None, event=None, dst=None, **kargs):
"""Experimental clone attempt of http://sourceforge.net/projects/afterglow
each datum is reduced as src -> event -> dst and the data are graphed.
by default we have IP.src -> IP.dport -> IP.dst"""
if src is None:
s... | python | def afterglow(self, src=None, event=None, dst=None, **kargs):
"""Experimental clone attempt of http://sourceforge.net/projects/afterglow
each datum is reduced as src -> event -> dst and the data are graphed.
by default we have IP.src -> IP.dport -> IP.dst"""
if src is None:
s... | [
"def",
"afterglow",
"(",
"self",
",",
"src",
"=",
"None",
",",
"event",
"=",
"None",
",",
"dst",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"if",
"src",
"is",
"None",
":",
"src",
"=",
"lambda",
"x",
":",
"x",
"[",
"'IP'",
"]",
".",
"src",... | Experimental clone attempt of http://sourceforge.net/projects/afterglow
each datum is reduced as src -> event -> dst and the data are graphed.
by default we have IP.src -> IP.dport -> IP.dst | [
"Experimental",
"clone",
"attempt",
"of",
"http",
":",
"//",
"sourceforge",
".",
"net",
"/",
"projects",
"/",
"afterglow",
"each",
"datum",
"is",
"reduced",
"as",
"src",
"-",
">",
"event",
"-",
">",
"dst",
"and",
"the",
"data",
"are",
"graphed",
".",
"... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L264-L343 |
phaethon/kamene | kamene/plist.py | PacketList.psdump | def psdump(self, filename = None, **kargs):
"""Creates a multipage poscript file with a psdump of every packet
filename: name of the file to write to. If empty, a temporary file is used and
conf.prog.psreader is called"""
d = self._dump_document(**kargs)
if filename is ... | python | def psdump(self, filename = None, **kargs):
"""Creates a multipage poscript file with a psdump of every packet
filename: name of the file to write to. If empty, a temporary file is used and
conf.prog.psreader is called"""
d = self._dump_document(**kargs)
if filename is ... | [
"def",
"psdump",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"d",
"=",
"self",
".",
"_dump_document",
"(",
"*",
"*",
"kargs",
")",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"get_temp_file",
"(",
"autoext",... | Creates a multipage poscript file with a psdump of every packet
filename: name of the file to write to. If empty, a temporary file is used and
conf.prog.psreader is called | [
"Creates",
"a",
"multipage",
"poscript",
"file",
"with",
"a",
"psdump",
"of",
"every",
"packet",
"filename",
":",
"name",
"of",
"the",
"file",
"to",
"write",
"to",
".",
"If",
"empty",
"a",
"temporary",
"file",
"is",
"used",
"and",
"conf",
".",
"prog",
... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L364-L375 |
phaethon/kamene | kamene/plist.py | PacketList.pdfdump | def pdfdump(self, filename = None, **kargs):
"""Creates a PDF file with a psdump of every packet
filename: name of the file to write to. If empty, a temporary file is used and
conf.prog.pdfreader is called"""
d = self._dump_document(**kargs)
if filename is None:
... | python | def pdfdump(self, filename = None, **kargs):
"""Creates a PDF file with a psdump of every packet
filename: name of the file to write to. If empty, a temporary file is used and
conf.prog.pdfreader is called"""
d = self._dump_document(**kargs)
if filename is None:
... | [
"def",
"pdfdump",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"*",
"*",
"kargs",
")",
":",
"d",
"=",
"self",
".",
"_dump_document",
"(",
"*",
"*",
"kargs",
")",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"get_temp_file",
"(",
"autoext"... | Creates a PDF file with a psdump of every packet
filename: name of the file to write to. If empty, a temporary file is used and
conf.prog.pdfreader is called | [
"Creates",
"a",
"PDF",
"file",
"with",
"a",
"psdump",
"of",
"every",
"packet",
"filename",
":",
"name",
"of",
"the",
"file",
"to",
"write",
"to",
".",
"If",
"empty",
"a",
"temporary",
"file",
"is",
"used",
"and",
"conf",
".",
"prog",
".",
"pdfreader",
... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L377-L388 |
phaethon/kamene | kamene/plist.py | SndRcvList.summary | def summary(self, prn=None, lfilter=None):
"""prints a summary of each SndRcv packet pair
prn: function to apply to each packet pair instead of lambda s, r: "%s ==> %s" % (s.summary(),r.summary())
lfilter: truth function to apply to each packet pair to decide whether it will be displayed"""
for s, r... | python | def summary(self, prn=None, lfilter=None):
"""prints a summary of each SndRcv packet pair
prn: function to apply to each packet pair instead of lambda s, r: "%s ==> %s" % (s.summary(),r.summary())
lfilter: truth function to apply to each packet pair to decide whether it will be displayed"""
for s, r... | [
"def",
"summary",
"(",
"self",
",",
"prn",
"=",
"None",
",",
"lfilter",
"=",
"None",
")",
":",
"for",
"s",
",",
"r",
"in",
"self",
".",
"res",
":",
"if",
"lfilter",
"is",
"not",
"None",
":",
"if",
"not",
"lfilter",
"(",
"s",
",",
"r",
")",
":... | prints a summary of each SndRcv packet pair
prn: function to apply to each packet pair instead of lambda s, r: "%s ==> %s" % (s.summary(),r.summary())
lfilter: truth function to apply to each packet pair to decide whether it will be displayed | [
"prints",
"a",
"summary",
"of",
"each",
"SndRcv",
"packet",
"pair",
"prn",
":",
"function",
"to",
"apply",
"to",
"each",
"packet",
"pair",
"instead",
"of",
"lambda",
"s",
"r",
":",
"%s",
"==",
">",
"%s",
"%",
"(",
"s",
".",
"summary",
"()",
"r",
".... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L479-L490 |
phaethon/kamene | kamene/plist.py | SndRcvList.nsummary | def nsummary(self,prn=None, lfilter=None):
"""prints a summary of each SndRcv packet pair with the pair's number
prn: function to apply to each packet pair instead of lambda s, r: "%s ==> %s" % (s.summary(),r.summary())
lfilter: truth function to apply to each packet pair to decide whether it will be displ... | python | def nsummary(self,prn=None, lfilter=None):
"""prints a summary of each SndRcv packet pair with the pair's number
prn: function to apply to each packet pair instead of lambda s, r: "%s ==> %s" % (s.summary(),r.summary())
lfilter: truth function to apply to each packet pair to decide whether it will be displ... | [
"def",
"nsummary",
"(",
"self",
",",
"prn",
"=",
"None",
",",
"lfilter",
"=",
"None",
")",
":",
"for",
"i",
",",
"(",
"s",
",",
"r",
")",
"in",
"enumerate",
"(",
"self",
".",
"res",
")",
":",
"if",
"lfilter",
"is",
"not",
"None",
":",
"if",
"... | prints a summary of each SndRcv packet pair with the pair's number
prn: function to apply to each packet pair instead of lambda s, r: "%s ==> %s" % (s.summary(),r.summary())
lfilter: truth function to apply to each packet pair to decide whether it will be displayed | [
"prints",
"a",
"summary",
"of",
"each",
"SndRcv",
"packet",
"pair",
"with",
"the",
"pair",
"s",
"number",
"prn",
":",
"function",
"to",
"apply",
"to",
"each",
"packet",
"pair",
"instead",
"of",
"lambda",
"s",
"r",
":",
"%s",
"==",
">",
"%s",
"%",
"("... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L491-L503 |
phaethon/kamene | kamene/plist.py | SndRcvList.filter | def filter(self, func):
"""Returns a SndRcv list filtered by a truth function"""
return self.__class__( [ i for i in self.res if func(*i) ], name='filtered %s'%self.listname) | python | def filter(self, func):
"""Returns a SndRcv list filtered by a truth function"""
return self.__class__( [ i for i in self.res if func(*i) ], name='filtered %s'%self.listname) | [
"def",
"filter",
"(",
"self",
",",
"func",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"[",
"i",
"for",
"i",
"in",
"self",
".",
"res",
"if",
"func",
"(",
"*",
"i",
")",
"]",
",",
"name",
"=",
"'filtered %s'",
"%",
"self",
".",
"listname",
... | Returns a SndRcv list filtered by a truth function | [
"Returns",
"a",
"SndRcv",
"list",
"filtered",
"by",
"a",
"truth",
"function"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L504-L506 |
phaethon/kamene | kamene/contrib/ppi.py | _PPIGuessPayloadClass | def _PPIGuessPayloadClass(p, **kargs):
""" This function tells the PacketListField how it should extract the
TLVs from the payload. We pass cls only the length string
pfh_len says it needs. If a payload is returned, that means
part of the sting was unused. This converts to a Raw layer... | python | def _PPIGuessPayloadClass(p, **kargs):
""" This function tells the PacketListField how it should extract the
TLVs from the payload. We pass cls only the length string
pfh_len says it needs. If a payload is returned, that means
part of the sting was unused. This converts to a Raw layer... | [
"def",
"_PPIGuessPayloadClass",
"(",
"p",
",",
"*",
"*",
"kargs",
")",
":",
"if",
"len",
"(",
"p",
")",
">=",
"4",
":",
"t",
",",
"pfh_len",
"=",
"struct",
".",
"unpack",
"(",
"\"<HH\"",
",",
"p",
"[",
":",
"4",
"]",
")",
"# Find out if the value t... | This function tells the PacketListField how it should extract the
TLVs from the payload. We pass cls only the length string
pfh_len says it needs. If a payload is returned, that means
part of the sting was unused. This converts to a Raw layer, and
the remainder of p is added as Ra... | [
"This",
"function",
"tells",
"the",
"PacketListField",
"how",
"it",
"should",
"extract",
"the",
"TLVs",
"from",
"the",
"payload",
".",
"We",
"pass",
"cls",
"only",
"the",
"length",
"string",
"pfh_len",
"says",
"it",
"needs",
".",
"If",
"a",
"payload",
"is"... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/ppi.py#L38-L62 |
phaethon/kamene | kamene/fields.py | Field.i2b | def i2b(self, pkt, x):
"""Convert internal value to internal value"""
if type(x) is str:
x = bytes([ ord(i) for i in x ])
return x | python | def i2b(self, pkt, x):
"""Convert internal value to internal value"""
if type(x) is str:
x = bytes([ ord(i) for i in x ])
return x | [
"def",
"i2b",
"(",
"self",
",",
"pkt",
",",
"x",
")",
":",
"if",
"type",
"(",
"x",
")",
"is",
"str",
":",
"x",
"=",
"bytes",
"(",
"[",
"ord",
"(",
"i",
")",
"for",
"i",
"in",
"x",
"]",
")",
"return",
"x"
] | Convert internal value to internal value | [
"Convert",
"internal",
"value",
"to",
"internal",
"value"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/fields.py#L45-L49 |
phaethon/kamene | kamene/fields.py | Field.randval | def randval(self):
"""Return a volatile object whose value is both random and suitable for this field"""
fmtt = self.fmt[-1]
if fmtt in "BHIQ":
return {"B":RandByte,"H":RandShort,"I":RandInt, "Q":RandLong}[fmtt]()
elif fmtt == "s":
if self.fmt[0] in "0123456789":
... | python | def randval(self):
"""Return a volatile object whose value is both random and suitable for this field"""
fmtt = self.fmt[-1]
if fmtt in "BHIQ":
return {"B":RandByte,"H":RandShort,"I":RandInt, "Q":RandLong}[fmtt]()
elif fmtt == "s":
if self.fmt[0] in "0123456789":
... | [
"def",
"randval",
"(",
"self",
")",
":",
"fmtt",
"=",
"self",
".",
"fmt",
"[",
"-",
"1",
"]",
"if",
"fmtt",
"in",
"\"BHIQ\"",
":",
"return",
"{",
"\"B\"",
":",
"RandByte",
",",
"\"H\"",
":",
"RandShort",
",",
"\"I\"",
":",
"RandInt",
",",
"\"Q\"",
... | Return a volatile object whose value is both random and suitable for this field | [
"Return",
"a",
"volatile",
"object",
"whose",
"value",
"is",
"both",
"random",
"and",
"suitable",
"for",
"this",
"field"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/fields.py#L93-L105 |
phaethon/kamene | kamene/layers/can.py | srcanloop | def srcanloop(pkts, *args, **kargs):
"""Send a packet at can layer in loop and print the answer each time
srloop(pkts, [prn], [inter], [count], ...) --> None"""
return sendrecv.__sr_loop(srcan, pkts, *args, **kargs) | python | def srcanloop(pkts, *args, **kargs):
"""Send a packet at can layer in loop and print the answer each time
srloop(pkts, [prn], [inter], [count], ...) --> None"""
return sendrecv.__sr_loop(srcan, pkts, *args, **kargs) | [
"def",
"srcanloop",
"(",
"pkts",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"return",
"sendrecv",
".",
"__sr_loop",
"(",
"srcan",
",",
"pkts",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")"
] | Send a packet at can layer in loop and print the answer each time
srloop(pkts, [prn], [inter], [count], ...) --> None | [
"Send",
"a",
"packet",
"at",
"can",
"layer",
"in",
"loop",
"and",
"print",
"the",
"answer",
"each",
"time",
"srloop",
"(",
"pkts",
"[",
"prn",
"]",
"[",
"inter",
"]",
"[",
"count",
"]",
"...",
")",
"--",
">",
"None"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/can.py#L119-L122 |
phaethon/kamene | kamene/utils.py | str2bytes | def str2bytes(x):
"""Convert input argument to bytes"""
if type(x) is bytes:
return x
elif type(x) is str:
return bytes([ ord(i) for i in x ])
else:
return str2bytes(str(x)) | python | def str2bytes(x):
"""Convert input argument to bytes"""
if type(x) is bytes:
return x
elif type(x) is str:
return bytes([ ord(i) for i in x ])
else:
return str2bytes(str(x)) | [
"def",
"str2bytes",
"(",
"x",
")",
":",
"if",
"type",
"(",
"x",
")",
"is",
"bytes",
":",
"return",
"x",
"elif",
"type",
"(",
"x",
")",
"is",
"str",
":",
"return",
"bytes",
"(",
"[",
"ord",
"(",
"i",
")",
"for",
"i",
"in",
"x",
"]",
")",
"el... | Convert input argument to bytes | [
"Convert",
"input",
"argument",
"to",
"bytes"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L41-L48 |
phaethon/kamene | kamene/utils.py | is_private_addr | def is_private_addr(x):
"""Returns True if the IPv4 Address is an RFC 1918 private address."""
paddrs = ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16']
found = False
for ipr in paddrs:
try:
if ipaddress.ip_address(x) in ipaddress.ip_network(ipr):
found = True
... | python | def is_private_addr(x):
"""Returns True if the IPv4 Address is an RFC 1918 private address."""
paddrs = ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16']
found = False
for ipr in paddrs:
try:
if ipaddress.ip_address(x) in ipaddress.ip_network(ipr):
found = True
... | [
"def",
"is_private_addr",
"(",
"x",
")",
":",
"paddrs",
"=",
"[",
"'10.0.0.0/8'",
",",
"'172.16.0.0/12'",
",",
"'192.168.0.0/16'",
"]",
"found",
"=",
"False",
"for",
"ipr",
"in",
"paddrs",
":",
"try",
":",
"if",
"ipaddress",
".",
"ip_address",
"(",
"x",
... | Returns True if the IPv4 Address is an RFC 1918 private address. | [
"Returns",
"True",
"if",
"the",
"IPv4",
"Address",
"is",
"an",
"RFC",
"1918",
"private",
"address",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L96-L107 |
phaethon/kamene | kamene/utils.py | do_graph | def do_graph(graph,prog=None,format='png',target=None,string=False,options=None, figsize = (12, 12), **kargs):
"""do_graph(graph, prog=conf.prog.dot, format="png",
target=None, options=None, string=False):
if networkx library is available and graph is instance of Graph, use networkx.draw
string: i... | python | def do_graph(graph,prog=None,format='png',target=None,string=False,options=None, figsize = (12, 12), **kargs):
"""do_graph(graph, prog=conf.prog.dot, format="png",
target=None, options=None, string=False):
if networkx library is available and graph is instance of Graph, use networkx.draw
string: i... | [
"def",
"do_graph",
"(",
"graph",
",",
"prog",
"=",
"None",
",",
"format",
"=",
"'png'",
",",
"target",
"=",
"None",
",",
"string",
"=",
"False",
",",
"options",
"=",
"None",
",",
"figsize",
"=",
"(",
"12",
",",
"12",
")",
",",
"*",
"*",
"kargs",
... | do_graph(graph, prog=conf.prog.dot, format="png",
target=None, options=None, string=False):
if networkx library is available and graph is instance of Graph, use networkx.draw
string: if not False, simply return the graph string
graph: GraphViz graph description
format: output type (svg, ps, gi... | [
"do_graph",
"(",
"graph",
"prog",
"=",
"conf",
".",
"prog",
".",
"dot",
"format",
"=",
"png",
"target",
"=",
"None",
"options",
"=",
"None",
"string",
"=",
"False",
")",
":",
"if",
"networkx",
"library",
"is",
"available",
"and",
"graph",
"is",
"instan... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L354-L399 |
phaethon/kamene | kamene/utils.py | colgen | def colgen(*lstcol,**kargs):
"""Returns a generator that mixes provided quantities forever
trans: a function to convert the three arguments into a color. lambda x,y,z:(x,y,z) by default"""
if len(lstcol) < 2:
lstcol *= 2
trans = kargs.get("trans", lambda x,y,z: (x,y,z))
while 1:
for ... | python | def colgen(*lstcol,**kargs):
"""Returns a generator that mixes provided quantities forever
trans: a function to convert the three arguments into a color. lambda x,y,z:(x,y,z) by default"""
if len(lstcol) < 2:
lstcol *= 2
trans = kargs.get("trans", lambda x,y,z: (x,y,z))
while 1:
for ... | [
"def",
"colgen",
"(",
"*",
"lstcol",
",",
"*",
"*",
"kargs",
")",
":",
"if",
"len",
"(",
"lstcol",
")",
"<",
"2",
":",
"lstcol",
"*=",
"2",
"trans",
"=",
"kargs",
".",
"get",
"(",
"\"trans\"",
",",
"lambda",
"x",
",",
"y",
",",
"z",
":",
"(",... | Returns a generator that mixes provided quantities forever
trans: a function to convert the three arguments into a color. lambda x,y,z:(x,y,z) by default | [
"Returns",
"a",
"generator",
"that",
"mixes",
"provided",
"quantities",
"forever",
"trans",
":",
"a",
"function",
"to",
"convert",
"the",
"three",
"arguments",
"into",
"a",
"color",
".",
"lambda",
"x",
"y",
"z",
":",
"(",
"x",
"y",
"z",
")",
"by",
"def... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L424-L435 |
phaethon/kamene | kamene/utils.py | corrupt_bytes | def corrupt_bytes(s, p=0.01, n=None):
"""Corrupt a given percentage or number of bytes from bytes"""
s = bytes(s)
s = array.array("B",s)
l = len(s)
if n is None:
n = max(1,int(l*p))
for i in random.sample(range(l), n):
s[i] = (s[i]+random.randint(1,255))%256
return s.tobytes(... | python | def corrupt_bytes(s, p=0.01, n=None):
"""Corrupt a given percentage or number of bytes from bytes"""
s = bytes(s)
s = array.array("B",s)
l = len(s)
if n is None:
n = max(1,int(l*p))
for i in random.sample(range(l), n):
s[i] = (s[i]+random.randint(1,255))%256
return s.tobytes(... | [
"def",
"corrupt_bytes",
"(",
"s",
",",
"p",
"=",
"0.01",
",",
"n",
"=",
"None",
")",
":",
"s",
"=",
"bytes",
"(",
"s",
")",
"s",
"=",
"array",
".",
"array",
"(",
"\"B\"",
",",
"s",
")",
"l",
"=",
"len",
"(",
"s",
")",
"if",
"n",
"is",
"No... | Corrupt a given percentage or number of bytes from bytes | [
"Corrupt",
"a",
"given",
"percentage",
"or",
"number",
"of",
"bytes",
"from",
"bytes"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L516-L525 |
phaethon/kamene | kamene/utils.py | wrpcap | def wrpcap(filename, pkt, *args, **kargs):
"""Write a list of packets to a pcap file
gz: set to 1 to save a gzipped capture
linktype: force linktype value
endianness: "<" or ">", force endianness"""
with PcapWriter(filename, *args, **kargs) as pcap:
pcap.write(pkt) | python | def wrpcap(filename, pkt, *args, **kargs):
"""Write a list of packets to a pcap file
gz: set to 1 to save a gzipped capture
linktype: force linktype value
endianness: "<" or ">", force endianness"""
with PcapWriter(filename, *args, **kargs) as pcap:
pcap.write(pkt) | [
"def",
"wrpcap",
"(",
"filename",
",",
"pkt",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"with",
"PcapWriter",
"(",
"filename",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
"as",
"pcap",
":",
"pcap",
".",
"write",
"(",
"pkt",
")"
] | Write a list of packets to a pcap file
gz: set to 1 to save a gzipped capture
linktype: force linktype value
endianness: "<" or ">", force endianness | [
"Write",
"a",
"list",
"of",
"packets",
"to",
"a",
"pcap",
"file",
"gz",
":",
"set",
"to",
"1",
"to",
"save",
"a",
"gzipped",
"capture",
"linktype",
":",
"force",
"linktype",
"value",
"endianness",
":",
"<",
"or",
">",
"force",
"endianness"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L545-L551 |
phaethon/kamene | kamene/utils.py | rdpcap | def rdpcap(filename, count=-1):
"""Read a pcap file and return a packet list
count: read only <count> packets"""
with PcapReader(filename) as pcap:
return pcap.read_all(count=count) | python | def rdpcap(filename, count=-1):
"""Read a pcap file and return a packet list
count: read only <count> packets"""
with PcapReader(filename) as pcap:
return pcap.read_all(count=count) | [
"def",
"rdpcap",
"(",
"filename",
",",
"count",
"=",
"-",
"1",
")",
":",
"with",
"PcapReader",
"(",
"filename",
")",
"as",
"pcap",
":",
"return",
"pcap",
".",
"read_all",
"(",
"count",
"=",
"count",
")"
] | Read a pcap file and return a packet list
count: read only <count> packets | [
"Read",
"a",
"pcap",
"file",
"and",
"return",
"a",
"packet",
"list",
"count",
":",
"read",
"only",
"<count",
">",
"packets"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L554-L558 |
phaethon/kamene | kamene/utils.py | wireshark | def wireshark(pktlist, *args):
"""Run wireshark on a list of packets"""
fname = get_temp_file()
wrpcap(fname, pktlist)
subprocess.Popen([conf.prog.wireshark, "-r", fname] + list(args)) | python | def wireshark(pktlist, *args):
"""Run wireshark on a list of packets"""
fname = get_temp_file()
wrpcap(fname, pktlist)
subprocess.Popen([conf.prog.wireshark, "-r", fname] + list(args)) | [
"def",
"wireshark",
"(",
"pktlist",
",",
"*",
"args",
")",
":",
"fname",
"=",
"get_temp_file",
"(",
")",
"wrpcap",
"(",
"fname",
",",
"pktlist",
")",
"subprocess",
".",
"Popen",
"(",
"[",
"conf",
".",
"prog",
".",
"wireshark",
",",
"\"-r\"",
",",
"fn... | Run wireshark on a list of packets | [
"Run",
"wireshark",
"on",
"a",
"list",
"of",
"packets"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L1003-L1007 |
phaethon/kamene | kamene/utils.py | tdecode | def tdecode(pkt, *args):
"""Run tshark to decode and display the packet. If no args defined uses -V"""
if not args:
args = [ "-V" ]
fname = get_temp_file()
wrpcap(fname,[pkt])
subprocess.call(["tshark", "-r", fname] + list(args)) | python | def tdecode(pkt, *args):
"""Run tshark to decode and display the packet. If no args defined uses -V"""
if not args:
args = [ "-V" ]
fname = get_temp_file()
wrpcap(fname,[pkt])
subprocess.call(["tshark", "-r", fname] + list(args)) | [
"def",
"tdecode",
"(",
"pkt",
",",
"*",
"args",
")",
":",
"if",
"not",
"args",
":",
"args",
"=",
"[",
"\"-V\"",
"]",
"fname",
"=",
"get_temp_file",
"(",
")",
"wrpcap",
"(",
"fname",
",",
"[",
"pkt",
"]",
")",
"subprocess",
".",
"call",
"(",
"[",
... | Run tshark to decode and display the packet. If no args defined uses -V | [
"Run",
"tshark",
"to",
"decode",
"and",
"display",
"the",
"packet",
".",
"If",
"no",
"args",
"defined",
"uses",
"-",
"V"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L1010-L1016 |
phaethon/kamene | kamene/utils.py | hexedit | def hexedit(x):
"""Run external hex editor on a packet or bytes. Set editor in conf.prog.hexedit"""
x = bytes(x)
fname = get_temp_file()
with open(fname,"wb") as f:
f.write(x)
subprocess.call([conf.prog.hexedit, fname])
with open(fname, "rb") as f:
x = f.read()
return x | python | def hexedit(x):
"""Run external hex editor on a packet or bytes. Set editor in conf.prog.hexedit"""
x = bytes(x)
fname = get_temp_file()
with open(fname,"wb") as f:
f.write(x)
subprocess.call([conf.prog.hexedit, fname])
with open(fname, "rb") as f:
x = f.read()
return x | [
"def",
"hexedit",
"(",
"x",
")",
":",
"x",
"=",
"bytes",
"(",
"x",
")",
"fname",
"=",
"get_temp_file",
"(",
")",
"with",
"open",
"(",
"fname",
",",
"\"wb\"",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"x",
")",
"subprocess",
".",
"call",
"(",... | Run external hex editor on a packet or bytes. Set editor in conf.prog.hexedit | [
"Run",
"external",
"hex",
"editor",
"on",
"a",
"packet",
"or",
"bytes",
".",
"Set",
"editor",
"in",
"conf",
".",
"prog",
".",
"hexedit"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L1019-L1028 |
phaethon/kamene | kamene/utils.py | _RawPcapOldReader.read_packet | def read_packet(self, size=MTU):
"""return a single packet read from the file
bytes, (sec, #timestamp seconds
usec, #timestamp microseconds
wirelen) #actual length of packet
returns None when no more packets are available
"""
hdr = self.f.read(16)
... | python | def read_packet(self, size=MTU):
"""return a single packet read from the file
bytes, (sec, #timestamp seconds
usec, #timestamp microseconds
wirelen) #actual length of packet
returns None when no more packets are available
"""
hdr = self.f.read(16)
... | [
"def",
"read_packet",
"(",
"self",
",",
"size",
"=",
"MTU",
")",
":",
"hdr",
"=",
"self",
".",
"f",
".",
"read",
"(",
"16",
")",
"if",
"len",
"(",
"hdr",
")",
"<",
"16",
":",
"return",
"None",
"sec",
",",
"usec",
",",
"caplen",
",",
"wirelen",
... | return a single packet read from the file
bytes, (sec, #timestamp seconds
usec, #timestamp microseconds
wirelen) #actual length of packet
returns None when no more packets are available | [
"return",
"a",
"single",
"packet",
"read",
"from",
"the",
"file",
"bytes",
"(",
"sec",
"#timestamp",
"seconds",
"usec",
"#timestamp",
"microseconds",
"wirelen",
")",
"#actual",
"length",
"of",
"packet",
"returns",
"None",
"when",
"no",
"more",
"packets",
"are"... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L793-L805 |
phaethon/kamene | kamene/utils.py | RawPcapWriter.write | def write(self, pkt):
"""accepts a either a single packet or a list of packets
to be written to the dumpfile
"""
if not self.header_present:
self._write_header(pkt)
if type(pkt) is bytes:
self._write_packet(pkt)
else:
for p in pkt:
... | python | def write(self, pkt):
"""accepts a either a single packet or a list of packets
to be written to the dumpfile
"""
if not self.header_present:
self._write_header(pkt)
if type(pkt) is bytes:
self._write_packet(pkt)
else:
for p in pkt:
... | [
"def",
"write",
"(",
"self",
",",
"pkt",
")",
":",
"if",
"not",
"self",
".",
"header_present",
":",
"self",
".",
"_write_header",
"(",
"pkt",
")",
"if",
"type",
"(",
"pkt",
")",
"is",
"bytes",
":",
"self",
".",
"_write_packet",
"(",
"pkt",
")",
"el... | accepts a either a single packet or a list of packets
to be written to the dumpfile | [
"accepts",
"a",
"either",
"a",
"single",
"packet",
"or",
"a",
"list",
"of",
"packets",
"to",
"be",
"written",
"to",
"the",
"dumpfile"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L893-L903 |
phaethon/kamene | kamene/utils.py | RawPcapWriter._write_packet | def _write_packet(self, packet, sec=None, usec=None, caplen=None, wirelen=None):
"""writes a single packet to the pcap file
"""
if caplen is None:
caplen = len(packet)
if wirelen is None:
wirelen = caplen
if sec is None or usec is None:
t=time.... | python | def _write_packet(self, packet, sec=None, usec=None, caplen=None, wirelen=None):
"""writes a single packet to the pcap file
"""
if caplen is None:
caplen = len(packet)
if wirelen is None:
wirelen = caplen
if sec is None or usec is None:
t=time.... | [
"def",
"_write_packet",
"(",
"self",
",",
"packet",
",",
"sec",
"=",
"None",
",",
"usec",
"=",
"None",
",",
"caplen",
"=",
"None",
",",
"wirelen",
"=",
"None",
")",
":",
"if",
"caplen",
"is",
"None",
":",
"caplen",
"=",
"len",
"(",
"packet",
")",
... | writes a single packet to the pcap file | [
"writes",
"a",
"single",
"packet",
"to",
"the",
"pcap",
"file"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L905-L922 |
phaethon/kamene | kamene/utils.py | PcapWriter.get_packet_time | def get_packet_time(self, pkt):
"""Return the second and micro-second timestamp components for a packet."""
if pkt.sent_time:
t = pkt.sent_time
sec = int(t)
else:
t = pkt.time
sec = int(t)
usec = int(round((t-sec)*1000000))
return (sec,usec... | python | def get_packet_time(self, pkt):
"""Return the second and micro-second timestamp components for a packet."""
if pkt.sent_time:
t = pkt.sent_time
sec = int(t)
else:
t = pkt.time
sec = int(t)
usec = int(round((t-sec)*1000000))
return (sec,usec... | [
"def",
"get_packet_time",
"(",
"self",
",",
"pkt",
")",
":",
"if",
"pkt",
".",
"sent_time",
":",
"t",
"=",
"pkt",
".",
"sent_time",
"sec",
"=",
"int",
"(",
"t",
")",
"else",
":",
"t",
"=",
"pkt",
".",
"time",
"sec",
"=",
"int",
"(",
"t",
")",
... | Return the second and micro-second timestamp components for a packet. | [
"Return",
"the",
"second",
"and",
"micro",
"-",
"second",
"timestamp",
"components",
"for",
"a",
"packet",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L949-L958 |
phaethon/kamene | kamene/utils.py | PcapWriter.write | def write(self, pkt):
"""accepts a either a single packet or a list of packets
to be written to the dumpfile
"""
if not self.header_present:
self._write_header(pkt)
if isinstance(pkt, BasePacket):
self._write_packet(pkt)
else:
for p in pk... | python | def write(self, pkt):
"""accepts a either a single packet or a list of packets
to be written to the dumpfile
"""
if not self.header_present:
self._write_header(pkt)
if isinstance(pkt, BasePacket):
self._write_packet(pkt)
else:
for p in pk... | [
"def",
"write",
"(",
"self",
",",
"pkt",
")",
":",
"if",
"not",
"self",
".",
"header_present",
":",
"self",
".",
"_write_header",
"(",
"pkt",
")",
"if",
"isinstance",
"(",
"pkt",
",",
"BasePacket",
")",
":",
"self",
".",
"_write_packet",
"(",
"pkt",
... | accepts a either a single packet or a list of packets
to be written to the dumpfile | [
"accepts",
"a",
"either",
"a",
"single",
"packet",
"or",
"a",
"list",
"of",
"packets",
"to",
"be",
"written",
"to",
"the",
"dumpfile"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L969-L979 |
phaethon/kamene | kamene/layers/uds.py | ISO14229.hashret | def hashret(self):
"""DEV: returns a string that has the same value for a request and its answer."""
if 'PositiveResponse' in self.services[self.service]:
return struct.pack('B', self.service - 0x40)
elif self.service == 0x7f:
return struct.pack('B', self.requestServiceId... | python | def hashret(self):
"""DEV: returns a string that has the same value for a request and its answer."""
if 'PositiveResponse' in self.services[self.service]:
return struct.pack('B', self.service - 0x40)
elif self.service == 0x7f:
return struct.pack('B', self.requestServiceId... | [
"def",
"hashret",
"(",
"self",
")",
":",
"if",
"'PositiveResponse'",
"in",
"self",
".",
"services",
"[",
"self",
".",
"service",
"]",
":",
"return",
"struct",
".",
"pack",
"(",
"'B'",
",",
"self",
".",
"service",
"-",
"0x40",
")",
"elif",
"self",
"."... | DEV: returns a string that has the same value for a request and its answer. | [
"DEV",
":",
"returns",
"a",
"string",
"that",
"has",
"the",
"same",
"value",
"for",
"a",
"request",
"and",
"its",
"answer",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/uds.py#L141-L148 |
phaethon/kamene | kamene/contrib/eigrp.py | ShortVersionField.h2i | def h2i(self, pkt, x):
"""The field accepts string values like v12.1, v1.1 or integer values.
String values have to start with a "v" folled by a floating point number.
Valid numbers are between 0 and 255.
"""
if type(x) is str and x.startswith("v") and len(x) <= 8:
... | python | def h2i(self, pkt, x):
"""The field accepts string values like v12.1, v1.1 or integer values.
String values have to start with a "v" folled by a floating point number.
Valid numbers are between 0 and 255.
"""
if type(x) is str and x.startswith("v") and len(x) <= 8:
... | [
"def",
"h2i",
"(",
"self",
",",
"pkt",
",",
"x",
")",
":",
"if",
"type",
"(",
"x",
")",
"is",
"str",
"and",
"x",
".",
"startswith",
"(",
"\"v\"",
")",
"and",
"len",
"(",
"x",
")",
"<=",
"8",
":",
"major",
"=",
"int",
"(",
"x",
".",
"split",... | The field accepts string values like v12.1, v1.1 or integer values.
String values have to start with a "v" folled by a floating point number.
Valid numbers are between 0 and 255. | [
"The",
"field",
"accepts",
"string",
"values",
"like",
"v12",
".",
"1",
"v1",
".",
"1",
"or",
"integer",
"values",
".",
"String",
"values",
"have",
"to",
"start",
"with",
"a",
"v",
"folled",
"by",
"a",
"floating",
"point",
"number",
".",
"Valid",
"numb... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/eigrp.py#L254-L273 |
phaethon/kamene | kamene/layers/bluetooth.py | srbt | def srbt(peer, pkts, inter=0.1, *args, **kargs):
"""send and receive using a bluetooth socket"""
s = conf.BTsocket(peer=peer)
a,b = sndrcv(s,pkts,inter=inter,*args,**kargs)
s.close()
return a,b | python | def srbt(peer, pkts, inter=0.1, *args, **kargs):
"""send and receive using a bluetooth socket"""
s = conf.BTsocket(peer=peer)
a,b = sndrcv(s,pkts,inter=inter,*args,**kargs)
s.close()
return a,b | [
"def",
"srbt",
"(",
"peer",
",",
"pkts",
",",
"inter",
"=",
"0.1",
",",
"*",
"args",
",",
"*",
"*",
"kargs",
")",
":",
"s",
"=",
"conf",
".",
"BTsocket",
"(",
"peer",
"=",
"peer",
")",
"a",
",",
"b",
"=",
"sndrcv",
"(",
"s",
",",
"pkts",
",... | send and receive using a bluetooth socket | [
"send",
"and",
"receive",
"using",
"a",
"bluetooth",
"socket"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/bluetooth.py#L197-L202 |
phaethon/kamene | kamene/arch/__init__.py | get_if_raw_addr6 | def get_if_raw_addr6(iff):
"""
Returns the main global unicast address associated with provided
interface, in network format. If no global address is found, None
is returned.
"""
#r = filter(lambda x: x[2] == iff and x[1] == IPV6_ADDR_GLOBAL, in6_getifaddr())
r = [ x for x in in6_getifadd... | python | def get_if_raw_addr6(iff):
"""
Returns the main global unicast address associated with provided
interface, in network format. If no global address is found, None
is returned.
"""
#r = filter(lambda x: x[2] == iff and x[1] == IPV6_ADDR_GLOBAL, in6_getifaddr())
r = [ x for x in in6_getifadd... | [
"def",
"get_if_raw_addr6",
"(",
"iff",
")",
":",
"#r = filter(lambda x: x[2] == iff and x[1] == IPV6_ADDR_GLOBAL, in6_getifaddr())",
"r",
"=",
"[",
"x",
"for",
"x",
"in",
"in6_getifaddr",
"(",
")",
"if",
"x",
"[",
"2",
"]",
"==",
"iff",
"and",
"x",
"[",
"1",
"... | Returns the main global unicast address associated with provided
interface, in network format. If no global address is found, None
is returned. | [
"Returns",
"the",
"main",
"global",
"unicast",
"address",
"associated",
"with",
"provided",
"interface",
"in",
"network",
"format",
".",
"If",
"no",
"global",
"address",
"is",
"found",
"None",
"is",
"returned",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/__init__.py#L100-L112 |
phaethon/kamene | kamene/layers/ipsec.py | zero_mutable_fields | def zero_mutable_fields(pkt, sending=False):
"""
When using AH, all "mutable" fields must be "zeroed" before calculating
the ICV. See RFC 4302, Section 3.3.3.1. Handling Mutable Fields.
@param pkt: an IP(v6) packet containing an AH layer.
NOTE: The packet will be modified
@param sen... | python | def zero_mutable_fields(pkt, sending=False):
"""
When using AH, all "mutable" fields must be "zeroed" before calculating
the ICV. See RFC 4302, Section 3.3.3.1. Handling Mutable Fields.
@param pkt: an IP(v6) packet containing an AH layer.
NOTE: The packet will be modified
@param sen... | [
"def",
"zero_mutable_fields",
"(",
"pkt",
",",
"sending",
"=",
"False",
")",
":",
"if",
"pkt",
".",
"haslayer",
"(",
"AH",
")",
":",
"pkt",
"[",
"AH",
"]",
".",
"icv",
"=",
"chr",
"(",
"0",
")",
"*",
"len",
"(",
"pkt",
"[",
"AH",
"]",
".",
"i... | When using AH, all "mutable" fields must be "zeroed" before calculating
the ICV. See RFC 4302, Section 3.3.3.1. Handling Mutable Fields.
@param pkt: an IP(v6) packet containing an AH layer.
NOTE: The packet will be modified
@param sending: if true, ipv6 routing headers will not be reordered | [
"When",
"using",
"AH",
"all",
"mutable",
"fields",
"must",
"be",
"zeroed",
"before",
"calculating",
"the",
"ICV",
".",
"See",
"RFC",
"4302",
"Section",
"3",
".",
"3",
".",
"3",
".",
"1",
".",
"Handling",
"Mutable",
"Fields",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/ipsec.py#L655-L722 |
phaethon/kamene | kamene/layers/ipsec.py | CryptAlgo.new_cipher | def new_cipher(self, key, iv, digest=None):
"""
@param key: the secret key, a byte string
@param iv: the initialization vector, a byte string. Used as the
initial nonce in counter mode
@param digest: also known as tag or icv. A byte string containing the
... | python | def new_cipher(self, key, iv, digest=None):
"""
@param key: the secret key, a byte string
@param iv: the initialization vector, a byte string. Used as the
initial nonce in counter mode
@param digest: also known as tag or icv. A byte string containing the
... | [
"def",
"new_cipher",
"(",
"self",
",",
"key",
",",
"iv",
",",
"digest",
"=",
"None",
")",
":",
"if",
"type",
"(",
"key",
")",
"is",
"str",
":",
"key",
"=",
"key",
".",
"encode",
"(",
"'ascii'",
")",
"if",
"self",
".",
"is_aead",
"and",
"digest",
... | @param key: the secret key, a byte string
@param iv: the initialization vector, a byte string. Used as the
initial nonce in counter mode
@param digest: also known as tag or icv. A byte string containing the
digest of the encrypted data. Only use this ... | [
"@param",
"key",
":",
"the",
"secret",
"key",
"a",
"byte",
"string",
"@param",
"iv",
":",
"the",
"initialization",
"vector",
"a",
"byte",
"string",
".",
"Used",
"as",
"the",
"initial",
"nonce",
"in",
"counter",
"mode",
"@param",
"digest",
":",
"also",
"k... | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/ipsec.py#L250-L275 |
phaethon/kamene | kamene/layers/ipsec.py | CryptAlgo.pad | def pad(self, esp):
"""
Add the correct amount of padding so that the data to encrypt is
exactly a multiple of the algorithm's block size.
Also, make sure that the total ESP packet length is a multiple of 4
bytes.
@param esp: an unencrypted _ESPPlain packet
... | python | def pad(self, esp):
"""
Add the correct amount of padding so that the data to encrypt is
exactly a multiple of the algorithm's block size.
Also, make sure that the total ESP packet length is a multiple of 4
bytes.
@param esp: an unencrypted _ESPPlain packet
... | [
"def",
"pad",
"(",
"self",
",",
"esp",
")",
":",
"# 2 extra bytes for padlen and nh",
"data_len",
"=",
"len",
"(",
"esp",
".",
"data",
")",
"+",
"2",
"# according to the RFC4303, section 2.4. Padding (for Encryption)",
"# the size of the ESP payload must be a multiple of 32 b... | Add the correct amount of padding so that the data to encrypt is
exactly a multiple of the algorithm's block size.
Also, make sure that the total ESP packet length is a multiple of 4
bytes.
@param esp: an unencrypted _ESPPlain packet
@return: an unencrypted _ESPPlain pac... | [
"Add",
"the",
"correct",
"amount",
"of",
"padding",
"so",
"that",
"the",
"data",
"to",
"encrypt",
"is",
"exactly",
"a",
"multiple",
"of",
"the",
"algorithm",
"s",
"block",
"size",
"."
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/ipsec.py#L278-L311 |
phaethon/kamene | kamene/layers/ipsec.py | CryptAlgo.decrypt | def decrypt(self, esp, key, icv_size=None):
"""
Decrypt an ESP packet
@param esp: an encrypted ESP packet
@param key: the secret key used for encryption
@param icv_size: the length of the icv used for integrity check
@return: a valid ESP packet encryp... | python | def decrypt(self, esp, key, icv_size=None):
"""
Decrypt an ESP packet
@param esp: an encrypted ESP packet
@param key: the secret key used for encryption
@param icv_size: the length of the icv used for integrity check
@return: a valid ESP packet encryp... | [
"def",
"decrypt",
"(",
"self",
",",
"esp",
",",
"key",
",",
"icv_size",
"=",
"None",
")",
":",
"if",
"icv_size",
"is",
"None",
":",
"icv_size",
"=",
"self",
".",
"icv_size",
"if",
"self",
".",
"is_aead",
"else",
"0",
"iv",
"=",
"esp",
".",
"data",
... | Decrypt an ESP packet
@param esp: an encrypted ESP packet
@param key: the secret key used for encryption
@param icv_size: the length of the icv used for integrity check
@return: a valid ESP packet encrypted with this algorithm
@raise IPSecIntegrityError: if t... | [
"Decrypt",
"an",
"ESP",
"packet"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/ipsec.py#L338-L387 |
phaethon/kamene | kamene/contrib/igmp.py | IGMP.igmpize | def igmpize(self, ip=None, ether=None):
"""Called to explicitely fixup associated IP and Ethernet headers
Parameters:
self The instantiation of an IGMP class.
ip The instantiation of the associated IP class.
ether The instantiation of the associated Ethernet.
Returns:
Tru... | python | def igmpize(self, ip=None, ether=None):
"""Called to explicitely fixup associated IP and Ethernet headers
Parameters:
self The instantiation of an IGMP class.
ip The instantiation of the associated IP class.
ether The instantiation of the associated Ethernet.
Returns:
Tru... | [
"def",
"igmpize",
"(",
"self",
",",
"ip",
"=",
"None",
",",
"ether",
"=",
"None",
")",
":",
"# The rules are:",
"# 1. the Max Response time is meaningful only in Membership Queries and should be zero ",
"# otherwise (RFC 2236, section 2.2)",
"if",
"(",
"self",
".",
... | Called to explicitely fixup associated IP and Ethernet headers
Parameters:
self The instantiation of an IGMP class.
ip The instantiation of the associated IP class.
ether The instantiation of the associated Ethernet.
Returns:
True The tuple ether/ip/self passed all check a... | [
"Called",
"to",
"explicitely",
"fixup",
"associated",
"IP",
"and",
"Ethernet",
"headers"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/igmp.py#L78-L107 |
phaethon/kamene | kamene/contrib/gsm_um.py | additionalAssignment | def additionalAssignment(MobileAllocation_presence=0,
StartingTime_presence=0):
"""ADDITIONAL ASSIGNMENT Section 9.1.1"""
# Mandatory
a = TpPd(pd=0x6)
b = MessageType(mesType=0x3B) # 00111011
c = ChannelDescription()
packet = a / b / c
# Not Mandatory
if MobileA... | python | def additionalAssignment(MobileAllocation_presence=0,
StartingTime_presence=0):
"""ADDITIONAL ASSIGNMENT Section 9.1.1"""
# Mandatory
a = TpPd(pd=0x6)
b = MessageType(mesType=0x3B) # 00111011
c = ChannelDescription()
packet = a / b / c
# Not Mandatory
if MobileA... | [
"def",
"additionalAssignment",
"(",
"MobileAllocation_presence",
"=",
"0",
",",
"StartingTime_presence",
"=",
"0",
")",
":",
"# Mandatory",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x3B",
")",
"# 00111011",... | ADDITIONAL ASSIGNMENT Section 9.1.1 | [
"ADDITIONAL",
"ASSIGNMENT",
"Section",
"9",
".",
"1",
".",
"1"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L180-L195 |
phaethon/kamene | kamene/contrib/gsm_um.py | assignmentCommand | def assignmentCommand(FrequencyList_presence=0,
CellChannelDescription_presence=0,
CellChannelDescription_presence1=0,
MultislotAllocation_presence=0,
ChannelMode_presence=0, ChannelMode_presence1=0,
ChannelMod... | python | def assignmentCommand(FrequencyList_presence=0,
CellChannelDescription_presence=0,
CellChannelDescription_presence1=0,
MultislotAllocation_presence=0,
ChannelMode_presence=0, ChannelMode_presence1=0,
ChannelMod... | [
"def",
"assignmentCommand",
"(",
"FrequencyList_presence",
"=",
"0",
",",
"CellChannelDescription_presence",
"=",
"0",
",",
"CellChannelDescription_presence1",
"=",
"0",
",",
"MultislotAllocation_presence",
"=",
"0",
",",
"ChannelMode_presence",
"=",
"0",
",",
"ChannelM... | ASSIGNMENT COMMAND Section 9.1.2 | [
"ASSIGNMENT",
"COMMAND",
"Section",
"9",
".",
"1",
".",
"2"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L199-L292 |
phaethon/kamene | kamene/contrib/gsm_um.py | assignmentComplete | def assignmentComplete():
"""ASSIGNMENT COMPLETE Section 9.1.3"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x29) # 00101001
c = RrCause()
packet = a / b / c
return packet | python | def assignmentComplete():
"""ASSIGNMENT COMPLETE Section 9.1.3"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x29) # 00101001
c = RrCause()
packet = a / b / c
return packet | [
"def",
"assignmentComplete",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x29",
")",
"# 00101001",
"c",
"=",
"RrCause",
"(",
")",
"packet",
"=",
"a",
"/",
"b",
"/",
"c",
"return",
"p... | ASSIGNMENT COMPLETE Section 9.1.3 | [
"ASSIGNMENT",
"COMPLETE",
"Section",
"9",
".",
"1",
".",
"3"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L296-L302 |
phaethon/kamene | kamene/contrib/gsm_um.py | channelModeModify | def channelModeModify(VgcsTargetModeIdentication_presence=0,
MultiRateConfiguration_presence=0):
"""CHANNEL MODE MODIFY Section 9.1.5"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x8) # 0001000
c = ChannelDescription2()
d = ChannelMode()
packet = a / b / c / d
if VgcsTa... | python | def channelModeModify(VgcsTargetModeIdentication_presence=0,
MultiRateConfiguration_presence=0):
"""CHANNEL MODE MODIFY Section 9.1.5"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x8) # 0001000
c = ChannelDescription2()
d = ChannelMode()
packet = a / b / c / d
if VgcsTa... | [
"def",
"channelModeModify",
"(",
"VgcsTargetModeIdentication_presence",
"=",
"0",
",",
"MultiRateConfiguration_presence",
"=",
"0",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x8",
")",
"# 0001000",
... | CHANNEL MODE MODIFY Section 9.1.5 | [
"CHANNEL",
"MODE",
"MODIFY",
"Section",
"9",
".",
"1",
".",
"5"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L316-L330 |
phaethon/kamene | kamene/contrib/gsm_um.py | channelModeModifyAcknowledge | def channelModeModifyAcknowledge():
"""CHANNEL MODE MODIFY ACKNOWLEDGE Section 9.1.6"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x17) # 00010111
c = ChannelDescription2()
d = ChannelMode()
packet = a / b / c / d
return packet | python | def channelModeModifyAcknowledge():
"""CHANNEL MODE MODIFY ACKNOWLEDGE Section 9.1.6"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x17) # 00010111
c = ChannelDescription2()
d = ChannelMode()
packet = a / b / c / d
return packet | [
"def",
"channelModeModifyAcknowledge",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x17",
")",
"# 00010111",
"c",
"=",
"ChannelDescription2",
"(",
")",
"d",
"=",
"ChannelMode",
"(",
")",
"... | CHANNEL MODE MODIFY ACKNOWLEDGE Section 9.1.6 | [
"CHANNEL",
"MODE",
"MODIFY",
"ACKNOWLEDGE",
"Section",
"9",
".",
"1",
".",
"6"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L333-L340 |
phaethon/kamene | kamene/contrib/gsm_um.py | channelRelease | def channelRelease(BaRange_presence=0, GroupChannelDescription_presence=0,
GroupCipherKeyNumber_presence=0, GprsResumption_presence=0,
BaListPref_presence=0):
"""CHANNEL RELEASE Section 9.1.7"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0xD) # 00001101
c = RrCause(... | python | def channelRelease(BaRange_presence=0, GroupChannelDescription_presence=0,
GroupCipherKeyNumber_presence=0, GprsResumption_presence=0,
BaListPref_presence=0):
"""CHANNEL RELEASE Section 9.1.7"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0xD) # 00001101
c = RrCause(... | [
"def",
"channelRelease",
"(",
"BaRange_presence",
"=",
"0",
",",
"GroupChannelDescription_presence",
"=",
"0",
",",
"GroupCipherKeyNumber_presence",
"=",
"0",
",",
"GprsResumption_presence",
"=",
"0",
",",
"BaListPref_presence",
"=",
"0",
")",
":",
"a",
"=",
"TpPd... | CHANNEL RELEASE Section 9.1.7 | [
"CHANNEL",
"RELEASE",
"Section",
"9",
".",
"1",
".",
"7"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L344-L367 |
phaethon/kamene | kamene/contrib/gsm_um.py | cipheringModeCommand | def cipheringModeCommand():
"""CIPHERING MODE COMMAND Section 9.1.9"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x35) # 00110101
c = RrCause()
#d=cipherModeSetting()
#e=cipherResponse()
# FIX
d = CipherModeSettingAndcipherResponse()
packet = a / b / c / d
return packet | python | def cipheringModeCommand():
"""CIPHERING MODE COMMAND Section 9.1.9"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x35) # 00110101
c = RrCause()
#d=cipherModeSetting()
#e=cipherResponse()
# FIX
d = CipherModeSettingAndcipherResponse()
packet = a / b / c / d
return packet | [
"def",
"cipheringModeCommand",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x35",
")",
"# 00110101",
"c",
"=",
"RrCause",
"(",
")",
"#d=cipherModeSetting()",
"#e=cipherResponse()",
"# FIX",
"d... | CIPHERING MODE COMMAND Section 9.1.9 | [
"CIPHERING",
"MODE",
"COMMAND",
"Section",
"9",
".",
"1",
".",
"9"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L383-L393 |
phaethon/kamene | kamene/contrib/gsm_um.py | cipheringModeComplete | def cipheringModeComplete(MobileId_presence=0):
"""CIPHERING MODE COMPLETE Section 9.1.10"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x32) # 00110010
packet = a / b
if MobileId_presence is 1:
c = MobileIdHdr(ieiMI=0x17, eightBitMI=0x0)
packet = packet / c
return packet | python | def cipheringModeComplete(MobileId_presence=0):
"""CIPHERING MODE COMPLETE Section 9.1.10"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x32) # 00110010
packet = a / b
if MobileId_presence is 1:
c = MobileIdHdr(ieiMI=0x17, eightBitMI=0x0)
packet = packet / c
return packet | [
"def",
"cipheringModeComplete",
"(",
"MobileId_presence",
"=",
"0",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x32",
")",
"# 00110010",
"packet",
"=",
"a",
"/",
"b",
"if",
"MobileId_presence",
... | CIPHERING MODE COMPLETE Section 9.1.10 | [
"CIPHERING",
"MODE",
"COMPLETE",
"Section",
"9",
".",
"1",
".",
"10"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L396-L404 |
phaethon/kamene | kamene/contrib/gsm_um.py | classmarkChange | def classmarkChange(MobileStationClassmark3_presence=0):
"""CLASSMARK CHANGE Section 9.1.11"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x16) # 00010110
c = MobileStationClassmark2()
packet = a / b / c
if MobileStationClassmark3_presence is 1:
e = MobileStationClassmark3(ieiMSC3=0x20)
... | python | def classmarkChange(MobileStationClassmark3_presence=0):
"""CLASSMARK CHANGE Section 9.1.11"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x16) # 00010110
c = MobileStationClassmark2()
packet = a / b / c
if MobileStationClassmark3_presence is 1:
e = MobileStationClassmark3(ieiMSC3=0x20)
... | [
"def",
"classmarkChange",
"(",
"MobileStationClassmark3_presence",
"=",
"0",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x16",
")",
"# 00010110",
"c",
"=",
"MobileStationClassmark2",
"(",
")",
"pa... | CLASSMARK CHANGE Section 9.1.11 | [
"CLASSMARK",
"CHANGE",
"Section",
"9",
".",
"1",
".",
"11"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L408-L417 |
phaethon/kamene | kamene/contrib/gsm_um.py | classmarkEnquiry | def classmarkEnquiry():
"""CLASSMARK ENQUIRY Section 9.1.12"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x13) # 00010011
packet = a / b
return packet | python | def classmarkEnquiry():
"""CLASSMARK ENQUIRY Section 9.1.12"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x13) # 00010011
packet = a / b
return packet | [
"def",
"classmarkEnquiry",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x13",
")",
"# 00010011",
"packet",
"=",
"a",
"/",
"b",
"return",
"packet"
] | CLASSMARK ENQUIRY Section 9.1.12 | [
"CLASSMARK",
"ENQUIRY",
"Section",
"9",
".",
"1",
".",
"12"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L421-L426 |
phaethon/kamene | kamene/contrib/gsm_um.py | configurationChangeCommand | def configurationChangeCommand(ChannelMode_presence=0,
ChannelMode_presence1=0,
ChannelMode_presence2=0,
ChannelMode_presence3=0,
ChannelMode_presence4=0,
ChannelMod... | python | def configurationChangeCommand(ChannelMode_presence=0,
ChannelMode_presence1=0,
ChannelMode_presence2=0,
ChannelMode_presence3=0,
ChannelMode_presence4=0,
ChannelMod... | [
"def",
"configurationChangeCommand",
"(",
"ChannelMode_presence",
"=",
"0",
",",
"ChannelMode_presence1",
"=",
"0",
",",
"ChannelMode_presence2",
"=",
"0",
",",
"ChannelMode_presence3",
"=",
"0",
",",
"ChannelMode_presence4",
"=",
"0",
",",
"ChannelMode_presence5",
"=... | CONFIGURATION CHANGE COMMAND Section 9.1.12b | [
"CONFIGURATION",
"CHANGE",
"COMMAND",
"Section",
"9",
".",
"1",
".",
"12b"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L431-L468 |
phaethon/kamene | kamene/contrib/gsm_um.py | configurationChangeAcknowledge | def configurationChangeAcknowledge():
"""CONFIGURATION CHANGE ACKNOWLEDGE Section 9.1.12c"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x31) # 00110001
c = MobileId()
packet = a / b / c
return packet | python | def configurationChangeAcknowledge():
"""CONFIGURATION CHANGE ACKNOWLEDGE Section 9.1.12c"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x31) # 00110001
c = MobileId()
packet = a / b / c
return packet | [
"def",
"configurationChangeAcknowledge",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x31",
")",
"# 00110001",
"c",
"=",
"MobileId",
"(",
")",
"packet",
"=",
"a",
"/",
"b",
"/",
"c",
"... | CONFIGURATION CHANGE ACKNOWLEDGE Section 9.1.12c | [
"CONFIGURATION",
"CHANGE",
"ACKNOWLEDGE",
"Section",
"9",
".",
"1",
".",
"12c"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L471-L477 |
phaethon/kamene | kamene/contrib/gsm_um.py | frequencyRedefinition | def frequencyRedefinition(CellChannelDescription_presence=0):
"""Frequency redefinition Section 9.1.13"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x14) # 00010100
c = ChannelDescription()
d = MobileAllocation()
e = StartingTime()
packet = a / b / c / d / e
if CellChannelDescription_pre... | python | def frequencyRedefinition(CellChannelDescription_presence=0):
"""Frequency redefinition Section 9.1.13"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x14) # 00010100
c = ChannelDescription()
d = MobileAllocation()
e = StartingTime()
packet = a / b / c / d / e
if CellChannelDescription_pre... | [
"def",
"frequencyRedefinition",
"(",
"CellChannelDescription_presence",
"=",
"0",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x14",
")",
"# 00010100",
"c",
"=",
"ChannelDescription",
"(",
")",
"d"... | Frequency redefinition Section 9.1.13 | [
"Frequency",
"redefinition",
"Section",
"9",
".",
"1",
".",
"13"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L490-L501 |
phaethon/kamene | kamene/contrib/gsm_um.py | pdchAssignmentCommand | def pdchAssignmentCommand(ChannelDescription_presence=0,
CellChannelDescription_presence=0,
MobileAllocation_presence=0,
StartingTime_presence=0, FrequencyList_presence=0,
ChannelDescription_presence1=0,
... | python | def pdchAssignmentCommand(ChannelDescription_presence=0,
CellChannelDescription_presence=0,
MobileAllocation_presence=0,
StartingTime_presence=0, FrequencyList_presence=0,
ChannelDescription_presence1=0,
... | [
"def",
"pdchAssignmentCommand",
"(",
"ChannelDescription_presence",
"=",
"0",
",",
"CellChannelDescription_presence",
"=",
"0",
",",
"MobileAllocation_presence",
"=",
"0",
",",
"StartingTime_presence",
"=",
"0",
",",
"FrequencyList_presence",
"=",
"0",
",",
"ChannelDesc... | PDCH ASSIGNMENT COMMAND Section 9.1.13a | [
"PDCH",
"ASSIGNMENT",
"COMMAND",
"Section",
"9",
".",
"1",
".",
"13a"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L505-L549 |
phaethon/kamene | kamene/contrib/gsm_um.py | gprsSuspensionRequest | def gprsSuspensionRequest():
"""GPRS SUSPENSION REQUEST Section 9.1.13b"""
a = TpPd(pd=0x6)
b = MessageType()
c = Tlli()
d = RoutingAreaIdentification()
e = SuspensionCause()
packet = a / b / c / d / e
return packet | python | def gprsSuspensionRequest():
"""GPRS SUSPENSION REQUEST Section 9.1.13b"""
a = TpPd(pd=0x6)
b = MessageType()
c = Tlli()
d = RoutingAreaIdentification()
e = SuspensionCause()
packet = a / b / c / d / e
return packet | [
"def",
"gprsSuspensionRequest",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
")",
"c",
"=",
"Tlli",
"(",
")",
"d",
"=",
"RoutingAreaIdentification",
"(",
")",
"e",
"=",
"SuspensionCause",
"(",
")",
"packe... | GPRS SUSPENSION REQUEST Section 9.1.13b | [
"GPRS",
"SUSPENSION",
"REQUEST",
"Section",
"9",
".",
"1",
".",
"13b"
] | train | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L552-L560 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.