Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » CROSSTAG conditioned on several fields
CROSSTAG conditioned on several fields [message #1848231] Thu, 25 November 2021 16:16 Go to next message
Pau Espin Pedrol is currently offline Pau Espin PedrolFriend
Messages: 14
Registered: November 2021
Junior Member
Hi,

I was trying to implement a CodecPort for a simple message-based protocol on top of a Unix Domain socket (AF_UNIX, SOCK_SEQPACKET), where the message content is based in a 3-field tuple header:

struct hnb_prim_hdr {
	uint32_t sap;    /*!< Service Access Point Identifier */
	uint32_t primitive;    /*!< Primitive number */
	uint32_t operation; /*! Primitive Operation */
} __attribute__ ((packed));


So sap is a first level of multiplexing between diferent services in the socket interface, with following values:
#define HNB_PRIM_SAPI_CTL 0
#define HNB_PRIM_SAPI_IUH 1
#define HNB_PRIM_SAPI_GTP 2
#define HNB_PRIM_SAPI_AUDIO 3


Then each SAP has its own set of primitive values, which also define the contents of the payload. For instance:
enum hnb_ctl_prim_type {
	HNB_CTL_PRIM_HELLO,
	_HNB_CTL_PRIM_MAX
};


And finally we have a shared set of common operations which also define the contents of the payload:
/*! primitive operation */
enum osmo_prim_operation {
	PRIM_OP_REQUEST,	/*!< request */
	PRIM_OP_RESPONSE,	/*!< response */
	PRIM_OP_INDICATION,	/*!< indication */
	PRIM_OP_CONFIRM,	/*!< confirm */
};


So, the idea is that the 3 first fields of the message identify the contents following it.
So ideally, in TTCN3 I'd like to have something like a record containing the 3-field header + one union containing aa record for each of the the 3-field combinations, something like:
/**********************
 * CTL SAPI
 **********************/
type enumerated HNBLLIF_CTL_MsgType {
	HNBLL_IF_CTL_MSG_HELLO	('00000000'O)
} with { variant "FIELDLENGTH(32)" };

type record HNBLLIF_CTL_hello_ind {
	uint32_t	api_version
} with { variant "" };

type record HNBLLIF_CTL_hello_cnf {
	uint32_t	api_version
} with { variant "" };

type union HNBLLIF_CTL_MsgUnion {
	HNBLLIF_CTL_hello_ind	hello_ind,
	HNBLLIF_CTL_hello_cnf	hello_cnf,
	octetstring		other
} with { variant "" };


/**********************
 * IUH SAPI
 **********************/
 type enumerated HNBLLIF_IUH_MsgType {
 	HNBLL_IF_IUH_MSG_CONFIGURE	('00000000'O)
 } with { variant "FIELDLENGTH(32)" };

 type record HNBLLIF_IUH_configure_req {
 	uint32_t	api_version
 } with { variant "" };

 type union HNBLLIF_IUH_MsgUnion {
 	HNBLLIF_IUH_configure_req	hello_ind,
 	octetstring			other
 } with { variant "" };

/**********************
* General
**********************/
type enumerated HNBLLIF_Sapi {
	HNBLL_IF_SAPI_CTL		('0000'O),
	HNBLL_IF_SAPI_IUH		('0001'O)//,
	//HNBLL_IF_SAPI_GTP		('0002'O),
	//HNBLL_IF_SAPI_AUDIO		('0003'O),
} with { variant "FIELDLENGTH(32)" };

type enumerated HNBLLIF_Operation {
	HNBLL_IF_OP_REQUEST	('00000000'O),
	HNBLL_IF_OP_RESPONSE	('00000001'O),
	HNBLL_IF_OP_INDICATION	('00000002'O),
	HNBLL_IF_OP_CONFIRM	('00000003'O)
} with { variant "FIELDLENGTH(32)" };

type union HNBLLIF_PrimitiveUnion {
	HNBLLIF_CTL_MsgType		ctl,
	HNBLLIF_IUH_MsgType		iuh,
	uint32_t			other
} with { variant "" };

type union HNBLLIF_MsgUnion {
	HNBLLIF_CTL_MsgUnion		ctl,
	HNBLLIF_IUH_MsgUnion		iuh,
	octetstring			other
} with { variant "" };

type record HNBLLIF_Message {
	HNBLLIF_Sapi sapi,
	HNBLLIF_PrimitiveUnion prim,
	HNBLLIF_Operation operation,
	HNBLLIF_MsgUnion u
} with { variant (prim) "CROSSTAG(
				ctl, 		sapi = HNBLL_IF_SAPI_CTL;
				iuh, 		sapi = HNBLL_IF_SAPI_IUH;
				other,	OTHERWISE)"
	variant (u) "CROSSTAG(
				ctl, 		sapi = HNBLL_IF_SAPI_CTL;
				iuh, 		sapi = HNBLL_IF_SAPI_IUH;
				other,	OTHERWISE)"
	variant (u.ctl) "CROSSTAG(
				hello_ind, 	prim.ctl = HNBLL_IF_CTL_MSG_HELLO;
				other,	OTHERWISE)"
};

external function enc_HNBLLIF_Message(in HNBLLIF_Message pdu) return octetstring
	with { extension "prototype(convert) encode(RAW)" };
external function dec_HNBLLIF_Message(in octetstring stream) return HNBLLIF_Message
	with { extension "prototype(convert) decode(RAW)" };



The problem I found, is that it seems CROSSTAG seems to work based only on one key_value conditions/restriction. So I cannot do something like:
sapi=HNBLL_IF_SAPI_CTL + prim=operation + operation=HNBLL_IF_OP_INDICATION => select u.ctl.hello_ind

The example above I showed is compiling fine, but the RAW decoder is always choosing u.ctl.other. Also, I'd need to differentiate between hello_ind and hello_cnf somehow.

So far I'm rewriting all that TTCN3 code above to have it into several nested record+union records, but it adds a lot of boilerplate when defining the messages and using them, so something like my initial idea would be great. Now the question: Is it possible with the RAW codec?

[Updated on: Thu, 25 November 2021 16:17]

Report message to a moderator

Re: CROSSTAG conditioned on several fields [message #1848258 is a reply to message #1848231] Fri, 26 November 2021 07:43 Go to previous message
Gábor Szalai is currently offline Gábor SzalaiFriend
Messages: 134
Registered: December 2015
Senior Member
Currently the CROSSTAG uses only one key. A different layered structure is needed to decode the structure with RAW decoder.

Previous Topic:ttcn3_makefilegen with TPD files for hello world project
Next Topic:Finalize a test result before teardown
Goto Forum:
  


Current Time: Sat Oct 12 10:19:39 GMT 2024

Powered by FUDForum. Page generated in 0.03837 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top