-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot get AVP data in native type #1
Comments
Hi @ofraiwan, Thanks for your feedback. Bromélia was designed to store serialized data into instance attributes for all DiameterAVP subclasses. It means all DiameterAVP subclasses will have a data attribute with the encoded AVP data (i.e. in byte stream). It applies to code, flags, length, vendor_id & padding attributes as well. There are available methods to get DiameterAVP attributes in integer format, except the data one. However, in order to check the value of a given DiameterAVP (data attribute) you may use the defined constants in For example: >>> from bromelia.lib.etsi_3gpp_gx import *
>>> cca = CCA()
>>> cca
<Diameter Message: 272 [CCA] PXY, 16777238 [3GPP Gx], 7 AVP(s)>
>>> cca.result_code_avp
<Diameter AVP: 268 [Result-Code] MANDATORY>
>>> cca.result_code_avp.data
b'\x00\x00\x07\xd1'
>>> from bromelia.constants import *
>>> DIAMETER_SUCCESS
b'\x00\x00\x07\xd1'
>>> cca.result_code_avp.data == DIAMETER_SUCCESS
True Let me know if it works as per you purpose. Otherwise, feel free to give more details on how it would work and why my explanation does not help to do so. Btw, did you refer to have something like as follows? >>> cca.result_code_avp.get_data()
'DIAMETER_SUCCESS' Or >>> cca.result_code_avp.get_data()
2001 Cheers! |
Hi @heimiricmr The comparison method mentioned in But having something like the suggestion in The same applies to all methods, like get_flags, get_vendor_id, etc. |
Hi @ofraiwan, I got your point. It seems to me we may label it as an enhancement, right? On one hand, I think the >>> from bromelia.base import DiameterAVP
>>> avp = DiameterAVP()
>>> avp
<Diameter AVP: 0 [Unknown]>
>>> avp.set_mandatory_bit(True)
>>> avp
<Diameter AVP: 0 [Unknown] MANDATORY>
>>> avp.set_vendor_id_bit(True)
>>> avp
<Diameter AVP: 0 [Unknown] VENDOR, MANDATORY>
>>> avp.set_protected_bit(True)
>>> avp
<Diameter AVP: 0 [Unknown] VENDOR, MANDATORY, PROTECTED> On the other hand, I agree with you a >>> from bromelia.avps import *
>>> avp = RatTypeAVP(RAT_TYPE_EUTRAN)
>>> avp.data
b'\x00\x00\x03\xec'
>>> avp.get_data()
`EUTRAN` However, what about other BaseType based objects such as Unsigned32Type, Integer32Type and Unsigned64Type? Should it return its integer value? What about GroupedType based objects? They already provide a way to access its AVPs by attributes and the I would like your support in order to define how it should work. So we may fine tune the expected requirements. Let me know your thoughts on each subject. Cheers! |
Hi @heimiricmr For the first question, yes, it might be labeled as an enhancement. Second, the get_data method should do the inverse function of the serializing function. You have two cases:
For the GroupedType, you are already using a composite design pattern, so it is up to you how to implement the inverse function and represent the returned data. |
For example, I have an answer object of type CreditControlAnswer, which has an AVP of type ResultCodeAVP.
I need to check what is the value of that AVP. The data attribute of the ResultCodeAVP returns only the serialized (encoded) data, and there are no methods available to deserialize (decode) that data.
The same applies to all AVP classes of all types.
The text was updated successfully, but these errors were encountered: