gprs: Move NS Types/CodecPort/Emulation to library directory

Change-Id: I876ce0e981d70ff0e737175983002268fd690989
diff --git a/gprs_gb/NS_CodecPort.ttcn b/gprs_gb/NS_CodecPort.ttcn
deleted file mode 100644
index 29f8aa5..0000000
--- a/gprs_gb/NS_CodecPort.ttcn
+++ /dev/null
@@ -1,62 +0,0 @@
-module NS_CodecPort {
-
-	import from IPL4asp_PortType all;
-	import from IPL4asp_Types all;
-	import from BSSGP_Helper_Functions all;
-	import from NS_Types all;
-
-	type record NS_RecvFrom {
-		ConnectionId	connId,
-		HostName	remName,
-		PortNumber	remPort,
-		HostName	locName,
-		PortNumber	locPort,
-		NsPdu		msg
-	}
-
-	template NS_RecvFrom t_NS_RecvFrom(template NsPdu pdu) := {
-		connId := ?,
-		remName := ?,
-		remPort := ?,
-		locName := ?,
-		locPort := ?,
-		msg := pdu
-	};
-
-	type record NS_Send {
-		ConnectionId	connId,
-		NsPdu		msg
-	}
-
-	template NS_Send t_NS_Send(template ConnectionId connId, template NsPdu msg) := {
-		connId := connId,
-		msg := msg
-	}
-
-	private function IPL4_to_NS_RecvFrom(in ASP_RecvFrom pin, out NS_RecvFrom pout) {
-		pout.connId := pin.connId;
-		pout.remName := pin.remName;
-		pout.remPort := pin.remPort;
-		pout.locName := pin.locName;
-		pout.locPort := pin.locPort;
-		pout.msg := dec_NsPdu(f_NS_expand_len(pin.msg));
-	} with { extension "prototype(fast)" };
-
-	private function NS_to_IPL4_Send(in NS_Send pin, out ASP_Send pout) {
-		pout.connId := pin.connId;
-		pout.proto := { udp := {} };
-		pout.msg := f_NS_compact_len(enc_NsPdu(pin.msg));
-	} with { extension "prototype(fast)" };
-
-	type port NS_CODEC_PT message {
-		out	NS_Send;
-		in	NS_RecvFrom,
-			ASP_ConnId_ReadyToRelease,
-			ASP_Event;
-	} with { extension "user IPL4asp_PT
-		out(NS_Send -> ASP_Send: function(NS_to_IPL4_Send))
-		in(ASP_RecvFrom -> NS_RecvFrom: function(IPL4_to_NS_RecvFrom);
-		   ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
-		   ASP_Event -> ASP_Event: simple)"
-	}
-}
diff --git a/gprs_gb/NS_CodecPort_CtrlFunct.ttcn b/gprs_gb/NS_CodecPort_CtrlFunct.ttcn
deleted file mode 100644
index cc77dda..0000000
--- a/gprs_gb/NS_CodecPort_CtrlFunct.ttcn
+++ /dev/null
@@ -1,44 +0,0 @@
-module NS_CodecPort_CtrlFunct {
-
-  import from NS_CodecPort all;
-  import from IPL4asp_Types all;
-
-  external function f_IPL4_listen(
-    inout NS_CODEC_PT portRef,
-    in HostName locName,
-    in PortNumber locPort,
-    in ProtoTuple proto,
-    in OptionList options := {}
-  ) return Result;
-
-  external function f_IPL4_connect(
-    inout NS_CODEC_PT portRef,
-    in HostName remName,
-    in PortNumber remPort,
-    in HostName locName,
-    in PortNumber locPort,
-    in ConnectionId connId,
-    in ProtoTuple proto,
-    in OptionList options := {}
-  ) return Result;
-
-  external function f_IPL4_close(
-    inout NS_CODEC_PT portRef,
-    in ConnectionId id,
-    in ProtoTuple proto := { unspecified := {} }
-  ) return Result;
-
-  external function f_IPL4_setUserData(
-    inout NS_CODEC_PT portRef,
-    in ConnectionId id,
-    in UserData userData
-  ) return Result;
-
-  external function f_IPL4_getUserData(
-    inout NS_CODEC_PT portRef,
-    in ConnectionId id,
-    out UserData userData
-  ) return Result;
-
-}
-
diff --git a/gprs_gb/NS_CodecPort_CtrlFunctDef.cc b/gprs_gb/NS_CodecPort_CtrlFunctDef.cc
deleted file mode 100644
index a6da7ac..0000000
--- a/gprs_gb/NS_CodecPort_CtrlFunctDef.cc
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "IPL4asp_PortType.hh"
-#include "NS_CodecPort.hh"
-#include "IPL4asp_PT.hh"
-
-namespace NS__CodecPort__CtrlFunct {
-
-  IPL4asp__Types::Result f__IPL4__listen(
-    NS__CodecPort::NS__CODEC__PT& portRef,
-    const IPL4asp__Types::HostName& locName,
-    const IPL4asp__Types::PortNumber& locPort,
-    const IPL4asp__Types::ProtoTuple& proto,
-    const IPL4asp__Types::OptionList& options)
-  {
-    return f__IPL4__PROVIDER__listen(portRef, locName, locPort, proto, options);
-  }
-  
-  IPL4asp__Types::Result f__IPL4__connect(
-    NS__CodecPort::NS__CODEC__PT& portRef,
-    const IPL4asp__Types::HostName& remName,
-    const IPL4asp__Types::PortNumber& remPort,
-    const IPL4asp__Types::HostName& locName,
-    const IPL4asp__Types::PortNumber& locPort,
-    const IPL4asp__Types::ConnectionId& connId,
-    const IPL4asp__Types::ProtoTuple& proto,
-    const IPL4asp__Types::OptionList& options)
-  {
-    return f__IPL4__PROVIDER__connect(portRef, remName, remPort,
-                                      locName, locPort, connId, proto, options);
-  }
-
-  IPL4asp__Types::Result f__IPL4__close(
-    NS__CodecPort::NS__CODEC__PT& portRef, 
-    const IPL4asp__Types::ConnectionId& connId, 
-    const IPL4asp__Types::ProtoTuple& proto)
-  {
-      return f__IPL4__PROVIDER__close(portRef, connId, proto);
-  }
-
-  IPL4asp__Types::Result f__IPL4__setUserData(
-    NS__CodecPort::NS__CODEC__PT& portRef,
-    const IPL4asp__Types::ConnectionId& connId,
-    const IPL4asp__Types::UserData& userData)
-  {
-    return f__IPL4__PROVIDER__setUserData(portRef, connId, userData);
-  }
-  
-  IPL4asp__Types::Result f__IPL4__getUserData(
-    NS__CodecPort::NS__CODEC__PT& portRef,
-    const IPL4asp__Types::ConnectionId& connId,
-    IPL4asp__Types::UserData& userData)
-  {
-    return f__IPL4__PROVIDER__getUserData(portRef, connId, userData);
-  }
-  
-}
-
diff --git a/gprs_gb/NS_Emulation.ttcn b/gprs_gb/NS_Emulation.ttcn
deleted file mode 100644
index 253c91e..0000000
--- a/gprs_gb/NS_Emulation.ttcn
+++ /dev/null
@@ -1,271 +0,0 @@
-module NS_Emulation {
-	import from NS_Types all;
-	import from BSSGP_Types all;
-	import from BSSGP_Helper_Functions all;
-	import from NS_CodecPort all;
-	import from NS_CodecPort_CtrlFunct all;
-	import from IPL4asp_Types all;
-
-	type record NsUnitdataRequest {
-		BssgpBvci	bvci,
-		Nsei		nsei,
-		octetstring	sdu optional,
-		BssgpPdu	bssgp optional
-	}
-
-	template NsUnitdataRequest t_NsUdReq(template Nsei nsei, template BssgpBvci bvci, template octetstring sdu,
-					     template BssgpPdu bssgp) := {
-		bvci := bvci,
-		nsei := nsei,
-		sdu := sdu,
-		bssgp := bssgp
-	}
-
-	type record NsUnitdataIndication {
-		BssgpBvci	bvci,
-		Nsei		nsei,
-		octetstring	sdu optional,
-		BssgpPdu	bssgp optional
-	}
-
-	template NsUnitdataIndication t_NsUdInd(Nsei nsei, BssgpBvci bvci, octetstring sdu) := {
-		bvci := bvci,
-		nsei := nsei,
-		sdu := sdu,
-		bssgp := dec_BssgpPdu(f_BSSGP_expand_len(sdu))
-	}
-
-	type record NsStatusIndication {
-		Nsei		nsei,
-		Nsvci		nsvci,
-		NseState	old_state,
-		NseState	new_state
-	}
-
-	template NsStatusIndication t_NsStsInd(Nsei nsei, Nsvci nsvci, NseState old_state, NseState state) := {
-		nsei := nsei,
-		nsvci := nsvci,
-		old_state := old_state,
-		new_state := state
-	}
-
-	type enumerated NseState {
-		NSE_S_DEAD_BLOCKED,
-		NSE_S_WAIT_RESET,
-		NSE_S_ALIVE_BLOCKED,
-		NSE_S_ALIVE_UNBLOCKED
-	}
-
-	/* port from our (internal) point of view */
-	type port NS_SP_PT message {
-		in	NsUnitdataRequest;
-		out	NsUnitdataIndication,
-			NsStatusIndication,
-			ASP_Event;
-	} with { extension "internal" };
-
-	/* port from the user point of view */
-	type port NS_PT message {
-		in	ASP_Event,
-			NsStatusIndication,
-			NsUnitdataIndication;
-		out	NsUnitdataRequest;
-	} with { extension "internal" };
-
-	function NSStart() runs on NS_CT {
-		f_init();
-		f_ScanEvents();
-	}
-
-	private function f_init() runs on NS_CT {
-		var Result res;
-		/* Connect the UDP socket */
-		res := f_IPL4_connect(NSCP, mp_remote_ip, mp_remote_udp_port, mp_local_ip, mp_local_udp_port, 0, { udp := {}});
-		g_conn_id := res.connId;
-		f_change_state(NSE_S_DEAD_BLOCKED);
-		/* Send the first NS-ALIVE to test the connection */
-		f_sendReset();
-	}
-
-	type component NS_CT {
-		/* UDP port towards the bottom (IUT) */
-		port NS_CODEC_PT NSCP;
-		/* NS-User SAP towards the user */
-		port NS_SP_PT NS_SP;
-
-		var NseState		g_state := NSE_S_DEAD_BLOCKED;
-		var ConnectionId	g_conn_id := -1;
-
-		timer Tns_alive := 3.0;
-		timer Tns_test := 10.0;
-		timer Tns_block := 10.0;
-	}
-
-	modulepar {
-		PortNumber mp_local_udp_port := 23000;
-		charstring mp_local_ip := "127.0.0.1";
-		PortNumber mp_remote_udp_port := 21000;
-		charstring mp_remote_ip := "127.0.0.1";
-		Nsvci mp_nsvci := 0;
-		Nsvci mp_nsei := 2342;
-	};
-
-	private function f_change_state(NseState new_state) runs on NS_CT {
-		var NseState old_state := g_state;
-		g_state := new_state;
-		log("NS State Transition: ", old_state, " -> ", new_state);
-		NS_SP.send(t_NsStsInd(mp_nsei, mp_nsvci, old_state, new_state));
-	}
-
-	private function f_sendReset() runs on NS_CT {
-		NSCP.send(t_NS_Send(g_conn_id, t_NS_RESET(NS_CAUSE_OM_INTERVENTION, mp_nsvci, mp_nsei)));
-		g_state := NSE_S_WAIT_RESET;
-	}
-
-	private function f_sendAlive() runs on NS_CT {
-		NSCP.send(t_NS_Send(g_conn_id, t_NS_ALIVE));
-		Tns_alive.start;
-	}
-
-	private function f_sendUnblock() runs on NS_CT {
-		NSCP.send(t_NS_Send(g_conn_id, t_NS_UNBLOCK));
-		Tns_block.start;
-	}
-
-	private function f_sendBlock(NsCause cause) runs on NS_CT {
-		NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK(cause, mp_nsvci)));
-		Tns_block.start;
-	}
-
-	altstep as_allstate() runs on NS_CT {
-		var NS_RecvFrom rf;
-		var ASP_Event evt;
-
-		/* transition to DEAD if t_alive times out */
-		[] Tns_alive.timeout {
-			log("Tns-alive expired: changing to DEAD_BLOCKED + starting Tns-test");
-			f_change_state(NSE_S_DEAD_BLOCKED);
-			Tns_test.start;
-		}
-
-		[] Tns_test.timeout {
-			log("Tns-test expired: sending NS-ALIVE");
-			f_sendAlive();
-		}
-
-		/* Stop t_alive when receiving ALIVE-ACK */
-		[] NSCP.receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)) {
-			log("NS-ALIVE-ACK received: stopping Tns-alive; starting Tns-test");
-			Tns_alive.stop;
-			Tns_test.start;
-		}
-
-		/* respond to NS-ALIVE with NS-ALIVE-ACK */
-		[] NSCP.receive(t_NS_RecvFrom(t_NS_ALIVE)) {
-			NSCP.send(t_NS_Send(g_conn_id, t_NS_ALIVE_ACK));
-		}
-
-		/* Respond to BLOCK for wrong NSVCI */
-		[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK(?, ?))) -> value rf {
-			log("Rx NS-BLOCK for unknown NSVCI");
-			/* FIXME */
-		}
-
-		/* Respond to RESET with correct NSEI/NSVCI */
-		[] NSCP.receive(t_NS_RecvFrom(t_NS_RESET(?, mp_nsvci, mp_nsei))) -> value rf {
-			f_change_state(NSE_S_ALIVE_BLOCKED);
-			NSCP.send(t_NS_Send(g_conn_id, t_NS_RESET_ACK(mp_nsvci, mp_nsei)));
-		}
-
-		/* Respond to RESET with wrong NSEI/NSVCI */
-		[] NSCP.receive(t_NS_RecvFrom(t_NS_RESET(?, ?, ?))) -> value rf {
-			log("Rx NS-RESET for unknown NSEI/NSVCI");
-			/* FIXME */
-		}
-
-		/* default case of handling unknown PDUs */
-		[] NSCP.receive(t_NS_RecvFrom(?)) -> value rf {
-			log("Rx Unexpected NS PDU ", rf.msg," in state ", g_state);
-			NSCP.send(t_NS_Send(g_conn_id, t_NS_STATUS(NS_CAUSE_PDU_NOT_COMPATIBLE_WITH_PROTOCOL_STATE, rf.msg)));
-		}
-		/* Forwarding of ASP_Evet to user */
-		[] NSCP.receive(ASP_Event:?) -> value evt { NS_SP.send(evt); }
-	}
-
-	private function f_ScanEvents() runs on NS_CT {
-		var NsUnitdataRequest ud_req;
-		var NS_RecvFrom rf;
-		var default d;
-
-		d := activate(as_allstate());
-
-		while (true) {
-		if (g_state == NSE_S_DEAD_BLOCKED) {
-			alt {
-				[false] any timer.timeout {}
-			}
-		} else if (g_state == NSE_S_WAIT_RESET) {
-			alt {
-				[] NSCP.receive(t_NS_RecvFrom(t_NS_RESET_ACK(mp_nsvci, mp_nsei))) -> value rf {
-					f_change_state(NSE_S_ALIVE_BLOCKED);
-					f_sendAlive();
-					f_sendUnblock();
-				}
-			}
-		} else if (g_state == NSE_S_ALIVE_BLOCKED) {
-			alt {
-				/* bogus block, just respond with ACK */
-				[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK(?, mp_nsvci))) -> value rf {
-					NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK_ACK(mp_nsvci)));
-				}
-				/* Respond to UNBLOCK with UNBLOCK-ACK + change state */
-				[] NSCP.receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value rf {
-					NSCP.send(t_NS_Send(g_conn_id, t_NS_UNBLOCK_ACK));
-					Tns_block.stop;
-					f_change_state(NSE_S_ALIVE_UNBLOCKED);
-				}
-				[] NSCP.receive(t_NS_RecvFrom(t_NS_UNBLOCK_ACK)) -> value rf {
-					Tns_block.stop;
-					f_change_state(NSE_S_ALIVE_UNBLOCKED);
-				}
-				[] Tns_block.timeout {
-					/* repeat unblock transmission */
-					f_sendUnblock();
-				}
-			}
-		} else if (g_state == NSE_S_ALIVE_UNBLOCKED) {
-			alt {
-				/* bogus unblock, just respond with ACK */
-				[] NSCP.receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value rf {
-					NSCP.send(t_NS_Send(g_conn_id, t_NS_UNBLOCK_ACK));
-				}
-				/* Respond to BLOCK with BLOCK-ACK + change state */
-				[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK(?, mp_nsvci))) -> value rf {
-					NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK_ACK(mp_nsvci)));
-					Tns_block.stop;
-					f_change_state(NSE_S_ALIVE_BLOCKED);
-				}
-				[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK_ACK(mp_nsvci))) -> value rf {
-					Tns_block.stop;
-				}
-				/* NS-UNITDATA PDU from network to NS-UNITDATA.ind to user */
-				[] NSCP.receive(t_NS_RecvFrom(t_NS_UNITDATA(?, ?, ?))) -> value rf {
-					NS_SP.send(t_NsUdInd(mp_nsei, rf.msg.u.unitdata.bvci, rf.msg.u.unitdata.sdu));
-				}
-				/* NS-UNITDATA.req from user to NS-UNITDATA PDU on network */
-				[] NS_SP.receive(t_NsUdReq(mp_nsei, ?, ?, omit)) -> value ud_req {
-					/* using raw octetstring PDU */
-					NSCP.send(t_NS_Send(g_conn_id, t_NS_UNITDATA(t_SduCtrlB, ud_req.bvci, ud_req.sdu)));
-				}
-				[] NS_SP.receive(t_NsUdReq(mp_nsei, ?, omit, ?)) -> value ud_req {
-					/* using decoded BSSGP PDU that we need to encode first */
-					var octetstring enc := f_BSSGP_compact_len(enc_BssgpPdu(ud_req.bssgp));
-					NSCP.send(t_NS_Send(g_conn_id, t_NS_UNITDATA(t_SduCtrlB, ud_req.bvci, enc)));
-				}
-			}
-		}
-
-		} /* while */
-		//deactivate(d);
-	}
-}
diff --git a/gprs_gb/NS_Types.ttcn b/gprs_gb/NS_Types.ttcn
deleted file mode 100644
index ba1c461..0000000
--- a/gprs_gb/NS_Types.ttcn
+++ /dev/null
@@ -1,230 +0,0 @@
-module NS_Types {
-	import from General_Types all;
-	import from Osmocom_Types all;
-	import from GSM_Types all;
-	import from BSSGP_Types all;
-	import from BSSGP_Helper_Functions all;
-
-	/* TS 48.016 10.3.7 */
-	type enumerated NsPduType {
-		NS_PDUT_NS_UNITDATA	('00000000'B),
-		NS_PDUT_NS_RESET	('00000010'B),
-		NS_PDUT_NS_RESET_ACK	('00000011'B),
-		NS_PDUT_NS_BLOCK	('00000100'B),
-		NS_PDUT_NS_BLOCK_ACK	('00000101'B),
-		NS_PDUT_NS_UNBLOCK	('00000110'B),
-		NS_PDUT_NS_UNBLOCK_ACK	('00000111'B),
-		NS_PDUT_NS_STATUS	('00001000'B),
-		NS_PDUT_NS_ALIVE	('00001010'B),
-		NS_PDUT_NS_ALIVE_ACK	('00001011'B)
-		/* FIXME: SNS */
-	} with { variant "FIELDLENGTH(8)" };
-
-	/* TS 48.016 10.3 */
-	type enumerated NsIEI {
-		NS_IEI_CAUSE		('00000000'B),
-		NS_IEI_NSVCI		('00000001'B),
-		NS_IEI_NS_PDU		('00000010'B),
-		NS_IEI_BVCI		('00000011'B),
-		NS_IEI_NSEI		('00000100'B),
-		NS_IEI_LIST_IPv4	('00000101'B),
-		NS_IEI_LIST_IPv6	('00000110'B),
-		NS_IEI_MAX_NUM_NSVC	('00000111'B),
-		NS_IEI_NUM_IPv4_EP	('00001000'B),
-		NS_IEI_NUM_IPv6_EP	('00001001'B),
-		NS_IEI_RESET_FLAG	('00001010'B),
-		NS_IEI_IP_ADDRESS	('00001011'B)
-	} with { variant "FIELDLENGTH(8)" };
-
-	/* TS 48.016 10.3.2 */
-	type enumerated NsCause {
-		NS_CAUSE_TRANSIT_NETWORK_FAILURE		('00000000'B),
-		NS_CAUSE_OM_INTERVENTION			('00000001'B),
-		NS_CAUSE_EQUIPMENT_FAILURE			('00000010'B),
-		NS_CAUSE_NSVC_BLOCKED				('00000011'B),
-		NS_CAUSE_NSVC_UNKNOWN				('00000100'B),
-		NS_CAUSE_BVCI_UNKNOWN_AT_NSE			('00000101'B),
-		NS_CAUSE_SEMANTICALLY_INCORRECT_PDU		('00001000'B),
-		NS_CAUSE_PDU_NOT_COMPATIBLE_WITH_PROTOCOL_STATE	('00001010'B),
-		NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED		('00001011'B),
-		NS_CAUSE_INVALID_ESSENTIAL_IE			('00001100'B),
-		NS_CAUSE_MISSING_ESSENTIAL_IE			('00001101'B),
-		NS_CAUSE_INVALID_NR_OF_IPv4_ENDPOINTS		('00001110'B),
-		NS_CAUSE_INVALID_NR_OF_IPv6_ENDPOINTS		('00001111'B),
-		NS_CAUSE_INVALID_NR_OF_NSVCS			('00010000'B),
-		NS_CAUSE_INVALID_WEIGHTS			('00010001'B),
-		NS_CAUSE_UNKNOWN_IP_ENDPOINT			('00010010'B),
-		NS_CAUSE_UNKNOWN_IP_ADDRESS			('00010011'B),
-		NS_CAUSE_IP_TEST_FAILEDA			('00010100'B)
-	} with { variant "FIELDLENGTH(8)" };
-
-	/* TS 48.016 10.3.9 */
-	type record NsSduControlBits {
-		BIT6	spare,
-		boolean c,
-		boolean r
-	} with { variant (c) "FIELDLENGTH(1)"
-		 variant (r) "FIELDLENGTH(1)"
-	};
-
-	template NsSduControlBits t_SduCtrlB := {
-		spare := '000000'B,
-		c := false,
-		r := false
-	}
-
-	type uint16_t Nsvci;
-	type uint16_t Nsei;
-
-	type union NsIeUnion {
-		BssgpBvci		bvci,		/* 10.3.1 */
-		NsCause			cause,		/* 10.3.2 */
-		uint16_t		max_num_nsvc,	/* 10.3.2e */
-		uint16_t		num_ipv4_ep,	/* 10.3.2f */
-		uint16_t		num_ipv6_ep,	/* 10.3.2g */
-		Nsvci			nsvci,		/* 10.3.5 */
-		Nsei			nsei,		/* 10.3.6 */
-		octetstring 		other
-	};
-
-	type record NsTLV {
-		NsIEI		iei,
-		uint16_t	len,
-		NsIeUnion	u
-	} with {
-		variant (u) "CROSSTAG(
-				bvci, 			iei = NS_IEI_BVCI;
-				cause,			iei = NS_IEI_CAUSE;
-				max_num_nsvc,		iei = NS_IEI_MAX_NUM_NSVC;
-				num_ipv4_ep,		iei = NS_IEI_NUM_IPv4_EP;
-				num_ipv6_ep,		iei = NS_IEI_NUM_IPv6_EP;
-				nsvci,			iei = NS_IEI_NSVCI;
-				nsei,			iei = NS_IEI_NSEI;
-				other,			OTHERWISE)"
-		variant (len) "LENGTHTO(u)"
-	};
-
-	type record of NsTLV NsTLVs;
-
-	type record NsPduUnitdata {
-		NsSduControlBits	control_bits,
-		BssgpBvci		bvci,
-		octetstring		sdu
-	} with { variant "" };
-
-	type record NsPduOther {
-		NsTLVs		tlvs optional
-	} with { variant "" };
-
-	type union NsPduUnion {
-		NsPduUnitdata	unitdata,
-		NsPduOther	other
-	} with { variant "" };
-
-	type record NsPdu {
-		NsPduType	pdu_type,
-		NsPduUnion	u
-	} with { variant (u) "CROSSTAG(
-				unitdata,		pdu_type = NS_PDUT_NS_UNITDATA;
-				other,			OTHERWISE)"
-	};
-
-	external function enc_NsPdu(in NsPdu pdu) return octetstring
-		with { extension "prototype(convert) encode(RAW)" };
-	external function dec_NsPdu(in octetstring stream) return NsPdu
-		with { extension "prototype(convert) decode(RAW)" };
-
-
-
-	template NsTLV t_NS_IE_CAUSE(template NsCause cause) := {
-		iei := NS_IEI_CAUSE,
-		len := 1,
-		u := { cause := cause }
-	};
-
-	template NsTLV t_NS_IE_NSVCI(template Nsvci nsvci) := {
-		iei := NS_IEI_NSVCI,
-		len := 2,
-		u := { nsvci :=  nsvci }
-	}
-
-	template NsTLV t_NS_IE_NSEI(template Nsvci nsei) := {
-		iei := NS_IEI_NSEI,
-		len := 2,
-		u := { nsei := nsei }
-	}
-
-	template NsTLV t_NsIE(NsIEI iei, NsIeUnion u) := {
-		iei := iei,
-		u := u
-	}
-
-	template NsTLV t_NsIE_other(NsIEI iei, octetstring val) := {
-		iei := iei,
-		len := lengthof(val),
-		u := { other := val }
-	}
-
-	template NsPdu t_NS_RESET(template NsCause cause, template Nsvci nsvci, template Nsei nsei) := {
-		pdu_type := NS_PDUT_NS_RESET,
-		u := {
-			other := {
-				tlvs := { t_NS_IE_CAUSE(cause), t_NS_IE_NSVCI(nsvci), t_NS_IE_NSEI(nsei) }
-			}
-		}
-	};
-
-	template NsPdu t_NS_RESET_ACK(template Nsvci nsvci, template Nsei nsei) := {
-		pdu_type := NS_PDUT_NS_RESET_ACK,
-		u := {
-			other := {
-				tlvs := { t_NS_IE_NSVCI(nsvci), t_NS_IE_NSEI(nsei) }
-			}
-		}
-	};
-
-	template NsPdu t_NS_BLOCK(template NsCause cause, template Nsvci nsvci) := {
-		pdu_type := NS_PDUT_NS_BLOCK,
-		u := {
-			other := {
-				tlvs := { t_NS_IE_CAUSE(cause), t_NS_IE_NSVCI(nsvci) }
-			}
-		}
-	}
-
-	template NsPdu t_NS_BLOCK_ACK(template Nsvci nsvci) := {
-		pdu_type := NS_PDUT_NS_BLOCK_ACK,
-		u := {
-			other := {
-				tlvs := { t_NS_IE_NSVCI(nsvci) }
-			}
-		}
-	}
-
-	template NsPdu t_NsPduSimple(template NsPduType pdut) := { pdu_type := pdut, u := { other := { tlvs := omit } } };
-	template NsPdu t_NS_ALIVE := t_NsPduSimple(NS_PDUT_NS_ALIVE);
-	template NsPdu t_NS_ALIVE_ACK := t_NsPduSimple(NS_PDUT_NS_ALIVE_ACK);
-	template NsPdu t_NS_UNBLOCK := t_NsPduSimple(NS_PDUT_NS_UNBLOCK);
-	template NsPdu t_NS_UNBLOCK_ACK := t_NsPduSimple(NS_PDUT_NS_UNBLOCK_ACK);
-
-	template NsPdu t_NS_STATUS(NsCause cause, NsPdu pdu) := {
-		pdu_type := NS_PDUT_NS_STATUS,
-		u := {
-			other := {
-				tlvs := { t_NS_IE_CAUSE(cause), t_NsIE_other(NS_IEI_NS_PDU, f_NS_compact_len(enc_NsPdu(pdu))) }
-			}
-		}
-	}
-
-	template NsPdu t_NS_UNITDATA(template NsSduControlBits bits, template BssgpBvci bvci, template octetstring sdu) := {
-		pdu_type := NS_PDUT_NS_UNITDATA,
-		u := {
-			unitdata := {
-				control_bits := bits,
-				bvci := bvci,
-				sdu := sdu
-			}
-		}
-	}
-
-} with { encode "RAW" };
diff --git a/gprs_gb/gen_links.sh b/gprs_gb/gen_links.sh
index 2b56a2b..73ae3fa 100755
--- a/gprs_gb/gen_links.sh
+++ b/gprs_gb/gen_links.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 BASEDIR=../deps
 
@@ -32,5 +32,6 @@
 gen_links $DIR $FILES
 
 DIR=../library
-FILES="General_Types.ttcn GSM_Types.ttcn GSM_RR_Types.ttcn Osmocom_Types.ttcn RLCMAC_Types.ttcn RLCMAC_CSN1_Types.ttcn RLCMAC_EncDec.cc L1CTL_Types.ttcn L1CTL_PortType.ttcn LAPDm_RAW_PT.ttcn LAPDm_Types.ttcn"
+FILES="General_Types.ttcn GSM_Types.ttcn GSM_RR_Types.ttcn Osmocom_Types.ttcn RLCMAC_Types.ttcn RLCMAC_CSN1_Types.ttcn RLCMAC_EncDec.cc L1CTL_Types.ttcn L1CTL_PortType.ttcn LAPDm_RAW_PT.ttcn LAPDm_Types.ttcn "
+FILES+="NS_Types.ttcn NS_Emulation.ttcn NS_CodecPort.ttcn NS_CodecPort_CtrlFunct.ttcn NS_CodecPort_CtrlFunctDef.cc "
 gen_links $DIR $FILES