add basic unixsocket support

Allow to connect to a unix socket for communicating with LAPD.

Change-Id: Ia5723b09a5c68a0505829dc732def981e60a907a
diff --git a/include/Makefile.am b/include/Makefile.am
index 16fa506..2048520 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -3,4 +3,5 @@
 nobase_include_HEADERS = osmocom/abis/ipa.h osmocom/abis/trau_frame.h	\
  osmocom/abis/ipa_proxy.h osmocom/abis/ipaccess.h osmocom/abis/abis.h	\
  osmocom/abis/subchan_demux.h osmocom/abis/e1_input.h			\
- osmocom/abis/lapd.h osmocom/abis/lapd_pcap.h osmocom/trau/osmo_ortp.h
+ osmocom/abis/lapd.h osmocom/abis/lapd_pcap.h osmocom/trau/osmo_ortp.h	\
+ osmocom/abis/unixsocket_proto.h
diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h
index 4c7f8a0..8501d5c 100644
--- a/include/osmocom/abis/e1_input.h
+++ b/include/osmocom/abis/e1_input.h
@@ -183,6 +183,7 @@
 	unsigned int num;
 	const char *name;
 	unsigned int port_nr;
+	char *sock_path;
 	struct rate_ctr_group *rate_ctr;
 
 	/* keepalive configuration */
@@ -303,6 +304,9 @@
 struct gsm_network;
 int ipaccess_setup(struct gsm_network *gsmnet);
 
+/* activate superchannel or deactive to use timeslots. only valid for unixsocket driver */
+void e1inp_ericsson_set_altc(struct e1inp_line *unixlinue, int superchannel);
+
 extern struct llist_head e1inp_driver_list;
 extern struct llist_head e1inp_line_list;
 
diff --git a/include/osmocom/abis/unixsocket_proto.h b/include/osmocom/abis/unixsocket_proto.h
new file mode 100644
index 0000000..25718ff
--- /dev/null
+++ b/include/osmocom/abis/unixsocket_proto.h
@@ -0,0 +1,31 @@
+
+#ifndef UNIXSOCKET_PROTO_H
+#define UNIXSOCKET_PROTO_H
+
+/* The unix socket protocol is using a 2 byte header
+ * containg the version and type.
+ *
+ * header: | 1b version | 1b type |
+ *
+ * for data packets it would be
+ *
+ * data:    | 0x1 | 0x0 | lapd ..|
+ * control: | 0x1 | 0x1 | control payload |
+ *
+ * Atm there is only one control packet:
+ *  - set_altc (superchannel or timeslot)
+ *
+ * set_altc payload:
+ *  | 4b magic   | 1b new_state|
+ *  | 0x23004200 | 0x0         | to timeslot
+ *  | 0x23004200 | 0x1         | to superchannel
+ */
+
+#define UNIXSOCKET_PROTO_VERSION 0x1
+
+enum {
+	UNIXSOCKET_PROTO_DATA = 0x0,
+	UNIXSOCKET_PROTO_CONTROL = 0x1,
+};
+
+#endif /* UNIXSOCKET_PROTO_H */