# Precedence Level IE examples

The following examples show how to encode and decode the Precedence Level IE.

### Encoding the Precedence Level IE

void *p_data = msg_buffer;
int send_mlpp = 1;
Acu_ext_descr_nb = 0;
Acu_ext_descr_lgth = 0;
Acu_ext_descr_offset = Acu_conn_rq_start_ext_data;
uchar *p_ext_data = Acu_ext_descr_first_address;
//
// Generate MLPP Precedence Level IE
//
if ( send_mlpp )
{
acu_ext_precedence_level *p = ( acu_ext_precedence_level * ) p_ext_data;
Acu_ext_descr_nb += 1;
Acu_ext_descr_lgth += sizeof( acu_ext_precedence_level );
Acu_ext_lgth = sizeof( acu_ext_precedence_level );
Acu_ext_id = ACU_EXT_PRECEDENCE_LEVEL;
p_ext_data += sizeof( acu_ext_precedence_level );
p->level = 3; // PRIORITY level
p->lfb = MLPP_LFB_PATH_RESERVED; // Look Forward Busy - Path reserved.
p->change = 0; // level privilege may be changed at network boundaries
p->coding_std = 0; // CCITT standard coding
p->domain = 0x123456; // Domain is 123456
p->net_id = 0x0789; // Network identity is 789
}
...

### Decoding the Precedence Level IE

void printExtParameters( void * p_data )
{
uchar *p_ext_data = Acu_ext_descr_first_address;
for ( int i = 0; i < Acu_ext_descr_nb; i++ )
{
// Process according to parameter type
switch ( Acu_ext_id )
{
//-------------------------------------------------------------------------------
// MLPP Precedence Level
//-------------------------------------------------------------------------------
case ACU_EXT_PRECEDENCE_LEVEL:
{
acu_ext_precedence_level *p = ( acu_ext_precedence_level * ) p_ext_data;
printf("\t<EXT>: PRECEDENCE: level=%d, lfb=%d, chg=%d "
"NI='%X%X%X%X', domain=0x%06X\n",
p->level,
p->lfb,
p->change,
( p->net_id >> 12 ) & 0x0F,
( p->net_id >> 8 ) & 0x0F,
( p->net_id >> 4 ) & 0x0F,
( p->net_id >> 0 ) & 0x0F,
p->domain
);
}
break;
...
default:
printf("\t<EXT>: UNKNOWN: id=0x%04X\n", Acu_ext_id );
break;
}
p_ext_data += Acu_ext_lgth; // Move to the next parameter
}
}