Replies: 1 comment
-
Yes, it would be pretty much welcomed if you could add the protocol support yourself. To do this, I would suppose this is an application layer protocol, you need to create a skeleton class that represents the protocol itself, a data class that holds the protocol header fields, and a schema class that defines the structure of the protocol. Schema Classfrom pcapkit.corekit.fields.numbers import UInt32Field
from pcapkit.corekit.fields.strings import BytesField
from pcapkit.protocols.schema.schema import Schema, schema_final
@schema_final # this will automatically generate a constructor for this class
class Schema_NGAP(Schema):
# now you define the fields in order, for example, we say it has firstly two ports then binary data
port_one = UInt32Field()
port_two = UInt32Field()
data = BytesField(lambda: pkt: pkt['__length__'])
Data Classfrom pcapkit.corekit.infoclass import info_final
from pcapkit.protocols.data.protocol import Protocol
@info_final
class Data_NGAP(Protocol):
port_one: int
port_two: int
data: bytes Skeleton Classfrom pcapkit.protocols.application.application import Application
from pcapkit.utilities.exceptions import ProtocolError, UnsupportedCall
class NGAP(Application[Data_GNAP, Schema_NGAP], data=Data_NGAP, schema=Schema_NGAP):
@property
def name(self):
return 'NG Application Protocol'
def read(self, length: 'Optional[int]' = None, **kwargs: 'Any') -> 'Data_NGAP':
if length is None:
length = len(self)
schema = self.__header__
# extra handling of data mapping/processing can be done here before storing to the data class
return Data_NGAP(port_one=schema.port_one, port_two=schema.port_two, data=schema.data)
def make(...) -> Schema_NGAP': # constructor for the protocol with given args
...
return Schema_NGAP(port_one=..., port_two=..., data=...) Protocol RegistrationIf this protocol is wrapped under TCP (or UDP is the same), then you can register it by calling the from pcapkit.protocols.transport.tcp import TCP
TCP.register(port_number, NGAP) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, Is it possible to add NGAP protocol support to the kit? It is mainly used in 5G Networks. How would one go about adding support for it?
TIA
Beta Was this translation helpful? Give feedback.
All reactions