Add SI95 transport support
[ric-plt/lib/rmr.git] / src / rmr / si / src / si95 / socket_if.h
1 // vim: noet sw=4 ts=4:
2 /*
3 ==================================================================================
4     Copyright (c) 2020 Nokia
5     Copyright (c) 2020 AT&T Intellectual Property.
6
7    Licensed under the Apache License, Version 2.0 (the "License");
8    you may not use this file except in compliance with the License.
9    You may obtain a copy of the License at
10
11        http://www.apache.org/licenses/LICENSE-2.0
12
13    Unless required by applicable law or agreed to in writing, software
14    distributed under the License is distributed on an "AS IS" BASIS,
15    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16    See the License for the specific language governing permissions and
17    limitations under the License.
18 ==================================================================================
19 */
20
21 /*
22 ******************************************************************************
23 *
24 *  Mnemonic:    socket_if.h
25 *  Abstract:    Main set of definitions needed by the SI native functions and
26 *                               any user code.
27 *  Date:            26 March 1995       (original) 
28 *                               3 January 2020  (revised)
29 *  Author:              E. Scott Daniels
30 *
31 *****************************************************************************
32 */
33
34 #ifndef _SOCKET_IF_H
35 #define _SOCKET_IF_H
36
37 #ifndef PARINOID_CHECKS
38 #       define PARINOID_CHECKS 1
39 #endif
40
41 #define TCP_DEVICE      0       //  device type of socket 
42 #define UDP_DEVICE      1       
43
44 //  these are for SIclose, must be negative so as to be distinguished from real fd values 
45 #define TCP_LISTEN_PORT (-1)    //  close first listen port found 
46 #define UDP_PORT        (-2)    //  close first udp port found 
47
48 #define SI_BAD_HANDLE  ((void *) 0)
49
50 #define SI_OPT_NONE             0               // initialisation options
51 #define SI_OPT_FORK    0x01      //  fork new sessions
52 #define SI_OPT_FG      0x02      //  keep process in the "foreground" 
53 #define SI_OPT_TTY     0x04      //  processes keyboard interrupts if fg 
54 #define SI_OPT_ALRM    0x08      //  cause setsig to be called with alarm flg 
55
56                                  //  offsets of callbacks in table 
57                                  //  used to indentify cb in SIcbreg 
58 #define SI_CB_SIGNAL   0         //  usr signal/alarm received 
59 #define SI_CB_RDATA    1         //  handles data arrival on raw interface 
60 #define SI_CB_CDATA    2         //  handles data arrival on cooked interface 
61 #define SI_CB_KDATA    3         //  handles data arrival from keyboard 
62 #define SI_CB_SECURITY 4         //  authorizes acceptance of a conect req 
63 #define SI_CB_CONN     5         //  called when a session is accepted 
64 #define SI_CB_DISC     6         //  called when a session is lost 
65 #define SI_CB_POLL     7
66
67                                  //  return values callbacks are expected to produce
68 #define SI_RET_OK      0         //  processing ok -- continue
69 #define SI_RET_ERROR   (-1)      //  processing not ok -- reject/disallow
70 #define SI_RET_UNREG   1         //  unregester (never call again) the cb 
71 #define SI_RET_QUIT    2         //  set the shutdown flag  and terminate the SI environment
72
73                                  //  values returned to user by SI routines 
74 #define SI_ERROR       (-1)      //  unable to process 
75 #define SI_OK          0         //  processing completed successfully 
76 #define SI_QUEUED      1         //  send messages was queued 
77
78                                   //  flags passed to signal callback 
79 #define SI_SF_QUIT     0x01      //  program should terminate 
80 #define SI_SF_USR1     0x02      //  user 1 signal received 
81 #define SI_SF_USR2     0x04      //  user 2 signal received 
82 #define SI_SF_ALRM     0x08      //  alarm clock signal received 
83
84                                  //  signal bitmasks for the setsig routine 
85 #define SI_SIG_QUIT    0x01      //  please catch quit signal 
86 #define SI_SIG_HUP     0x02      //  catch hangup signal 
87 #define SI_SIG_TERM    0x04      //  catch the term signal 
88 #define SI_SIG_USR1    0x08      //  catch user signals 
89 #define SI_SIG_USR2    0x10
90 #define SI_SIG_ALRM    0x20      //  catch alarm signals 
91 #define SI_DEF_SIGS    0x1F      //  default signals to catch 
92
93                                  //  SIerrno values set in public rtns 
94 #define SI_ERR_NONE     0        //  no error as far as we can tell 
95 #define SI_ERR_QUEUED   1       //  must be same as queued 
96 #define SI_ERR_TPORT    2        //  could not bind to requested tcp port 
97 #define SI_ERR_UPORT    3        //  could not bind to requested udp port 
98 #define SI_ERR_FORK     4        //  could not fork to become daemon 
99 #define SI_ERR_HANDLE   5        //  global information pointer went off 
100 #define SI_ERR_SESSID   6        //  invalid session id 
101 #define SI_ERR_TP       7        //  error occured in transport provider 
102 #define SI_ERR_SHUTD    8        //  cannot process because in shutdown mode 
103 #define SI_ERR_NOFDS    9        //  no file descriptors are open 
104 #define SI_ERR_SIGUSR1  10       //  signal received data not read 
105 #define SI_ERR_SIGUSR2  11       //  signal received data not read 
106 #define SI_ERR_DISC     12       //  session disconnected 
107 #define SI_ERR_TIMEOUT  13       //  poll attempt timed out - no data 
108 #define SI_ERR_ORDREL   14       //  orderly release received 
109 #define SI_ERR_SIGALRM  15       //  alarm signal received 
110 #define SI_ERR_NOMEM    16       //  could not allocate needed memory 
111 #define SI_ERR_ADDR     17       //  address conversion failed 
112 #define SI_ERR_BLOCKED  18              // operation would block
113
114 #define SI_TF_NONE              0               // tcp flags in the global info applied to each session
115 #define SI_TF_NODELAY   0x01    // set nagle's off for each connection
116 #define SI_TF_FASTACK   0x02    // set fast ack on for each connection
117
118 #ifndef _SI_ERRNO
119 extern int SIerrno;               //  error number set by public routines 
120 #define _SI_ERRNO
121 #endif
122
123 typedef struct ginfo_blk si_ctx_t;              // generic context reference for users
124
125 #endif