1 /* linux/caif_socket.h
2  * CAIF Definitions for CAIF socket and network layer
3  * Copyright (C) ST-Ericsson AB 2010
4  * Author:	 Sjur Brendeland/ sjur.brandeland@stericsson.com
5  * License terms: GNU General Public License (GPL) version 2
6  */
7 
8 #ifndef _LINUX_CAIF_SOCKET_H
9 #define _LINUX_CAIF_SOCKET_H
10 
11 #include <linux/types.h>
12 
13 #ifdef __KERNEL__
14 #include <linux/socket.h>
15 #else
16 #include <sys/socket.h>
17 #endif
18 
19 /**
20  * enum caif_link_selector -    Physical Link Selection.
21  * @CAIF_LINK_HIGH_BANDW:	Physical interface for high-bandwidth
22  *				traffic.
23  * @CAIF_LINK_LOW_LATENCY:	Physical interface for low-latency
24  *				traffic.
25  *
26  * CAIF Link Layers can register their link properties.
27  * This enum is used for choosing between CAIF Link Layers when
28  * setting up CAIF Channels when multiple CAIF Link Layers exists.
29  */
30 enum caif_link_selector {
31 	CAIF_LINK_HIGH_BANDW,
32 	CAIF_LINK_LOW_LATENCY
33 };
34 
35 /**
36  * enum caif_channel_priority - CAIF channel priorities.
37  *
38  * @CAIF_PRIO_MIN:	Min priority for a channel.
39  * @CAIF_PRIO_LOW:	Low-priority channel.
40  * @CAIF_PRIO_NORMAL:	Normal/default priority level.
41  * @CAIF_PRIO_HIGH:	High priority level
42  * @CAIF_PRIO_MAX:	Max priority for channel
43  *
44  * Priority can be set on CAIF Channels in order to
45  * prioritize between traffic on different CAIF Channels.
46  * These priority levels are recommended, but the priority value
47  * is not restricted to the values defined in this enum, any value
48  * between CAIF_PRIO_MIN and CAIF_PRIO_MAX could be used.
49  */
50 enum caif_channel_priority {
51 	CAIF_PRIO_MIN	 = 0x01,
52 	CAIF_PRIO_LOW	 = 0x04,
53 	CAIF_PRIO_NORMAL = 0x0f,
54 	CAIF_PRIO_HIGH	 = 0x14,
55 	CAIF_PRIO_MAX	 = 0x1F
56 };
57 
58 /**
59  * enum caif_protocol_type  -	CAIF Channel type.
60  * @CAIFPROTO_AT:		Classic AT channel.
61  * @CAIFPROTO_DATAGRAM:	Datagram channel.
62  * @CAIFPROTO_DATAGRAM_LOOP:	Datagram loopback channel, used for testing.
63  * @CAIFPROTO_UTIL:		Utility (Psock) channel.
64  * @CAIFPROTO_RFM:		Remote File Manager
65  * @CAIFPROTO_DEBUG:		Debug link
66  *
67  * This enum defines the CAIF Channel type to be used. This defines
68  * the service to connect to on the modem.
69  */
70 enum caif_protocol_type {
71 	CAIFPROTO_AT,
72 	CAIFPROTO_DATAGRAM,
73 	CAIFPROTO_DATAGRAM_LOOP,
74 	CAIFPROTO_UTIL,
75 	CAIFPROTO_RFM,
76 	CAIFPROTO_DEBUG,
77 	_CAIFPROTO_MAX
78 };
79 #define	CAIFPROTO_MAX _CAIFPROTO_MAX
80 
81 /**
82  * enum caif_at_type - AT Service Endpoint
83  * @CAIF_ATTYPE_PLAIN:	     Connects to a plain vanilla AT channel.
84  */
85 enum caif_at_type {
86 	CAIF_ATTYPE_PLAIN = 2
87 };
88  /**
89  * enum caif_debug_type - Content selection for debug connection
90  * @CAIF_DEBUG_TRACE_INTERACTIVE: Connection will contain
91  *				both trace and interactive debug.
92  * @CAIF_DEBUG_TRACE:		Connection contains trace only.
93  * @CAIF_DEBUG_INTERACTIVE:	Connection to interactive debug.
94  */
95 enum caif_debug_type {
96 	CAIF_DEBUG_TRACE_INTERACTIVE = 0,
97 	CAIF_DEBUG_TRACE,
98 	CAIF_DEBUG_INTERACTIVE,
99 };
100 
101 /**
102  * enum caif_debug_service - Debug Service Endpoint
103  * @CAIF_RADIO_DEBUG_SERVICE:	Debug service on the Radio sub-system
104  * @CAIF_APP_DEBUG_SERVICE:	Debug for the applications sub-system
105  */
106 enum caif_debug_service {
107 	CAIF_RADIO_DEBUG_SERVICE = 1,
108 	CAIF_APP_DEBUG_SERVICE
109 };
110 
111 /**
112  * struct sockaddr_caif - the sockaddr structure for CAIF sockets.
113  * @family:		     Address family number, must be AF_CAIF.
114  * @u:			     Union of address data 'switched' by family.
115  * :
116  * @u.at:                    Applies when family = CAIFPROTO_AT.
117  *
118  * @u.at.type:               Type of AT link to set up (enum caif_at_type).
119  *
120  * @u.util:                  Applies when family = CAIFPROTO_UTIL
121  *
122  * @u.util.service:          Utility service name.
123  *
124  * @u.dgm:                   Applies when family = CAIFPROTO_DATAGRAM
125  *
126  * @u.dgm.connection_id:     Datagram connection id.
127  *
128  * @u.dgm.nsapi:             NSAPI of the PDP-Context.
129  *
130  * @u.rfm:                   Applies when family = CAIFPROTO_RFM
131  *
132  * @u.rfm.connection_id:     Connection ID for RFM.
133  *
134  * @u.rfm.volume:            Volume to mount.
135  *
136  * @u.dbg:		      Applies when family = CAIFPROTO_DEBUG.
137  *
138  * @u.dbg.type:			     Type of debug connection to set up
139  *			      (caif_debug_type).
140  *
141  * @u.dbg.service:	      Service sub-system to connect (caif_debug_service
142  * Description:
143  * This structure holds the connect parameters used for setting up a
144  * CAIF Channel. It defines the service to connect to on the modem.
145  */
146 struct sockaddr_caif {
147 	sa_family_t  family;
148 	union {
149 		struct {
150 			__u8  type;		/* type: enum caif_at_type */
151 		} at;				/* CAIFPROTO_AT */
152 		struct {
153 			char	  service[16];
154 		} util;				/* CAIFPROTO_UTIL */
155 		union {
156 			__u32 connection_id;
157 			__u8  nsapi;
158 		} dgm;				/* CAIFPROTO_DATAGRAM(_LOOP)*/
159 		struct {
160 			__u32 connection_id;
161 			char	  volume[16];
162 		} rfm;				/* CAIFPROTO_RFM */
163 		struct {
164 			__u8  type;		/* type:enum caif_debug_type */
165 			__u8  service;		/* service:caif_debug_service */
166 		} dbg;				/* CAIFPROTO_DEBUG */
167 	} u;
168 };
169 
170 /**
171  * enum caif_socket_opts - CAIF option values for getsockopt and setsockopt.
172  *
173  * @CAIFSO_LINK_SELECT:		Selector used if multiple CAIF Link layers are
174  *				available. Either a high bandwidth
175  *				link can be selected (CAIF_LINK_HIGH_BANDW) or
176  *				or a low latency link (CAIF_LINK_LOW_LATENCY).
177  *                              This option is of type __u32.
178  *				Alternatively SO_BINDTODEVICE can be used.
179  *
180  * @CAIFSO_REQ_PARAM:		Used to set the request parameters for a
181  *				utility channel. (maximum 256 bytes). This
182  *				option must be set before connecting.
183  *
184  * @CAIFSO_RSP_PARAM:		Gets the response parameters for a utility
185  *				channel. (maximum 256 bytes). This option
186  *				is valid after a successful connect.
187  *
188  *
189  * This enum defines the CAIF Socket options to be used on a socket
190  * of type PF_CAIF.
191  *
192  */
193 enum caif_socket_opts {
194 	CAIFSO_LINK_SELECT	= 127,
195 	CAIFSO_REQ_PARAM	= 128,
196 	CAIFSO_RSP_PARAM	= 129,
197 };
198 
199 #endif /* _LINUX_CAIF_SOCKET_H */
200