1 // vim: noet sw=4 ts=4:
3 ==================================================================================
4 Copyright (c) 2020 Nokia
5 Copyright (c) 2020 AT&T Intellectual Property.
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
11 http://www.apache.org/licenses/LICENSE-2.0
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 ==================================================================================
22 ******************************************************************************
24 * Mnemonic: socket_if.h
25 * Abstract: Main set of definitions needed by the SI native functions and
27 * Date: 26 March 1995 (original)
28 * 3 January 2020 (revised)
29 * Author: E. Scott Daniels
31 *****************************************************************************
37 #define TCP_DEVICE 0 // device type of socket
40 // these are for SIclose, must be negative so as to be distinguished from real fd values
41 #define TCP_LISTEN_PORT (-1) // close first listen port found
42 #define UDP_PORT (-2) // close first udp port found
44 #define SI_BAD_HANDLE ((void *) 0)
46 #define SI_OPT_NONE 0 // initialisation options
47 #define SI_OPT_FORK 0x01 // fork new sessions
48 #define SI_OPT_FG 0x02 // keep process in the "foreground"
49 #define SI_OPT_TTY 0x04 // processes keyboard interrupts if fg
50 #define SI_OPT_ALRM 0x08 // cause setsig to be called with alarm flg
52 // offsets of callbacks in table
53 // used to indentify cb in SIcbreg
54 #define SI_CB_SIGNAL 0 // usr signal/alarm received
55 #define SI_CB_RDATA 1 // handles data arrival on raw interface
56 #define SI_CB_CDATA 2 // handles data arrival on cooked interface
57 #define SI_CB_KDATA 3 // handles data arrival from keyboard
58 #define SI_CB_SECURITY 4 // authorizes acceptance of a conect req
59 #define SI_CB_CONN 5 // called when a session is accepted
60 #define SI_CB_DISC 6 // called when a session is lost
63 // return values callbacks are expected to produce
64 #define SI_RET_OK 0 // processing ok -- continue
65 #define SI_RET_ERROR (-1) // processing not ok -- reject/disallow
66 #define SI_RET_UNREG 1 // unregester (never call again) the cb
67 #define SI_RET_QUIT 2 // set the shutdown flag and terminate the SI environment
69 // values returned to user by SI routines
70 #define SI_ERROR (-1) // unable to process
71 #define SI_OK 0 // processing completed successfully
72 #define SI_QUEUED 1 // send messages was queued
74 // flags passed to signal callback
75 #define SI_SF_QUIT 0x01 // program should terminate
76 #define SI_SF_USR1 0x02 // user 1 signal received
77 #define SI_SF_USR2 0x04 // user 2 signal received
78 #define SI_SF_ALRM 0x08 // alarm clock signal received
80 // signal bitmasks for the setsig routine
81 #define SI_SIG_QUIT 0x01 // please catch quit signal
82 #define SI_SIG_HUP 0x02 // catch hangup signal
83 #define SI_SIG_TERM 0x04 // catch the term signal
84 #define SI_SIG_USR1 0x08 // catch user signals
85 #define SI_SIG_USR2 0x10
86 #define SI_SIG_ALRM 0x20 // catch alarm signals
87 #define SI_DEF_SIGS 0x1F // default signals to catch
89 // SIerrno values set in public rtns
90 #define SI_ERR_NONE 0 // no error as far as we can tell
91 #define SI_ERR_QUEUED 1 // must be same as queued
92 #define SI_ERR_TPORT 2 // could not bind to requested tcp port
93 #define SI_ERR_UPORT 3 // could not bind to requested udp port
94 #define SI_ERR_FORK 4 // could not fork to become daemon
95 #define SI_ERR_HANDLE 5 // global information pointer went off
96 #define SI_ERR_SESSID 6 // invalid session id
97 #define SI_ERR_TP 7 // error occured in transport provider
98 #define SI_ERR_SHUTD 8 // cannot process because in shutdown mode
99 #define SI_ERR_NOFDS 9 // no file descriptors are open
100 #define SI_ERR_SIGUSR1 10 // signal received data not read
101 #define SI_ERR_SIGUSR2 11 // signal received data not read
102 #define SI_ERR_DISC 12 // session disconnected
103 #define SI_ERR_TIMEOUT 13 // poll attempt timed out - no data
104 #define SI_ERR_ORDREL 14 // orderly release received
105 #define SI_ERR_SIGALRM 15 // alarm signal received
106 #define SI_ERR_NOMEM 16 // could not allocate needed memory
107 #define SI_ERR_ADDR 17 // address conversion failed
108 #define SI_ERR_BLOCKED 18 // operation would block
110 #define SI_TF_NONE 0 // tcp flags in the global info applied to each session
111 #define SI_TF_NODELAY 0x01 // set nagle's off for each connection
112 #define SI_TF_FASTACK 0x02 // set fast ack on for each connection
115 extern int SIerrno; // error number set by public routines
119 typedef struct ginfo_blk si_ctx_t; // generic context reference for users