No project description provided
Project description
Diameter codec - encoder & decoder
- codec is based on RFC https://datatracker.ietf.org/doc/html/rfc6733
- no third party py libs dependencies
- very simple and straightforward to use
- python support: >= 3.6
How to setup dev env
- apt install python3.6
- apt install python3.6-venv
- source venv/bin/activate
- pip install -r requirements.txt
- pylint src/main/python/codec/diameter/ --ignored-classes=_socketobject *.py
How to build project
- pyb -v
- pyb -Q
How to upload project to test.pypi with twine
- python -m twine upload --repository-url https://test.pypi.org/legacy/ target/dist/diameter-codec-<x.y.z>/dist/*
How to upload project to pypi with twine (production)
- python -m twine upload target/dist/diameter-codec-<x.y.z>/dist/*
How to push git tag
- git push origin v<x.y.z>
How to encode and decode Capabilities-Exchange message
import os
import typing
from codec.diameter.diameter import DiameterHeader, Diameter, Avp
from codec.diameter.dictionary import DictionaryLayout, DefaultDictionaryLayout
cer_request: typing.Tuple = (
Avp("Product-Name", "hello"),
Avp("Origin-Realm", "zte.com.cn"),
Avp("Origin-Host", "dmtsrv001.zte.com.cn"),
Avp("Host-IP-Address", "192.168.0.1"),
Avp("Vendor-Id", 10415),
Avp("Product-Name", "dummy-product"),
Avp("Inband-Security-Id", 1),
Avp("Vendor-Specific-Application-Id", (
Avp("Vendor-Id", 10415),
Avp("Acct-Application-Id", 1),
Avp("Auth-Application-Id", 1),
)),
Avp("Vendor-Specific-Application-Id", (
Avp("Auth-Application-Id", 2),
Avp("Acct-Application-Id", 2),
Avp("Vendor-Id", 10415),
)),
)
header: DiameterHeader = DiameterHeader(application_id=0, command_code=257, avp_set=cer_request)
xml_dict_path: str = <path to diameter xml file>
dictionary_layout: DictionaryLayout = DefaultDictionaryLayout(xml_dict_path)
diameter: Diameter = Diameter(dictionary_layout)
encoded_header: bytes = self.diameter.encode(header) # send to TCP server
decoded_header: DiameterHeader = diameter.decode(encoded_header) # decoded on TCP server
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
diameter-codec-1.0.3.tar.gz
(11.2 kB
view details)
Built Distribution
File details
Details for the file diameter-codec-1.0.3.tar.gz
.
File metadata
- Download URL: diameter-codec-1.0.3.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 632f8919292e7175437c50fef52c30ef3f15cae2a527f70c8ae8de0741e87eac |
|
MD5 | 22ff890ab70e981cfbff3615dad7aa91 |
|
BLAKE2b-256 | f2989829f1df9248fade0062a8d2f57c268a3701208e1348318896b03ff3c79f |
Provenance
File details
Details for the file diameter_codec-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: diameter_codec-1.0.3-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed0e90fff9513f82d5c798c43a8834c3cffa2034a9a46ec7e8e6b6ea40a80a70 |
|
MD5 | 9db8b459e40c6a352f4cd9394f3e0c37 |
|
BLAKE2b-256 | 4dfd2b4a134dd34464a088a6526a394f88e3014aa11a43ec31eeac646980895a |