diff options
Diffstat (limited to 'sualibrary/sua/sua_syntax.cpp')
-rw-r--r-- | sualibrary/sua/sua_syntax.cpp | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/sualibrary/sua/sua_syntax.cpp b/sualibrary/sua/sua_syntax.cpp index f7d67f4..2b5b755 100644 --- a/sualibrary/sua/sua_syntax.cpp +++ b/sualibrary/sua/sua_syntax.cpp @@ -15,7 +15,7 @@ * * ***************************************************************************/ /* - * $Id: sua_syntax.cpp,v 1.1.1.1 2002/02/04 14:30:41 p82609 Exp $ + * $Id: sua_syntax.cpp,v 1.2 2002/11/12 11:02:49 p82609 Exp $ * * SUA implementation according to SUA draft issue 8. * @@ -57,6 +57,7 @@ #include "sua_syntax.h" #include <iostream> #include <iomanip> + using namespace std; /********************************************************************/ @@ -178,7 +179,7 @@ boolean encode_data (string& msg, string& data) { int pdu_index = msg.size(); msg.resize(pdu_index + 4); /* Encode tag */ - OVERLAY.dw[0] = htons(0x0003); + OVERLAY.dw[0] = htons(0x010b); msg[pdu_index] = OVERLAY.db[0]; pdu_index++; msg[pdu_index] = OVERLAY.db[1]; @@ -771,6 +772,29 @@ boolean encode_SCCP_cause (string& msg, SCCP_cause_struct cause) { return TRUE; } +boolean encode_credit (string& msg, uint32_t credit) { + /* Reserve 8 bytes for credit number */ + int pdu_index = msg.size(); + msg.resize(pdu_index + 8); + /* Encode tag */ + OVERLAY.dw[0] = htons(0x010A); + msg[pdu_index] = OVERLAY.db[0]; + pdu_index++; + msg[pdu_index] = OVERLAY.db[1]; + pdu_index++; + /* Encode length, always 8 bytes */ + OVERLAY.dw[1] = htons(8); + msg[pdu_index] = OVERLAY.db[2]; + pdu_index++; + msg[pdu_index] = OVERLAY.db[3]; + pdu_index++; + /* Encode value : 2 spare bytes, then received seq nr, more data flag and sent seq nr */ + OVERLAY.dq = htonl(credit); // fill in credit value + for(int i = 0; i < 4; i++) + msg[pdu_index + i] = OVERLAY.db[i]; + return TRUE; +} + boolean encode_seq_nr (string& msg, Sua_seq_nr_struct seq_nr) { /* Reserve 8 bytes for sequence number */ int pdu_index = msg.size(); @@ -1422,6 +1446,7 @@ boolean encode_co_conn_ack_msg (Sua_primitive_struct& prim, string& msg) { - Protocol class - Destination reference - Source reference + - sequence control Following parameters are optional : - Routing context - Destination address @@ -1471,6 +1496,16 @@ boolean encode_co_conn_ack_msg (Sua_primitive_struct& prim, string& msg) { return FALSE; } } + + if (prim.seq_control_pres && no_error) + no_error = encode_seq_ctrl (msg, prim.seq_control); + else { + if (no_error) { + /* Signal error : mandatory parameter missing */ + SYNTAX_ERR.error_text = "Encoding : Sequence Control parameter missing"; + return FALSE; + } + } if (prim.dest_addr_pres && no_error) no_error = encode_dest_addr (msg, prim.dest_addr); if (prim.importance_pres && no_error) @@ -3351,7 +3386,7 @@ boolean decode_cl_data_msg (Sua_primitive_struct& prim, string& msg) { OVERLAY.db[1] = msg[pdu_index + 1]; par_tag = ntohs(OVERLAY.dw[0]); switch (par_tag) { - case 0x0003 : + case 0x010b : if (!prim.data_pres) no_error = decode_data (prim, msg, pdu_index); else { @@ -3401,7 +3436,7 @@ boolean decode_cl_data_msg (Sua_primitive_struct& prim, string& msg) { return FALSE; } break; - case 0x0116 : /* tag may change, see SUA v9 */ + case 0x0116 : if (!prim.seq_control_pres) no_error = decode_seq_ctrl (prim, msg, pdu_index); else { @@ -3515,7 +3550,7 @@ boolean decode_cl_data_resp_msg (Sua_primitive_struct& prim, string& msg) { OVERLAY.db[1] = msg[pdu_index + 1]; par_tag = ntohs(OVERLAY.dw[0]); switch (par_tag) { - case 0x0003 : + case 0x010b : if (!prim.data_pres) no_error = decode_data (prim, msg, pdu_index); else { @@ -3650,7 +3685,7 @@ boolean decode_co_conn_req_msg (Sua_primitive_struct& prim, string& msg) { OVERLAY.db[1] = msg[pdu_index + 1]; par_tag = ntohs(OVERLAY.dw[0]); switch (par_tag) { - case 0x0003 : + case 0x010b : if (!prim.data_pres) no_error = decode_data (prim, msg, pdu_index); else { @@ -3793,7 +3828,7 @@ boolean decode_co_conn_ack_msg (Sua_primitive_struct& prim, string& msg) { OVERLAY.db[1] = msg[pdu_index + 1]; par_tag = ntohs(OVERLAY.dw[0]); switch (par_tag) { - case 0x0003 : + case 0x010b : if (!prim.data_pres) no_error = decode_data (prim, msg, pdu_index); else { @@ -3926,7 +3961,7 @@ boolean decode_co_conn_ref_msg (Sua_primitive_struct& prim, string& msg) { OVERLAY.db[1] = msg[pdu_index + 1]; par_tag = ntohs(OVERLAY.dw[0]); switch (par_tag) { - case 0x0003 : + case 0x010b : if (!prim.data_pres) no_error = decode_data (prim, msg, pdu_index); else { @@ -4042,7 +4077,7 @@ boolean decode_co_rel_req_msg (Sua_primitive_struct& prim, string& msg) { OVERLAY.db[1] = msg[pdu_index + 1]; par_tag = ntohs(OVERLAY.dw[0]); switch (par_tag) { - case 0x0003 : + case 0x010b : if (!prim.data_pres) no_error = decode_data (prim, msg, pdu_index); else { @@ -4254,7 +4289,7 @@ boolean decode_co_data_msg (Sua_primitive_struct& prim, string& msg) { OVERLAY.db[1] = msg[pdu_index + 1]; par_tag = ntohs(OVERLAY.dw[0]); switch (par_tag) { - case 0x0003 : + case 0x010b : if (!prim.data_pres) no_error = decode_data (prim, msg, pdu_index); else { |