Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add String digits support for GenericDigits #58

Closed
gfigiel opened this Issue Apr 7, 2016 · 5 comments

Comments

Projects
None yet
3 participants
Collaborator

gfigiel commented Apr 7, 2016

Implement TODOs:

// TODO: add method: public String getDecodedDigits() ;
// TODO: add method: public void setDecodedDigits(int encodingScheme, String digits) ;
// TODO: add constructor: public GenericDigitsImpl(int encodingScheme, int typeOfDigits, String digits)

and
// TODO: add public String getDecodedDigits() ;
// TODO: add public void setDecodedDigits(int encodingScheme, String digits) ;

@deruelle deruelle added the enhancement label Apr 7, 2016

@deruelle deruelle added this to the 3.0.0 milestone Apr 7, 2016

@deruelle deruelle added the Help Wanted label Apr 7, 2016

Collaborator

gfigiel commented Apr 7, 2016

Pull request created: #59. The change has been tested only using prepared unit tests.

Collaborator

vetss commented Apr 17, 2016

Hello gfigiel,

I have checked your update, thanks for it.
RestComm Jss7 stack has already implemented code for BCD. See https://github.com/RestComm/jss7/blob/master/isup/isup-impl/src/main/java/org/mobicents/protocols/ss7/isup/impl/message/parameter/AbstractNumber.java
methods:
public int decodeDigits(ByteArrayInputStream bis, int octetsCount)
public int encodeDigits(ByteArrayOutputStream bos)

(Althow the method notations is different - AbstractNumber keeps data in String form, GenericDigits keeps data in the byte[] form). Also GenericDigits is marked as for a national use, may be that is why we keep data in a byte array form.

Which digits do you carry in your sidei GenericDigits ? Are they only '0' - '9' digits or it may be *, @, a, b, c, something other characters ?

AbstractNumber current implementation uses encoding as a hexadecimal digits (0-9, a-f)
As for https://en.wikipedia.org/wiki/Binary-coded_decimal BCD uses 0-9 digits only. TBCD uses 0-9,,#,a,b,c (but ISUP spec insists in BCD and says that values 10-15 are "spare", say are not used)
In your update you use 0-9,
(as 11) and # (as 12).

I am thinking, does ISUP use 10-15 codes at all (may be we need to code only 0-9 digits) ?

Collaborator

vetss commented Apr 17, 2016 edited

ok, I have found your comment for CAP primitives.

Here is an extract from CAP spec:
-- - CorrelationID in EstablishTemporaryConnection
-- - number in VariablePart
-- - digitsResponse in ReceivedInformationArg
-- - midCallEvents in oMidCallSpecificInfo and tMidCallSpecificInfo
-- -- In the digitsResponse and midCallevents, the digits may also include the '', '#',
-- a, b, c and d digits by using the IA5 character encoding scheme. If the BCD even or
-- BCD odd encoding scheme is used, then the following encoding shall be applied for the
-- non-decimal characters: 1011 (
), 1100 (#).
-- -- AssistingSSPIPRoutingAddress in EstablishTemporaryConnection and CorrelationID in
-- AssistRequestInstructions may contain a Hex B digit as address signal. Refer to
-- Annex A.6 for the usage of the Hex B digit.
-- -- Note that when CorrelationID is transported in Generic Digits, then the digits shall
-- always be BCD encoded.

Please confirm that you need this functionality only for usage for CAP stack.
If I am right - then it is better to implement encoder / decoder at CAP stack level. GenericDigits from ISUP point of view is something that is "national encoded". And CAP provides some exact algo for implementing of it (including IA5 encoding - this is first 128 characters of ASCII).

CAP: org.mobicents.protocols.ss7.isup.impl.message.parameter.Digits :
String Digits.getGenericDigitsDecoded();
int Digits.getGenericDigitsTypeOfDigits();
String Digits.setGenericDigitsDecoded(int encodingScheme, int typeOfDigits, String digits);

Is it what you need ?

Collaborator

gfigiel commented Apr 18, 2016

You guess right Sergey :-)
I need this encoding to handle AssistingSSPIPRoutingAddress in EstablishTemporaryConnection and CorrelationID in AssistRequestInstructions as in the specs you mentioned.

My intension was to make the implementation more generic and handle all Hex digits including special telco signes #, *, F depending on encoding scheme.

Any way I had some doubths if TBCD shall be used or plain BCD with neeble reverse order. Additionally I extended GenericDigits class according to: "Note that when CorrelationID is transported in Generic Digits, then the digits shall always be BCD encoded." and current CAP ETC operation API.

The only think I am confused about is special digits representation as there are differencies with coding special chars in (http://www.etsi.org/deliver/etsi_etr/001_099/060/02_60/etr_060e02p.pdf page 15):

TBCD-STRING ::= OCTET STRING (CONSTRAINED BY {
-- two digits per octet, each digit encoded 0000 to 1001 (0 to 9),
-- 1010 (*), 1011 (#), 1100 (a), 1101 (b) or 1110 (c); 1111 used
-- as filler when there is an odd number of digits.
-- bits 8765 of octet n encoding digit 2n
-- bits 4321 of octet n encoding digit 2(n-1) +1 --
} )
-- This type (Telephony Binary Coded Decimal String) is used to
-- represent several digits from 0 through 9, *, #, a, b , c, ..

and comment form specification you mentioned:

If the BCD even or
-- BCD odd encoding scheme is used, then the following encoding shall be applied for the
-- non-decimal characters: 1011 (*), 1100 (#).

Additionally the spcs does not mention TBCD encoding but just BCD - I just added nibbles reverse order based on examplary traces I had.

What do you think will be the best final implementation? Shall I extend ISUP related GenericDigits as CAPGenericDigits impl in CAP stack (changing also CAPParameterFactory API)? Then what encoding shall be used - I opt for TBCD but CAP spec compliant abcd#*f?
I do not need AI5 ES so I will leave it unimplemented as for now.

Indeed I need the follwoing API:
String Digits.getGenericDigitsDecoded();
int Digits.getGenericDigitsTypeOfDigits();
String Digits.setGenericDigitsDecoded(int encodingScheme, int typeOfDigits, String digits);

vetss added a commit to vetss/jss7 that referenced this issue Apr 19, 2016

vetss added a commit to vetss/jss7 that referenced this issue Apr 19, 2016

vetss added a commit to vetss/jss7 that referenced this issue Apr 19, 2016

vetss added a commit to vetss/jss7 that referenced this issue Apr 19, 2016

vetss added a commit to vetss/jss7 that referenced this issue Apr 19, 2016

vetss added a commit to vetss/jss7 that referenced this issue Apr 19, 2016

Collaborator

vetss commented Apr 19, 2016

We decided to add this into ISUP (not CAP) level.

I added your commits and also my extra commit so code fits some Restcomm code style. If you need extra update fill free to provide a new pull request.

69dff56
31eb7c9
564d4af

@vetss vetss closed this Apr 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment