| module LLC_Templates { |
| |
| import from LLC_Types all; |
| import from Osmocom_Types all; |
| import from General_Types all; |
| |
| template Address_field t_LLC_Addr(template BIT4 sapi, template BIT1 cr, template BIT1 pd := '0'B) := { |
| sAPI := sapi, |
| spare := '00'B, |
| cR := cr, |
| pD := '0'B |
| } |
| template (value) Address_field ts_LLC_Addr(template (value) BIT4 sapi, |
| template (value) BIT1 cr, |
| template (value) BIT1 pd := '0'B) := { |
| sAPI := sapi, |
| spare := '00'B, |
| cR := cr, |
| pD := '0'B |
| } |
| |
| template (value) Control_field_UI ts_LLC_CtrlUI(uint9_t n_u, boolean encrypted := false, |
| boolean protected := false) := { |
| format := '110'B, |
| spare := '00'B, |
| nU := n_u, |
| e := bool2bit(encrypted), |
| pM := bool2bit(protected) |
| } |
| |
| template (value) Control_field_U ts_LLC_CtrlU(template (value) BIT4 m_bits, template (value) BIT1 p_f) := { |
| mBits := m_bits, |
| pF := p_f, |
| format := '111'B |
| } |
| |
| template Control_field_UI tr_LLC_CtrlUI(template uint9_t n_u, |
| template boolean encrypted := ?, |
| template boolean protected := ?) := { |
| format := '110'B, |
| spare := '00'B, |
| nU := n_u, |
| e := bool2bit_tmpl(encrypted), |
| pM := bool2bit_tmpl(protected) |
| } |
| |
| template Control_field_U tr_LLC_CtrlU(template BIT4 m_bits := ?, |
| template BIT1 p_f := ?) := { |
| mBits := m_bits, |
| pF := p_f, |
| format := '111'B |
| } |
| |
| |
| template PDU_LLC ts_LLC_UI(octetstring payload, BIT4 sapi, BIT1 cr, uint9_t n_u, |
| boolean encrypted := false, boolean protected := false) := { |
| pDU_LLC_UI := { |
| address_field := ts_LLC_Addr(sapi, cr), |
| control_field := ts_LLC_CtrlUI(n_u, encrypted, protected), |
| information_field_UI := payload, |
| fCS := omit /* causes encoder to generate FCS */ |
| } |
| } |
| |
| template PDU_LLC tr_LLC_UI(template octetstring payload := ?, template BIT4 sapi := ?, |
| template BIT1 cr := ?, template uint9_t n_u := ?, |
| template boolean encrypted := ?, template boolean protected := ?) := { |
| pDU_LLC_UI := { |
| address_field := t_LLC_Addr(sapi, cr), |
| control_field := tr_LLC_CtrlUI(n_u, encrypted, protected), |
| information_field_UI := payload, |
| fCS := '000000'O /* provided by decoder if FCS OK */ |
| } |
| } |
| |
| template PDU_LLC tr_LLC_XID(template XID_Information xid, template BIT4 sapi := ?, |
| template BIT1 cr := ?, template BIT1 p_f := ?) := { |
| pDU_LLC_U := { |
| address_field := t_LLC_Addr(sapi, cr), |
| control_field := tr_LLC_CtrlU('1011'B, p_f), |
| information_field_U := { |
| xID := xid |
| }, |
| fCS := '000000'O /* provided by decoder if FCS OK */ |
| } |
| } |
| |
| template PDU_LLC tr_LLC_U(template BIT4 m_bits, template BIT1 p_f, template Information_field_U u, |
| template BIT4 sapi, template BIT1 cr) := { |
| pDU_LLC_U := { |
| address_field := t_LLC_Addr(sapi, cr), |
| control_field := tr_LLC_CtrlU(m_bits, p_f), |
| information_field_U := u, |
| fCS := '000000'O /* provided by decoder if FCS OK */ |
| } |
| } |
| template (value) PDU_LLC ts_LLC_U(template (value) BIT4 m_bits, template (value) BIT1 p_f, |
| template (value) Information_field_U u, |
| template (value) BIT4 sapi, template (value) BIT1 cr) := { |
| pDU_LLC_U := { |
| address_field := ts_LLC_Addr(sapi, cr), |
| control_field := ts_LLC_CtrlU(m_bits, p_f), |
| information_field_U := u, |
| fCS := omit /* causes encoder to generate FCS */ |
| } |
| } |
| |
| template PDU_LLC tr_LLC_SABM(template SABM_Information sabm_xid, template BIT1 p_f, |
| template BIT4 sapi, template BIT1 cr) := |
| tr_LLC_U('0111'B, p_f, Information_field_U:{sABM := sabm_xid}, sapi, cr); |
| template (value) PDU_LLC ts_LLC_SABM(template (value) SABM_Information sabm_xid, |
| template (value) BIT1 p_f, |
| template (value) BIT4 sapi, template (value) BIT1 cr) := |
| ts_LLC_U('0111'B, p_f, Information_field_U:{sABM := sabm_xid}, sapi, cr); |
| |
| template PDU_LLC tr_LLC_UA(template UA_Information ua_xid, template BIT1 p_f, |
| template BIT4 sapi, template BIT1 cr) := |
| tr_LLC_U('0110'B, p_f, Information_field_U:{uA := ua_xid}, sapi, cr); |
| template (value) PDU_LLC ts_LLC_UA(template (value) UA_Information ua_xid, |
| template (value) BIT1 p_f, |
| template (value) BIT4 sapi, template (value) BIT1 cr) := |
| ts_LLC_U('0110'B, p_f, Information_field_U:{uA := ua_xid}, sapi, cr); |
| |
| template PDU_LLC tr_LLC_FRMR(template FRMR_Information frmr, template BIT1 p_f, |
| template BIT4 sapi, template BIT1 cr) := |
| tr_LLC_U('1000'B, p_f, Information_field_U:{fRMR := frmr}, sapi, cr); |
| template (value) PDU_LLC ts_LLC_FRMR(template (value) FRMR_Information frmr, |
| template (value) BIT1 p_f, |
| template (value) BIT4 sapi, template (value) BIT1 cr) := |
| ts_LLC_U('1000'B, p_f, Information_field_U:{fRMR := frmr}, sapi, cr); |
| |
| template PDU_LLC tr_LLC_DM(template BIT1 p_f, template BIT4 sapi, template BIT1 cr) := |
| tr_LLC_U('0001'B, p_f, Information_field_U:{dM := ''O}, sapi, cr); |
| template (value) PDU_LLC ts_LLC_DM(template (value) BIT1 p_f, template (value) BIT4 sapi, |
| template (value) BIT1 cr) := |
| ts_LLC_U('0001'B, p_f, Information_field_U:{dM := ''O}, sapi, cr); |
| |
| template PDU_LLC tr_LLC_NULL(template BIT1 p_f, template BIT4 sapi, template BIT1 cr) := |
| tr_LLC_U('0000'B, p_f, Information_field_U:{nULL := ''O}, sapi, cr); |
| template (value) PDU_LLC ts_LLC_NULL(template (value) BIT1 p_f, template (value) BIT4 sapi, |
| template (value) BIT1 cr) := |
| ts_LLC_U('0000'B, p_f, Information_field_U:{nULL := ''O}, sapi, cr); |
| |
| template PDU_LLC tr_LLC_DISC(template BIT1 p_f, template BIT4 sapi, template BIT1 cr) := |
| tr_LLC_U('0100'B, p_f, Information_field_U:{dISC := ''O}, sapi, cr); |
| template (value) PDU_LLC ts_LLC_DISC(template (value) BIT1 p_f, template (value) BIT4 sapi, |
| template (value) BIT1 cr) := |
| ts_LLC_U('0100'B, p_f, Information_field_U:{dISC := ''O}, sapi, cr); |
| |
| |
| const BIT4 c_LLC_SAPI_LLGMM := '0001'B; |
| const BIT4 c_LLC_SAPI_TOM2 := '0010'B; |
| const BIT4 c_LLC_SAPI_LL3 := '0011'B; |
| const BIT4 c_LLC_SAPI_LL5 := '0101'B; |
| const BIT4 c_LLC_SAPI_LLSMS := '0111'B; |
| const BIT4 c_LLC_SAPI_TOM8 := '1000'B; |
| const BIT4 c_LLC_SAPI_LL9 := '1001'B; |
| const BIT4 c_LLC_SAPI_LL11 := '1011'B; |
| |
| const BIT1 LLC_CR_DL_CMD := '1'B; |
| const BIT1 LLC_CR_DL_RSP := '0'B; |
| const BIT1 LLC_CR_UL_CMD := '0'B; |
| const BIT1 LLC_CR_UL_RSP := '1'B; |
| |
| /* LLC UI frame with SAPI for L3 payload */ |
| template PDU_LLC tr_LLC_UI_L3 := ( tr_LLC_UI(?, c_LLC_SAPI_LLGMM) ); |
| |
| /* LLC UI frame with SAPI for User payload */ |
| template PDU_LLC tr_LLC_UI_USER := tr_LLC_UI(?, (c_LLC_SAPI_LL3, |
| c_LLC_SAPI_LL5, |
| c_LLC_SAPI_LL9, |
| c_LLC_SAPI_LL11) |
| ); |
| |
| |
| } |