repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
siznax/wptools | wptools/page.py | WPToolsPage._update_data | def _update_data(self, datapoint, key, new_data):
"""
update or assign new data to datapoint
"""
if new_data:
try:
self.data[datapoint].update({key: new_data})
except KeyError:
self.data[datapoint] = {key: new_data} | python | def _update_data(self, datapoint, key, new_data):
"""
update or assign new data to datapoint
"""
if new_data:
try:
self.data[datapoint].update({key: new_data})
except KeyError:
self.data[datapoint] = {key: new_data} | [
"def",
"_update_data",
"(",
"self",
",",
"datapoint",
",",
"key",
",",
"new_data",
")",
":",
"if",
"new_data",
":",
"try",
":",
"self",
".",
"data",
"[",
"datapoint",
"]",
".",
"update",
"(",
"{",
"key",
":",
"new_data",
"}",
")",
"except",
"KeyError... | update or assign new data to datapoint | [
"update",
"or",
"assign",
"new",
"data",
"to",
"datapoint"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L451-L459 | train |
siznax/wptools | wptools/page.py | WPToolsPage._update_params | def _update_params(self):
"""
update params from response data
"""
if self.data.get('title'):
self.params['title'] = self.data.get('title')
if self.data.get('pageid'):
self.params['pageid'] = self.data.get('pageid')
if self.data.get('wikibase'):
... | python | def _update_params(self):
"""
update params from response data
"""
if self.data.get('title'):
self.params['title'] = self.data.get('title')
if self.data.get('pageid'):
self.params['pageid'] = self.data.get('pageid')
if self.data.get('wikibase'):
... | [
"def",
"_update_params",
"(",
"self",
")",
":",
"if",
"self",
".",
"data",
".",
"get",
"(",
"'title'",
")",
":",
"self",
".",
"params",
"[",
"'title'",
"]",
"=",
"self",
".",
"data",
".",
"get",
"(",
"'title'",
")",
"if",
"self",
".",
"data",
"."... | update params from response data | [
"update",
"params",
"from",
"response",
"data"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L472-L481 | train |
siznax/wptools | wptools/page.py | WPToolsPage.skip_action | def skip_action(self, action):
"""
append action to skip flag
"""
if 'skip' not in self.flags:
self.flags['skip'] = []
self.flags['skip'].append(action) | python | def skip_action(self, action):
"""
append action to skip flag
"""
if 'skip' not in self.flags:
self.flags['skip'] = []
self.flags['skip'].append(action) | [
"def",
"skip_action",
"(",
"self",
",",
"action",
")",
":",
"if",
"'skip'",
"not",
"in",
"self",
".",
"flags",
":",
"self",
".",
"flags",
"[",
"'skip'",
"]",
"=",
"[",
"]",
"self",
".",
"flags",
"[",
"'skip'",
"]",
".",
"append",
"(",
"action",
"... | append action to skip flag | [
"append",
"action",
"to",
"skip",
"flag"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L483-L489 | train |
siznax/wptools | wptools/page.py | WPToolsPage.images | def images(self, fields=None, token=None):
"""
Returns image info keys for kind containing token
Args:
- fields: <list> image info values wanted
- token: <str> substring to match image kind
EXAMPLES
Get all available image info:
>>> page.images()
... | python | def images(self, fields=None, token=None):
"""
Returns image info keys for kind containing token
Args:
- fields: <list> image info values wanted
- token: <str> substring to match image kind
EXAMPLES
Get all available image info:
>>> page.images()
... | [
"def",
"images",
"(",
"self",
",",
"fields",
"=",
"None",
",",
"token",
"=",
"None",
")",
":",
"if",
"'image'",
"not",
"in",
"self",
".",
"data",
":",
"return",
"out",
"=",
"[",
"]",
"for",
"img",
"in",
"self",
".",
"data",
"[",
"'image'",
"]",
... | Returns image info keys for kind containing token
Args:
- fields: <list> image info values wanted
- token: <str> substring to match image kind
EXAMPLES
Get all available image info:
>>> page.images()
Get all image kinds:
>>> page.images('kind')
... | [
"Returns",
"image",
"info",
"keys",
"for",
"kind",
"containing",
"token"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L700-L738 | train |
siznax/wptools | wptools/request.py | WPToolsRequest.get | def get(self, url, status):
"""
in favor of python-requests for speed
"""
# consistently faster than requests by 3x
#
# r = requests.get(url,
# headers={'User-Agent': self.user_agent})
# return r.text
crl = self.cobj
try... | python | def get(self, url, status):
"""
in favor of python-requests for speed
"""
# consistently faster than requests by 3x
#
# r = requests.get(url,
# headers={'User-Agent': self.user_agent})
# return r.text
crl = self.cobj
try... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"status",
")",
":",
"crl",
"=",
"self",
".",
"cobj",
"try",
":",
"crl",
".",
"setopt",
"(",
"pycurl",
".",
"URL",
",",
"url",
")",
"except",
"UnicodeEncodeError",
":",
"crl",
".",
"setopt",
"(",
"pycurl",... | in favor of python-requests for speed | [
"in",
"favor",
"of",
"python",
"-",
"requests",
"for",
"speed"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/request.py#L52-L76 | train |
siznax/wptools | wptools/request.py | WPToolsRequest.curl_perform | def curl_perform(self, crl):
"""
performs HTTP GET and returns body of response
"""
bfr = BytesIO()
crl.setopt(crl.WRITEFUNCTION, bfr.write)
crl.perform()
info = curl_info(crl)
if info:
if self.verbose and not self.silent:
for i... | python | def curl_perform(self, crl):
"""
performs HTTP GET and returns body of response
"""
bfr = BytesIO()
crl.setopt(crl.WRITEFUNCTION, bfr.write)
crl.perform()
info = curl_info(crl)
if info:
if self.verbose and not self.silent:
for i... | [
"def",
"curl_perform",
"(",
"self",
",",
"crl",
")",
":",
"bfr",
"=",
"BytesIO",
"(",
")",
"crl",
".",
"setopt",
"(",
"crl",
".",
"WRITEFUNCTION",
",",
"bfr",
".",
"write",
")",
"crl",
".",
"perform",
"(",
")",
"info",
"=",
"curl_info",
"(",
"crl",... | performs HTTP GET and returns body of response | [
"performs",
"HTTP",
"GET",
"and",
"returns",
"body",
"of",
"response"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/request.py#L78-L93 | train |
siznax/wptools | wptools/query.py | safequote_restbase | def safequote_restbase(title):
"""
Safequote restbase title possibly having slash in title
"""
try:
return quote(title.encode('utf-8'), safe='')
except UnicodeDecodeError:
return quote(title, safe='') | python | def safequote_restbase(title):
"""
Safequote restbase title possibly having slash in title
"""
try:
return quote(title.encode('utf-8'), safe='')
except UnicodeDecodeError:
return quote(title, safe='') | [
"def",
"safequote_restbase",
"(",
"title",
")",
":",
"try",
":",
"return",
"quote",
"(",
"title",
".",
"encode",
"(",
"'utf-8'",
")",
",",
"safe",
"=",
"''",
")",
"except",
"UnicodeDecodeError",
":",
"return",
"quote",
"(",
"title",
",",
"safe",
"=",
"... | Safequote restbase title possibly having slash in title | [
"Safequote",
"restbase",
"title",
"possibly",
"having",
"slash",
"in",
"title"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/query.py#L416-L423 | train |
siznax/wptools | wptools/query.py | WPToolsQuery.category | def category(self, title, pageid=None, cparams=None, namespace=None):
"""
Returns category query string
"""
query = self.LIST.substitute(
WIKI=self.uri,
ENDPOINT=self.endpoint,
LIST='categorymembers')
status = pageid or title
query += ... | python | def category(self, title, pageid=None, cparams=None, namespace=None):
"""
Returns category query string
"""
query = self.LIST.substitute(
WIKI=self.uri,
ENDPOINT=self.endpoint,
LIST='categorymembers')
status = pageid or title
query += ... | [
"def",
"category",
"(",
"self",
",",
"title",
",",
"pageid",
"=",
"None",
",",
"cparams",
"=",
"None",
",",
"namespace",
"=",
"None",
")",
":",
"query",
"=",
"self",
".",
"LIST",
".",
"substitute",
"(",
"WIKI",
"=",
"self",
".",
"uri",
",",
"ENDPOI... | Returns category query string | [
"Returns",
"category",
"query",
"string"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/query.py#L129-L159 | train |
siznax/wptools | wptools/query.py | WPToolsQuery.labels | def labels(self, qids):
"""
Returns Wikidata labels query string
"""
if len(qids) > 50:
raise ValueError("The limit is 50.")
self.domain = 'www.wikidata.org'
self.uri = self.wiki_uri(self.domain)
query = self.WIKIDATA.substitute(
WIKI=sel... | python | def labels(self, qids):
"""
Returns Wikidata labels query string
"""
if len(qids) > 50:
raise ValueError("The limit is 50.")
self.domain = 'www.wikidata.org'
self.uri = self.wiki_uri(self.domain)
query = self.WIKIDATA.substitute(
WIKI=sel... | [
"def",
"labels",
"(",
"self",
",",
"qids",
")",
":",
"if",
"len",
"(",
"qids",
")",
">",
"50",
":",
"raise",
"ValueError",
"(",
"\"The limit is 50.\"",
")",
"self",
".",
"domain",
"=",
"'www.wikidata.org'",
"self",
".",
"uri",
"=",
"self",
".",
"wiki_u... | Returns Wikidata labels query string | [
"Returns",
"Wikidata",
"labels",
"query",
"string"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/query.py#L161-L182 | train |
siznax/wptools | wptools/query.py | WPToolsQuery.imageinfo | def imageinfo(self, files):
"""
Returns imageinfo query string
"""
files = '|'.join([safequote(x) for x in files])
self.set_status('imageinfo', files)
return self.IMAGEINFO.substitute(
WIKI=self.uri,
ENDPOINT=self.endpoint,
FILES=file... | python | def imageinfo(self, files):
"""
Returns imageinfo query string
"""
files = '|'.join([safequote(x) for x in files])
self.set_status('imageinfo', files)
return self.IMAGEINFO.substitute(
WIKI=self.uri,
ENDPOINT=self.endpoint,
FILES=file... | [
"def",
"imageinfo",
"(",
"self",
",",
"files",
")",
":",
"files",
"=",
"'|'",
".",
"join",
"(",
"[",
"safequote",
"(",
"x",
")",
"for",
"x",
"in",
"files",
"]",
")",
"self",
".",
"set_status",
"(",
"'imageinfo'",
",",
"files",
")",
"return",
"self"... | Returns imageinfo query string | [
"Returns",
"imageinfo",
"query",
"string"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/query.py#L184-L195 | train |
siznax/wptools | wptools/query.py | WPToolsQuery.parse | def parse(self, title, pageid=None):
"""
Returns Mediawiki action=parse query string
"""
qry = self.PARSE.substitute(
WIKI=self.uri,
ENDPOINT=self.endpoint,
PAGE=safequote(title) or pageid)
if pageid and not title:
qry = qry.replac... | python | def parse(self, title, pageid=None):
"""
Returns Mediawiki action=parse query string
"""
qry = self.PARSE.substitute(
WIKI=self.uri,
ENDPOINT=self.endpoint,
PAGE=safequote(title) or pageid)
if pageid and not title:
qry = qry.replac... | [
"def",
"parse",
"(",
"self",
",",
"title",
",",
"pageid",
"=",
"None",
")",
":",
"qry",
"=",
"self",
".",
"PARSE",
".",
"substitute",
"(",
"WIKI",
"=",
"self",
".",
"uri",
",",
"ENDPOINT",
"=",
"self",
".",
"endpoint",
",",
"PAGE",
"=",
"safequote"... | Returns Mediawiki action=parse query string | [
"Returns",
"Mediawiki",
"action",
"=",
"parse",
"query",
"string"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/query.py#L197-L214 | train |
siznax/wptools | wptools/query.py | WPToolsQuery.query | def query(self, titles, pageids=None, cparams=None):
"""
Returns MediaWiki action=query query string
"""
query = self.QUERY.substitute(
WIKI=self.uri,
ENDPOINT=self.endpoint,
TITLES=safequote(titles) or pageids)
status = titles or pageids
... | python | def query(self, titles, pageids=None, cparams=None):
"""
Returns MediaWiki action=query query string
"""
query = self.QUERY.substitute(
WIKI=self.uri,
ENDPOINT=self.endpoint,
TITLES=safequote(titles) or pageids)
status = titles or pageids
... | [
"def",
"query",
"(",
"self",
",",
"titles",
",",
"pageids",
"=",
"None",
",",
"cparams",
"=",
"None",
")",
":",
"query",
"=",
"self",
".",
"QUERY",
".",
"substitute",
"(",
"WIKI",
"=",
"self",
".",
"uri",
",",
"ENDPOINT",
"=",
"self",
".",
"endpoin... | Returns MediaWiki action=query query string | [
"Returns",
"MediaWiki",
"action",
"=",
"query",
"query",
"string"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/query.py#L216-L238 | train |
siznax/wptools | wptools/query.py | WPToolsQuery.random | def random(self, namespace=0):
"""
Returns query string for random page
"""
query = self.LIST.substitute(
WIKI=self.uri,
ENDPOINT=self.endpoint,
LIST='random')
query += "&rnlimit=1&rnnamespace=%d" % namespace
emoji = [
u'\U... | python | def random(self, namespace=0):
"""
Returns query string for random page
"""
query = self.LIST.substitute(
WIKI=self.uri,
ENDPOINT=self.endpoint,
LIST='random')
query += "&rnlimit=1&rnnamespace=%d" % namespace
emoji = [
u'\U... | [
"def",
"random",
"(",
"self",
",",
"namespace",
"=",
"0",
")",
":",
"query",
"=",
"self",
".",
"LIST",
".",
"substitute",
"(",
"WIKI",
"=",
"self",
".",
"uri",
",",
"ENDPOINT",
"=",
"self",
".",
"endpoint",
",",
"LIST",
"=",
"'random'",
")",
"query... | Returns query string for random page | [
"Returns",
"query",
"string",
"for",
"random",
"page"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/query.py#L266-L293 | train |
siznax/wptools | wptools/query.py | WPToolsQuery.restbase | def restbase(self, endpoint, title):
"""
Returns RESTBase query string
"""
if not endpoint:
raise ValueError("invalid endpoint: %s" % endpoint)
route = endpoint
if title and endpoint != '/page/':
route = endpoint + safequote_restbase(title)
... | python | def restbase(self, endpoint, title):
"""
Returns RESTBase query string
"""
if not endpoint:
raise ValueError("invalid endpoint: %s" % endpoint)
route = endpoint
if title and endpoint != '/page/':
route = endpoint + safequote_restbase(title)
... | [
"def",
"restbase",
"(",
"self",
",",
"endpoint",
",",
"title",
")",
":",
"if",
"not",
"endpoint",
":",
"raise",
"ValueError",
"(",
"\"invalid endpoint: %s\"",
"%",
"endpoint",
")",
"route",
"=",
"endpoint",
"if",
"title",
"and",
"endpoint",
"!=",
"'/page/'",... | Returns RESTBase query string | [
"Returns",
"RESTBase",
"query",
"string"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/query.py#L295-L308 | train |
siznax/wptools | wptools/query.py | WPToolsQuery.site | def site(self, action):
"""
Returns site query
"""
query = None
viewdays = 7
hostpath = self.uri + self.endpoint
if action == 'siteinfo':
query = hostpath + (
'?action=query'
'&meta=siteinfo|siteviews'
'... | python | def site(self, action):
"""
Returns site query
"""
query = None
viewdays = 7
hostpath = self.uri + self.endpoint
if action == 'siteinfo':
query = hostpath + (
'?action=query'
'&meta=siteinfo|siteviews'
'... | [
"def",
"site",
"(",
"self",
",",
"action",
")",
":",
"query",
"=",
"None",
"viewdays",
"=",
"7",
"hostpath",
"=",
"self",
".",
"uri",
"+",
"self",
".",
"endpoint",
"if",
"action",
"==",
"'siteinfo'",
":",
"query",
"=",
"hostpath",
"+",
"(",
"'?action... | Returns site query | [
"Returns",
"site",
"query"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/query.py#L329-L360 | train |
siznax/wptools | wptools/query.py | WPToolsQuery.wikidata | def wikidata(self, title, wikibase=None):
"""
Returns Wikidata query string
"""
self.domain = 'www.wikidata.org'
self.uri = self.wiki_uri(self.domain)
query = self.WIKIDATA.substitute(
WIKI=self.uri,
ENDPOINT=self.endpoint,
LANG=self.v... | python | def wikidata(self, title, wikibase=None):
"""
Returns Wikidata query string
"""
self.domain = 'www.wikidata.org'
self.uri = self.wiki_uri(self.domain)
query = self.WIKIDATA.substitute(
WIKI=self.uri,
ENDPOINT=self.endpoint,
LANG=self.v... | [
"def",
"wikidata",
"(",
"self",
",",
"title",
",",
"wikibase",
"=",
"None",
")",
":",
"self",
".",
"domain",
"=",
"'www.wikidata.org'",
"self",
".",
"uri",
"=",
"self",
".",
"wiki_uri",
"(",
"self",
".",
"domain",
")",
"query",
"=",
"self",
".",
"WIK... | Returns Wikidata query string | [
"Returns",
"Wikidata",
"query",
"string"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/query.py#L370-L392 | train |
siznax/wptools | wptools/restbase.py | WPToolsRESTBase._handle_response | def _handle_response(self):
"""
returns RESTBase response if appropriate
"""
content = self.cache['restbase']['info']['content-type']
if content.startswith('text/html'):
html = self.cache['restbase']['response']
if isinstance(html, bytes):
... | python | def _handle_response(self):
"""
returns RESTBase response if appropriate
"""
content = self.cache['restbase']['info']['content-type']
if content.startswith('text/html'):
html = self.cache['restbase']['response']
if isinstance(html, bytes):
... | [
"def",
"_handle_response",
"(",
"self",
")",
":",
"content",
"=",
"self",
".",
"cache",
"[",
"'restbase'",
"]",
"[",
"'info'",
"]",
"[",
"'content-type'",
"]",
"if",
"content",
".",
"startswith",
"(",
"'text/html'",
")",
":",
"html",
"=",
"self",
".",
... | returns RESTBase response if appropriate | [
"returns",
"RESTBase",
"response",
"if",
"appropriate"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/restbase.py#L41-L65 | train |
siznax/wptools | wptools/restbase.py | WPToolsRESTBase._query | def _query(self, action, qobj):
"""
returns WPToolsQuery string from action
"""
return qobj.restbase(self.params['rest_endpoint'],
self.params.get('title')) | python | def _query(self, action, qobj):
"""
returns WPToolsQuery string from action
"""
return qobj.restbase(self.params['rest_endpoint'],
self.params.get('title')) | [
"def",
"_query",
"(",
"self",
",",
"action",
",",
"qobj",
")",
":",
"return",
"qobj",
".",
"restbase",
"(",
"self",
".",
"params",
"[",
"'rest_endpoint'",
"]",
",",
"self",
".",
"params",
".",
"get",
"(",
"'title'",
")",
")"
] | returns WPToolsQuery string from action | [
"returns",
"WPToolsQuery",
"string",
"from",
"action"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/restbase.py#L67-L72 | train |
siznax/wptools | wptools/restbase.py | WPToolsRESTBase._unpack_images | def _unpack_images(self, rdata):
"""
Set image data from RESTBase response
"""
image = rdata.get('image') # /page/mobile-sections-lead
originalimage = rdata.get('originalimage') # /page/summary
thumbnail = rdata.get('thumbnail') # /page/summary
if image or ori... | python | def _unpack_images(self, rdata):
"""
Set image data from RESTBase response
"""
image = rdata.get('image') # /page/mobile-sections-lead
originalimage = rdata.get('originalimage') # /page/summary
thumbnail = rdata.get('thumbnail') # /page/summary
if image or ori... | [
"def",
"_unpack_images",
"(",
"self",
",",
"rdata",
")",
":",
"image",
"=",
"rdata",
".",
"get",
"(",
"'image'",
")",
"originalimage",
"=",
"rdata",
".",
"get",
"(",
"'originalimage'",
")",
"thumbnail",
"=",
"rdata",
".",
"get",
"(",
"'thumbnail'",
")",
... | Set image data from RESTBase response | [
"Set",
"image",
"data",
"from",
"RESTBase",
"response"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/restbase.py#L120-L155 | train |
siznax/wptools | wptools/utils.py | is_text | def is_text(obj, name=None):
"""
returns True if object is text-like
"""
try: # python2
ans = isinstance(obj, basestring)
except NameError: # python3
ans = isinstance(obj, str)
if name:
print("is_text: (%s) %s = %s" % (ans, name, obj.__class__),
file=sys.s... | python | def is_text(obj, name=None):
"""
returns True if object is text-like
"""
try: # python2
ans = isinstance(obj, basestring)
except NameError: # python3
ans = isinstance(obj, str)
if name:
print("is_text: (%s) %s = %s" % (ans, name, obj.__class__),
file=sys.s... | [
"def",
"is_text",
"(",
"obj",
",",
"name",
"=",
"None",
")",
":",
"try",
":",
"ans",
"=",
"isinstance",
"(",
"obj",
",",
"basestring",
")",
"except",
"NameError",
":",
"ans",
"=",
"isinstance",
"(",
"obj",
",",
"str",
")",
"if",
"name",
":",
"print... | returns True if object is text-like | [
"returns",
"True",
"if",
"object",
"is",
"text",
"-",
"like"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/utils.py#L67-L78 | train |
siznax/wptools | wptools/utils.py | json_loads | def json_loads(data):
"""
python-version-safe json.loads
"""
try:
return json.loads(data, encoding='utf-8')
except TypeError:
return json.loads(data.decode('utf-8')) | python | def json_loads(data):
"""
python-version-safe json.loads
"""
try:
return json.loads(data, encoding='utf-8')
except TypeError:
return json.loads(data.decode('utf-8')) | [
"def",
"json_loads",
"(",
"data",
")",
":",
"try",
":",
"return",
"json",
".",
"loads",
"(",
"data",
",",
"encoding",
"=",
"'utf-8'",
")",
"except",
"TypeError",
":",
"return",
"json",
".",
"loads",
"(",
"data",
".",
"decode",
"(",
"'utf-8'",
")",
")... | python-version-safe json.loads | [
"python",
"-",
"version",
"-",
"safe",
"json",
".",
"loads"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/utils.py#L90-L97 | train |
siznax/wptools | wptools/utils.py | stderr | def stderr(msg, silent=False):
"""
write msg to stderr if not silent
"""
if not silent:
print(msg, file=sys.stderr) | python | def stderr(msg, silent=False):
"""
write msg to stderr if not silent
"""
if not silent:
print(msg, file=sys.stderr) | [
"def",
"stderr",
"(",
"msg",
",",
"silent",
"=",
"False",
")",
":",
"if",
"not",
"silent",
":",
"print",
"(",
"msg",
",",
"file",
"=",
"sys",
".",
"stderr",
")"
] | write msg to stderr if not silent | [
"write",
"msg",
"to",
"stderr",
"if",
"not",
"silent"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/utils.py#L110-L115 | train |
siznax/wptools | wptools/utils.py | template_to_dict | def template_to_dict(tree, debug=0, find=False):
"""
returns wikitext template as dict
debug = 1
prints minimal debug info to stdout
debug > 1
compares _iter() versus _find() results
find = True
sets values from _find() algorithm (default _iter())
"""
# you can comp... | python | def template_to_dict(tree, debug=0, find=False):
"""
returns wikitext template as dict
debug = 1
prints minimal debug info to stdout
debug > 1
compares _iter() versus _find() results
find = True
sets values from _find() algorithm (default _iter())
"""
# you can comp... | [
"def",
"template_to_dict",
"(",
"tree",
",",
"debug",
"=",
"0",
",",
"find",
"=",
"False",
")",
":",
"obj",
"=",
"defaultdict",
"(",
"str",
")",
"errors",
"=",
"[",
"]",
"for",
"item",
"in",
"tree",
":",
"try",
":",
"name",
"=",
"item",
".",
"fin... | returns wikitext template as dict
debug = 1
prints minimal debug info to stdout
debug > 1
compares _iter() versus _find() results
find = True
sets values from _find() algorithm (default _iter()) | [
"returns",
"wikitext",
"template",
"as",
"dict"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/utils.py#L118-L168 | train |
siznax/wptools | wptools/utils.py | template_to_dict_debug | def template_to_dict_debug(name, item, debug):
"""
Print debug statements to compare algorithms
"""
if debug == 1:
print("\n%s = " % name)
elif debug > 1:
print("\n%s" % name)
print("=" * 64)
print(lxml.etree.tostring(item))
print() | python | def template_to_dict_debug(name, item, debug):
"""
Print debug statements to compare algorithms
"""
if debug == 1:
print("\n%s = " % name)
elif debug > 1:
print("\n%s" % name)
print("=" * 64)
print(lxml.etree.tostring(item))
print() | [
"def",
"template_to_dict_debug",
"(",
"name",
",",
"item",
",",
"debug",
")",
":",
"if",
"debug",
"==",
"1",
":",
"print",
"(",
"\"\\n%s = \"",
"%",
"name",
")",
"elif",
"debug",
">",
"1",
":",
"print",
"(",
"\"\\n%s\"",
"%",
"name",
")",
"print",
"(... | Print debug statements to compare algorithms | [
"Print",
"debug",
"statements",
"to",
"compare",
"algorithms"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/utils.py#L202-L212 | train |
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"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/utils.py#L280-L294 | train |
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"
] | 100eaea585c34aa9ad87a9eda8982bb4898f6ec9 | https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/utils.py#L297-L311 | train |
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",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/igmpv3.py#L55-L62 | train |
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",
"]",
":",
"p",
"=",
"p",
"[",
":",
"1",
"]",
"+",
"chr",
"(",
"0",
")",
... | 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",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/igmpv3.py#L144-L158 | train |
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",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/igmpv3.py#L161-L167 | train |
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",
")",
":",
"if",
"ip",
"!=",
"None",
"and",
"ip",
".",
"haslayer",
"(",
"IP",
")",
"and",
"ether",
"!=",
"None",
"and",
"ether",
".",
"haslayer",
"(",
"Ether",
... | 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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/igmpv3.py#L208-L222 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/igmpv3.py#L225-L264 | train |
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",
")",
":",
"CHKSUM_OFFSET",
"=",
"16",
"if",
"len",
"(",
"lsa",
")",
"<",
"CHKSUM_OFFSET",
":",
"raise",
"Exception",
"(",
"\"LSA Packet too short (%s bytes)\"",
"%",
"len",
"(",
"lsa",
")",
")",
"c0",
"=",
"c1",
"=",... | 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",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/ospf.py#L208-L243 | train |
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",
")",
":",
"cls",
"=",
"conf",
".",
"raw_layer",
"if",
"len",
"(",
"p",
")",
">=",
"4",
":",
"typ",
"=",
"p",
"[",
"3",
"]",
"clsname",
"=",
"_OSPF_LSclasses",
".",
"get",
"(",
"typ",
"... | Guess the correct LSA class for a given payload | [
"Guess",
"the",
"correct",
"LSA",
"class",
"for",
"a",
"given",
"payload"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/ospf.py#L283-L292 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/modules/geoip.py#L52-L70 | train |
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",
")",
":",
"tmp",
"=",
"inet_pton",
"(",
"socket",
".",
"AF_INET6",
",",
"ip",
")",
"addr",
"=",
"inet_ntop",
"(",
"socket",
".",
"AF_INET",
",",
"tmp",
"[",
... | 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",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet6.py#L2882-L2899 | train |
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",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils6.py#L386-L397 | train |
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",
"(",
")",
":",
"tod",
"=",
"time",
".",
"time",
"(",
")",
"i",
"=",
"int",
"(",
"tod",
")",
"j",
"=",
"int",
"(",
"(",
"tod",
"-",
"i",
")",
"*",
"(",
"2",
"**",
"32",
")",
")",
"tod",
"=",
"struct",
".",
... | 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",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils6.py#L400-L428 | train |
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",
")",
":",
"a",
"=",
"struct",
".",
"unpack",
"(",
"'16B'",
",",
"a",
")",
"[",
"-",
"4",
":",
"]",
"mac",
"=",
"'33:33:'",
"mac",
"+=",
"(",
"':'",
".",
"join",
"(",
"map",
"(",
"lambda",
"x",
":",
"'%.2x'",
"... | 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",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils6.py#L646-L655 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/windows/__init__.py#L30-L41 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/windows/__init__.py#L43-L55 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/windows/__init__.py#L120-L127 | train |
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'",
"]",
"if",
"co... | Update info about network interface according to given dnet dictionary | [
"Update",
"info",
"about",
"network",
"interface",
"according",
"to",
"given",
"dnet",
"dictionary"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/windows/__init__.py#L129-L144 | train |
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",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/arch/windows/__init__.py#L175-L183 | train |
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",
")",
":",
"RRlist",
"=",
"[",
"]",
"while",
"bitmap",
":",
"if",
"len",
"(",
"bitmap",
")",
"<",
"2",
":",
"warning",
"(",
"\"bitmap too short (%i)\"",
"%",
"len",
"(",
"bitmap",
")",
")",
"return",
"window_block",
... | 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",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/dns.py#L376-L416 | train |
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",
")",
"ietype",
"=",
"ord",
"(",
"s",
"[",
"0",
"]",
")",
"cls",
"=",
"ietypecls",
".",
"get",
"(",
"ietype",
",",
"Raw",
")",
... | Choose the correct Information Element class. | [
"Choose",
"the",
"correct",
"Information",
"Element",
"class",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gtp.py#L399-L413 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L133-L136 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L151-L165 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/plist.py#L504-L506 | train |
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",
"]",
")",
"cls",
"=",
"getPPIType",
... | 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"... | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/ppi.py#L38-L62 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/fields.py#L45-L49 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/fields.py#L93-L105 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L41-L48 | train |
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",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L96-L107 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L516-L525 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L1003-L1007 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L1010-L1016 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L1019-L1028 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L905-L922 | train |
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",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/utils.py#L949-L958 | train |
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",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/ipsec.py#L655-L722 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/ipsec.py#L338-L387 | train |
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",
")",
":",
"if",
"(",
"self",
".",
"type",
"!=",
"0x11",
")",
":",
"self",
".",
"mrtime",
"=",
"0",
"if",
"(",
"self",
".",
"adjust_ip",
"(",
"ip",
")",
"==",
"T... | 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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/igmp.py#L78-L107 | train |
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",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x3B",
")",
"c",
"=",
"ChannelDescript... | ADDITIONAL ASSIGNMENT Section 9.1.1 | [
"ADDITIONAL",
"ASSIGNMENT",
"Section",
"9",
".",
"1",
".",
"1"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L180-L195 | train |
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",
")",
"c",
"=",
"RrCause",
"(",
")",
"packet",
"=",
"a",
"/",
"b",
"/",
"c",
"return",
"packet"
] | ASSIGNMENT COMPLETE Section 9.1.3 | [
"ASSIGNMENT",
"COMPLETE",
"Section",
"9",
".",
"1",
".",
"3"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L296-L302 | train |
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",
")",
"c",
"=",
... | CHANNEL MODE MODIFY Section 9.1.5 | [
"CHANNEL",
"MODE",
"MODIFY",
"Section",
"9",
".",
"1",
".",
"5"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L316-L330 | train |
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",
")",
"c",
"=",
"ChannelDescription2",
"(",
")",
"d",
"=",
"ChannelMode",
"(",
")",
"packet",
"=",
... | CHANNEL MODE MODIFY ACKNOWLEDGE Section 9.1.6 | [
"CHANNEL",
"MODE",
"MODIFY",
"ACKNOWLEDGE",
"Section",
"9",
".",
"1",
".",
"6"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L333-L340 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L344-L367 | train |
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",
")",
"c",
"=",
"RrCause",
"(",
")",
"d",
"=",
"CipherModeSettingAndcipherResponse",
"(",
")",
"packet",
"=... | CIPHERING MODE COMMAND Section 9.1.9 | [
"CIPHERING",
"MODE",
"COMMAND",
"Section",
"9",
".",
"1",
".",
"9"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L383-L393 | train |
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",
")",
"packet",
"=",
"a",
"/",
"b",
"if",
"MobileId_presence",
"is",
"1",
... | CIPHERING MODE COMPLETE Section 9.1.10 | [
"CIPHERING",
"MODE",
"COMPLETE",
"Section",
"9",
".",
"1",
".",
"10"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L396-L404 | train |
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",
")",
"c",
"=",
"MobileStationClassmark2",
"(",
")",
"packet",
"=",
... | CLASSMARK CHANGE Section 9.1.11 | [
"CLASSMARK",
"CHANGE",
"Section",
"9",
".",
"1",
".",
"11"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L408-L417 | train |
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",
")",
"packet",
"=",
"a",
"/",
"b",
"return",
"packet"
] | CLASSMARK ENQUIRY Section 9.1.12 | [
"CLASSMARK",
"ENQUIRY",
"Section",
"9",
".",
"1",
".",
"12"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L421-L426 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L431-L468 | train |
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",
")",
"c",
"=",
"MobileId",
"(",
")",
"packet",
"=",
"a",
"/",
"b",
"/",
"c",
"return",
"pack... | CONFIGURATION CHANGE ACKNOWLEDGE Section 9.1.12c | [
"CONFIGURATION",
"CHANGE",
"ACKNOWLEDGE",
"Section",
"9",
".",
"1",
".",
"12c"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L471-L477 | train |
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",
")",
"c",
"=",
"ChannelDescription",
"(",
")",
"d",
"=",
"Mobi... | Frequency redefinition Section 9.1.13 | [
"Frequency",
"redefinition",
"Section",
"9",
".",
"1",
".",
"13"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L490-L501 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L505-L549 | train |
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"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L552-L560 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | handoverComplete | def handoverComplete(MobileTimeDifference_presence=0):
"""HANDOVER COMPLETE Section 9.1.16"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x2c) # 00101100
c = RrCause()
packet = a / b / c
if MobileTimeDifference_presence is 1:
d = MobileTimeDifferenceHdr(ieiMTD=0x77, eightBitMTD=0x0)
... | python | def handoverComplete(MobileTimeDifference_presence=0):
"""HANDOVER COMPLETE Section 9.1.16"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x2c) # 00101100
c = RrCause()
packet = a / b / c
if MobileTimeDifference_presence is 1:
d = MobileTimeDifferenceHdr(ieiMTD=0x77, eightBitMTD=0x0)
... | [
"def",
"handoverComplete",
"(",
"MobileTimeDifference_presence",
"=",
"0",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x2c",
")",
"c",
"=",
"RrCause",
"(",
")",
"packet",
"=",
"a",
"/",
"b",... | HANDOVER COMPLETE Section 9.1.16 | [
"HANDOVER",
"COMPLETE",
"Section",
"9",
".",
"1",
".",
"16"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L693-L702 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | immediateAssignment | def immediateAssignment(ChannelDescription_presence=0,
PacketChannelDescription_presence=0,
StartingTime_presence=0):
"""IMMEDIATE ASSIGNMENT Section 9.1.18"""
a = L2PseudoLength()
b = TpPd(pd=0x6)
c = MessageType(mesType=0x3F) # 00111111
d = PageMode... | python | def immediateAssignment(ChannelDescription_presence=0,
PacketChannelDescription_presence=0,
StartingTime_presence=0):
"""IMMEDIATE ASSIGNMENT Section 9.1.18"""
a = L2PseudoLength()
b = TpPd(pd=0x6)
c = MessageType(mesType=0x3F) # 00111111
d = PageMode... | [
"def",
"immediateAssignment",
"(",
"ChannelDescription_presence",
"=",
"0",
",",
"PacketChannelDescription_presence",
"=",
"0",
",",
"StartingTime_presence",
"=",
"0",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")"... | IMMEDIATE ASSIGNMENT Section 9.1.18 | [
"IMMEDIATE",
"ASSIGNMENT",
"Section",
"9",
".",
"1",
".",
"18"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L718-L742 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | immediateAssignmentExtended | def immediateAssignmentExtended(StartingTime_presence=0):
"""IMMEDIATE ASSIGNMENT EXTENDED Section 9.1.19"""
a = L2PseudoLength()
b = TpPd(pd=0x6)
c = MessageType(mesType=0x39) # 00111001
d = PageModeAndSpareHalfOctets()
f = ChannelDescription()
g = RequestReference()
h = TimingAdvance(... | python | def immediateAssignmentExtended(StartingTime_presence=0):
"""IMMEDIATE ASSIGNMENT EXTENDED Section 9.1.19"""
a = L2PseudoLength()
b = TpPd(pd=0x6)
c = MessageType(mesType=0x39) # 00111001
d = PageModeAndSpareHalfOctets()
f = ChannelDescription()
g = RequestReference()
h = TimingAdvance(... | [
"def",
"immediateAssignmentExtended",
"(",
"StartingTime_presence",
"=",
"0",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x39",
")",
"d",
"=",
"PageModeAndS... | IMMEDIATE ASSIGNMENT EXTENDED Section 9.1.19 | [
"IMMEDIATE",
"ASSIGNMENT",
"EXTENDED",
"Section",
"9",
".",
"1",
".",
"19"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L750-L766 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | immediateAssignmentReject | def immediateAssignmentReject():
"""IMMEDIATE ASSIGNMENT REJECT Section 9.1.20"""
a = L2PseudoLength(l2pLength=0x13)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x3a) # 00111010
d = PageModeAndSpareHalfOctets()
f = RequestReference()
g = WaitIndication()
h = RequestReference()
i = Wait... | python | def immediateAssignmentReject():
"""IMMEDIATE ASSIGNMENT REJECT Section 9.1.20"""
a = L2PseudoLength(l2pLength=0x13)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x3a) # 00111010
d = PageModeAndSpareHalfOctets()
f = RequestReference()
g = WaitIndication()
h = RequestReference()
i = Wait... | [
"def",
"immediateAssignmentReject",
"(",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
"l2pLength",
"=",
"0x13",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x3a",
")",
"d",
"=",
"PageModeAndSpareHalfOct... | IMMEDIATE ASSIGNMENT REJECT Section 9.1.20 | [
"IMMEDIATE",
"ASSIGNMENT",
"REJECT",
"Section",
"9",
".",
"1",
".",
"20"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L771-L787 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | measurementReport | def measurementReport():
"""MEASUREMENT REPORT Section 9.1.21"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x15) # 00010101
c = MeasurementResults()
packet = a / b / c
return packet | python | def measurementReport():
"""MEASUREMENT REPORT Section 9.1.21"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x15) # 00010101
c = MeasurementResults()
packet = a / b / c
return packet | [
"def",
"measurementReport",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x15",
")",
"c",
"=",
"MeasurementResults",
"(",
")",
"packet",
"=",
"a",
"/",
"b",
"/",
"c",
"return",
"packet"... | MEASUREMENT REPORT Section 9.1.21 | [
"MEASUREMENT",
"REPORT",
"Section",
"9",
".",
"1",
".",
"21"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L790-L796 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | notificationResponse | def notificationResponse():
"""NOTIFICATION RESPONSE Section 9.1.21d"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x26) # 00100110
c = MobileStationClassmark2()
d = MobileId()
e = DescriptiveGroupOrBroadcastCallReference()
packet = a / b / c / d / e
return packet | python | def notificationResponse():
"""NOTIFICATION RESPONSE Section 9.1.21d"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x26) # 00100110
c = MobileStationClassmark2()
d = MobileId()
e = DescriptiveGroupOrBroadcastCallReference()
packet = a / b / c / d / e
return packet | [
"def",
"notificationResponse",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x26",
")",
"c",
"=",
"MobileStationClassmark2",
"(",
")",
"d",
"=",
"MobileId",
"(",
")",
"e",
"=",
"Descripti... | NOTIFICATION RESPONSE Section 9.1.21d | [
"NOTIFICATION",
"RESPONSE",
"Section",
"9",
".",
"1",
".",
"21d"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L823-L831 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | rrCellChangeOrder | def rrCellChangeOrder():
"""RR-CELL CHANGE ORDER Section 9.1.21e"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x8) # 00001000
c = CellDescription()
d = NcModeAndSpareHalfOctets()
packet = a / b / c / d
return packet | python | def rrCellChangeOrder():
"""RR-CELL CHANGE ORDER Section 9.1.21e"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x8) # 00001000
c = CellDescription()
d = NcModeAndSpareHalfOctets()
packet = a / b / c / d
return packet | [
"def",
"rrCellChangeOrder",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x8",
")",
"c",
"=",
"CellDescription",
"(",
")",
"d",
"=",
"NcModeAndSpareHalfOctets",
"(",
")",
"packet",
"=",
"... | RR-CELL CHANGE ORDER Section 9.1.21e | [
"RR",
"-",
"CELL",
"CHANGE",
"ORDER",
"Section",
"9",
".",
"1",
".",
"21e"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L835-L842 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | pagingRequestType1 | def pagingRequestType1(MobileId_presence=0):
"""PAGING REQUEST TYPE 1 Section 9.1.22"""
#The L2 pseudo length of this message is the sum of lengths of all
#information elements present in the message except
#the P1 Rest Octets and L2 Pseudo Length information elements.
a = L2PseudoLength()
b = TpPd(pd=0x... | python | def pagingRequestType1(MobileId_presence=0):
"""PAGING REQUEST TYPE 1 Section 9.1.22"""
#The L2 pseudo length of this message is the sum of lengths of all
#information elements present in the message except
#the P1 Rest Octets and L2 Pseudo Length information elements.
a = L2PseudoLength()
b = TpPd(pd=0x... | [
"def",
"pagingRequestType1",
"(",
"MobileId_presence",
"=",
"0",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x21",
")",
"d",
"=",
"PageModeAndChannelNeeded"... | PAGING REQUEST TYPE 1 Section 9.1.22 | [
"PAGING",
"REQUEST",
"TYPE",
"1",
"Section",
"9",
".",
"1",
".",
"22"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L846-L862 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | pagingRequestType2 | def pagingRequestType2(MobileId_presence=0):
"""PAGING REQUEST TYPE 2 Section 9.1.23"""
a = L2PseudoLength()
b = TpPd(pd=0x6)
c = MessageType(mesType=0x22) # 00100010
d = PageModeAndChannelNeeded()
f = MobileId()
g = MobileId()
packet = a / b / c / d / f / g
if MobileId_presence is... | python | def pagingRequestType2(MobileId_presence=0):
"""PAGING REQUEST TYPE 2 Section 9.1.23"""
a = L2PseudoLength()
b = TpPd(pd=0x6)
c = MessageType(mesType=0x22) # 00100010
d = PageModeAndChannelNeeded()
f = MobileId()
g = MobileId()
packet = a / b / c / d / f / g
if MobileId_presence is... | [
"def",
"pagingRequestType2",
"(",
"MobileId_presence",
"=",
"0",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x22",
")",
"d",
"=",
"PageModeAndChannelNeeded"... | PAGING REQUEST TYPE 2 Section 9.1.23 | [
"PAGING",
"REQUEST",
"TYPE",
"2",
"Section",
"9",
".",
"1",
".",
"23"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L868-L882 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | pagingRequestType3 | def pagingRequestType3():
"""PAGING REQUEST TYPE 3 Section 9.1.24"""
# This message has a L2 Pseudo Length of 19
a = L2PseudoLength(l2pLength=0x13)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x24) # 00100100
d = PageModeAndChannelNeeded()
e = TmsiPTmsi()
f = TmsiPTmsi()
g = TmsiPTmsi()
... | python | def pagingRequestType3():
"""PAGING REQUEST TYPE 3 Section 9.1.24"""
# This message has a L2 Pseudo Length of 19
a = L2PseudoLength(l2pLength=0x13)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x24) # 00100100
d = PageModeAndChannelNeeded()
e = TmsiPTmsi()
f = TmsiPTmsi()
g = TmsiPTmsi()
... | [
"def",
"pagingRequestType3",
"(",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
"l2pLength",
"=",
"0x13",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x24",
")",
"d",
"=",
"PageModeAndChannelNeeded",
"... | PAGING REQUEST TYPE 3 Section 9.1.24 | [
"PAGING",
"REQUEST",
"TYPE",
"3",
"Section",
"9",
".",
"1",
".",
"24"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L886-L899 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | pagingResponse | def pagingResponse():
"""PAGING RESPONSE Section 9.1.25"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x27) # 00100111
c = CiphKeySeqNrAndSpareHalfOctets()
d = MobileStationClassmark2()
e = MobileId()
packet = a / b / c / d / e
return packet | python | def pagingResponse():
"""PAGING RESPONSE Section 9.1.25"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x27) # 00100111
c = CiphKeySeqNrAndSpareHalfOctets()
d = MobileStationClassmark2()
e = MobileId()
packet = a / b / c / d / e
return packet | [
"def",
"pagingResponse",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x27",
")",
"c",
"=",
"CiphKeySeqNrAndSpareHalfOctets",
"(",
")",
"d",
"=",
"MobileStationClassmark2",
"(",
")",
"e",
"... | PAGING RESPONSE Section 9.1.25 | [
"PAGING",
"RESPONSE",
"Section",
"9",
".",
"1",
".",
"25"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L902-L910 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | partialRelease | def partialRelease():
"""PARTIAL RELEASE Section 9.1.26"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0xa) # 00001010
c = ChannelDescription()
packet = a / b / c
return packet | python | def partialRelease():
"""PARTIAL RELEASE Section 9.1.26"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0xa) # 00001010
c = ChannelDescription()
packet = a / b / c
return packet | [
"def",
"partialRelease",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0xa",
")",
"c",
"=",
"ChannelDescription",
"(",
")",
"packet",
"=",
"a",
"/",
"b",
"/",
"c",
"return",
"packet"
] | PARTIAL RELEASE Section 9.1.26 | [
"PARTIAL",
"RELEASE",
"Section",
"9",
".",
"1",
".",
"26"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L914-L920 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | partialReleaseComplete | def partialReleaseComplete():
"""PARTIAL RELEASE COMPLETE Section 9.1.27"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0xf) # 00001111
packet = a / b
return packet | python | def partialReleaseComplete():
"""PARTIAL RELEASE COMPLETE Section 9.1.27"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0xf) # 00001111
packet = a / b
return packet | [
"def",
"partialReleaseComplete",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0xf",
")",
"packet",
"=",
"a",
"/",
"b",
"return",
"packet"
] | PARTIAL RELEASE COMPLETE Section 9.1.27 | [
"PARTIAL",
"RELEASE",
"COMPLETE",
"Section",
"9",
".",
"1",
".",
"27"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L923-L928 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | physicalInformation | def physicalInformation():
"""PHYSICAL INFORMATION Section 9.1.28"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x2d) # 00101101
c = TimingAdvance()
packet = a / b / c
return packet | python | def physicalInformation():
"""PHYSICAL INFORMATION Section 9.1.28"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x2d) # 00101101
c = TimingAdvance()
packet = a / b / c
return packet | [
"def",
"physicalInformation",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x2d",
")",
"c",
"=",
"TimingAdvance",
"(",
")",
"packet",
"=",
"a",
"/",
"b",
"/",
"c",
"return",
"packet"
] | PHYSICAL INFORMATION Section 9.1.28 | [
"PHYSICAL",
"INFORMATION",
"Section",
"9",
".",
"1",
".",
"28"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L932-L938 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | rrInitialisationRequest | def rrInitialisationRequest():
"""RR Initialisation Request Section 9.1.28.a"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x3c) # 00111100
c = CiphKeySeqNrAndMacModeAndChannelCodingRequest()
e = MobileStationClassmark2()
f = Tlli()
g = ChannelRequestDescription()
h = GprsMeasurementResul... | python | def rrInitialisationRequest():
"""RR Initialisation Request Section 9.1.28.a"""
a = TpPd(pd=0x6)
b = MessageType(mesType=0x3c) # 00111100
c = CiphKeySeqNrAndMacModeAndChannelCodingRequest()
e = MobileStationClassmark2()
f = Tlli()
g = ChannelRequestDescription()
h = GprsMeasurementResul... | [
"def",
"rrInitialisationRequest",
"(",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x3c",
")",
"c",
"=",
"CiphKeySeqNrAndMacModeAndChannelCodingRequest",
"(",
")",
"e",
"=",
"MobileStationClassmark2",
... | RR Initialisation Request Section 9.1.28.a | [
"RR",
"Initialisation",
"Request",
"Section",
"9",
".",
"1",
".",
"28",
".",
"a"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L941-L951 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | systemInformationType1 | def systemInformationType1():
"""SYSTEM INFORMATION TYPE 1 Section 9.1.31"""
a = L2PseudoLength(l2pLength=0x15)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x19) # 00011001
d = CellChannelDescription()
e = RachControlParameters()
f = Si1RestOctets()
packet = a / b / c / d / e / f
retur... | python | def systemInformationType1():
"""SYSTEM INFORMATION TYPE 1 Section 9.1.31"""
a = L2PseudoLength(l2pLength=0x15)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x19) # 00011001
d = CellChannelDescription()
e = RachControlParameters()
f = Si1RestOctets()
packet = a / b / c / d / e / f
retur... | [
"def",
"systemInformationType1",
"(",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
"l2pLength",
"=",
"0x15",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x19",
")",
"d",
"=",
"CellChannelDescription",
... | SYSTEM INFORMATION TYPE 1 Section 9.1.31 | [
"SYSTEM",
"INFORMATION",
"TYPE",
"1",
"Section",
"9",
".",
"1",
".",
"31"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L983-L992 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | systemInformationType2 | def systemInformationType2():
"""SYSTEM INFORMATION TYPE 2 Section 9.1.32"""
a = L2PseudoLength(l2pLength=0x16)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x1a) # 00011010
d = NeighbourCellsDescription()
e = NccPermitted()
f = RachControlParameters()
packet = a / b / c / d / e / f
ret... | python | def systemInformationType2():
"""SYSTEM INFORMATION TYPE 2 Section 9.1.32"""
a = L2PseudoLength(l2pLength=0x16)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x1a) # 00011010
d = NeighbourCellsDescription()
e = NccPermitted()
f = RachControlParameters()
packet = a / b / c / d / e / f
ret... | [
"def",
"systemInformationType2",
"(",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
"l2pLength",
"=",
"0x16",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x1a",
")",
"d",
"=",
"NeighbourCellsDescription"... | SYSTEM INFORMATION TYPE 2 Section 9.1.32 | [
"SYSTEM",
"INFORMATION",
"TYPE",
"2",
"Section",
"9",
".",
"1",
".",
"32"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L997-L1006 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | systemInformationType2bis | def systemInformationType2bis():
"""SYSTEM INFORMATION TYPE 2bis Section 9.1.33"""
a = L2PseudoLength(l2pLength=0x15)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x2) # 00000010
d = NeighbourCellsDescription()
e = RachControlParameters()
f = Si2bisRestOctets()
packet = a / b / c / d / e / ... | python | def systemInformationType2bis():
"""SYSTEM INFORMATION TYPE 2bis Section 9.1.33"""
a = L2PseudoLength(l2pLength=0x15)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x2) # 00000010
d = NeighbourCellsDescription()
e = RachControlParameters()
f = Si2bisRestOctets()
packet = a / b / c / d / e / ... | [
"def",
"systemInformationType2bis",
"(",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
"l2pLength",
"=",
"0x15",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x2",
")",
"d",
"=",
"NeighbourCellsDescriptio... | SYSTEM INFORMATION TYPE 2bis Section 9.1.33 | [
"SYSTEM",
"INFORMATION",
"TYPE",
"2bis",
"Section",
"9",
".",
"1",
".",
"33"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L1011-L1020 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | systemInformationType2ter | def systemInformationType2ter():
"""SYSTEM INFORMATION TYPE 2ter Section 9.1.34"""
a = L2PseudoLength(l2pLength=0x12)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x3) # 00000011
d = NeighbourCellsDescription2()
e = Si2terRestOctets()
packet = a / b / c / d / e
return packet | python | def systemInformationType2ter():
"""SYSTEM INFORMATION TYPE 2ter Section 9.1.34"""
a = L2PseudoLength(l2pLength=0x12)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x3) # 00000011
d = NeighbourCellsDescription2()
e = Si2terRestOctets()
packet = a / b / c / d / e
return packet | [
"def",
"systemInformationType2ter",
"(",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
"l2pLength",
"=",
"0x12",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x3",
")",
"d",
"=",
"NeighbourCellsDescriptio... | SYSTEM INFORMATION TYPE 2ter Section 9.1.34 | [
"SYSTEM",
"INFORMATION",
"TYPE",
"2ter",
"Section",
"9",
".",
"1",
".",
"34"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L1025-L1033 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | systemInformationType3 | def systemInformationType3():
"""SYSTEM INFORMATION TYPE 3 Section 9.1.35"""
a = L2PseudoLength(l2pLength=0x12)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x1b) # 00011011
d = CellIdentity()
e = LocalAreaId()
f = ControlChannelDescription()
g = CellOptionsBCCH()
h = CellSelectionParam... | python | def systemInformationType3():
"""SYSTEM INFORMATION TYPE 3 Section 9.1.35"""
a = L2PseudoLength(l2pLength=0x12)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x1b) # 00011011
d = CellIdentity()
e = LocalAreaId()
f = ControlChannelDescription()
g = CellOptionsBCCH()
h = CellSelectionParam... | [
"def",
"systemInformationType3",
"(",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
"l2pLength",
"=",
"0x12",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x1b",
")",
"d",
"=",
"CellIdentity",
"(",
")... | SYSTEM INFORMATION TYPE 3 Section 9.1.35 | [
"SYSTEM",
"INFORMATION",
"TYPE",
"3",
"Section",
"9",
".",
"1",
".",
"35"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L1038-L1051 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | systemInformationType4 | def systemInformationType4(ChannelDescription_presence=0,
MobileAllocation_presence=0):
"""SYSTEM INFORMATION TYPE 4 Section 9.1.36"""
a = L2PseudoLength()
b = TpPd(pd=0x6)
c = MessageType(mesType=0x1C) # 000111100
d = LocalAreaId()
e = CellSelectionParameters()
f... | python | def systemInformationType4(ChannelDescription_presence=0,
MobileAllocation_presence=0):
"""SYSTEM INFORMATION TYPE 4 Section 9.1.36"""
a = L2PseudoLength()
b = TpPd(pd=0x6)
c = MessageType(mesType=0x1C) # 000111100
d = LocalAreaId()
e = CellSelectionParameters()
f... | [
"def",
"systemInformationType4",
"(",
"ChannelDescription_presence",
"=",
"0",
",",
"MobileAllocation_presence",
"=",
"0",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
... | SYSTEM INFORMATION TYPE 4 Section 9.1.36 | [
"SYSTEM",
"INFORMATION",
"TYPE",
"4",
"Section",
"9",
".",
"1",
".",
"36"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L1058-L1076 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | systemInformationType5bis | def systemInformationType5bis():
"""SYSTEM INFORMATION TYPE 5bis Section 9.1.38"""
a = L2PseudoLength(l2pLength=0x12)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x5) # 00000101
d = NeighbourCellsDescription()
packet = a / b / c / d
return packet | python | def systemInformationType5bis():
"""SYSTEM INFORMATION TYPE 5bis Section 9.1.38"""
a = L2PseudoLength(l2pLength=0x12)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x5) # 00000101
d = NeighbourCellsDescription()
packet = a / b / c / d
return packet | [
"def",
"systemInformationType5bis",
"(",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
"l2pLength",
"=",
"0x12",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x5",
")",
"d",
"=",
"NeighbourCellsDescriptio... | SYSTEM INFORMATION TYPE 5bis Section 9.1.38 | [
"SYSTEM",
"INFORMATION",
"TYPE",
"5bis",
"Section",
"9",
".",
"1",
".",
"38"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L1093-L1100 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | systemInformationType5ter | def systemInformationType5ter():
"""SYSTEM INFORMATION TYPE 5ter Section 9.1.39"""
a = L2PseudoLength(l2pLength=0x12)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x6) # 00000110
d = NeighbourCellsDescription2()
packet = a / b / c / d
return packet | python | def systemInformationType5ter():
"""SYSTEM INFORMATION TYPE 5ter Section 9.1.39"""
a = L2PseudoLength(l2pLength=0x12)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x6) # 00000110
d = NeighbourCellsDescription2()
packet = a / b / c / d
return packet | [
"def",
"systemInformationType5ter",
"(",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
"l2pLength",
"=",
"0x12",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x6",
")",
"d",
"=",
"NeighbourCellsDescriptio... | SYSTEM INFORMATION TYPE 5ter Section 9.1.39 | [
"SYSTEM",
"INFORMATION",
"TYPE",
"5ter",
"Section",
"9",
".",
"1",
".",
"39"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L1105-L1112 | train |
phaethon/kamene | kamene/contrib/gsm_um.py | systemInformationType6 | def systemInformationType6():
"""SYSTEM INFORMATION TYPE 6 Section 9.1.40"""
a = L2PseudoLength(l2pLength=0x0b)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x1e) # 00011011
d = CellIdentity()
e = LocalAreaId()
f = CellOptionsBCCH()
g = NccPermitted()
h = Si6RestOctets()
packet = a ... | python | def systemInformationType6():
"""SYSTEM INFORMATION TYPE 6 Section 9.1.40"""
a = L2PseudoLength(l2pLength=0x0b)
b = TpPd(pd=0x6)
c = MessageType(mesType=0x1e) # 00011011
d = CellIdentity()
e = LocalAreaId()
f = CellOptionsBCCH()
g = NccPermitted()
h = Si6RestOctets()
packet = a ... | [
"def",
"systemInformationType6",
"(",
")",
":",
"a",
"=",
"L2PseudoLength",
"(",
"l2pLength",
"=",
"0x0b",
")",
"b",
"=",
"TpPd",
"(",
"pd",
"=",
"0x6",
")",
"c",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x1e",
")",
"d",
"=",
"CellIdentity",
"(",
")... | SYSTEM INFORMATION TYPE 6 Section 9.1.40 | [
"SYSTEM",
"INFORMATION",
"TYPE",
"6",
"Section",
"9",
".",
"1",
".",
"40"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L1117-L1128 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.