| 1 | #ifndef __DIMDEFS
|
|---|
| 2 | #define __DIMDEFS
|
|---|
| 3 | /*
|
|---|
| 4 | * DNA (Delphi Network Access) implements the network layer for the DIM
|
|---|
| 5 | * (Delphi Information Managment) System.
|
|---|
| 6 | *
|
|---|
| 7 | * Started : 10-11-91
|
|---|
| 8 | * Last modification : 03-08-94
|
|---|
| 9 | * Written by : C. Gaspar
|
|---|
| 10 | * Adjusted by : G.C. Ballintijn
|
|---|
| 11 | *
|
|---|
| 12 | */
|
|---|
| 13 |
|
|---|
| 14 | #include "dim_common.h"
|
|---|
| 15 |
|
|---|
| 16 | #define DIM_VERSION_NUMBER 1919
|
|---|
| 17 |
|
|---|
| 18 | #define MY_LITTLE_ENDIAN 0x1
|
|---|
| 19 | #define MY_BIG_ENDIAN 0x2
|
|---|
| 20 |
|
|---|
| 21 | #define VAX_FLOAT 0x10
|
|---|
| 22 | #define IEEE_FLOAT 0x20
|
|---|
| 23 | #define AXP_FLOAT 0x30
|
|---|
| 24 |
|
|---|
| 25 | #define MY_OS9 0x100
|
|---|
| 26 | #define IT_IS_FLOAT 0x1000
|
|---|
| 27 |
|
|---|
| 28 | #ifdef VMS
|
|---|
| 29 | #include <ssdef.h>
|
|---|
| 30 | #include <stdio.h>
|
|---|
| 31 | #include <stdlib.h>
|
|---|
| 32 | #include <string.h>
|
|---|
| 33 | #include <starlet.h>
|
|---|
| 34 | #include <time.h>
|
|---|
| 35 | #define DIM_NOSHARE noshare
|
|---|
| 36 | #define RE_ENABLE_AST long int ast_enable = sys$setast(1);
|
|---|
| 37 | #define RE_DISABLE_AST if (ast_enable != SS$_WASSET) sys$setast(0);
|
|---|
| 38 | #define vtohl(l) (l)
|
|---|
| 39 | #define htovl(l) (l)
|
|---|
| 40 | #ifdef __alpha
|
|---|
| 41 | #define MY_FORMAT MY_LITTLE_ENDIAN+AXP_FLOAT
|
|---|
| 42 | #else
|
|---|
| 43 | #define MY_FORMAT MY_LITTLE_ENDIAN+VAX_FLOAT
|
|---|
| 44 | #endif
|
|---|
| 45 | #endif
|
|---|
| 46 |
|
|---|
| 47 | #ifdef __unix__
|
|---|
| 48 | #include <unistd.h>
|
|---|
| 49 | #include <sys/time.h>
|
|---|
| 50 | #include <sys/types.h>
|
|---|
| 51 | #include <netinet/in.h>
|
|---|
| 52 | #include <stdio.h>
|
|---|
| 53 | #include <stdlib.h>
|
|---|
| 54 | #include <string.h>
|
|---|
| 55 | #include <signal.h>
|
|---|
| 56 | #ifdef VxWorks
|
|---|
| 57 | #include <sigLib.h>
|
|---|
| 58 | #endif
|
|---|
| 59 | #define DIM_NOSHARE
|
|---|
| 60 | #define RE_ENABLE_AST sigset_t set, oset;sigemptyset(&set);sigaddset(&set,SIGIO);sigaddset(&set,SIGALRM);sigprocmask(SIG_UNBLOCK,&set,&oset);
|
|---|
| 61 | #define RE_DISABLE_AST sigprocmask(SIG_SETMASK,&oset,0);
|
|---|
| 62 | #ifdef MIPSEL
|
|---|
| 63 | #define vtohl(l) (l)
|
|---|
| 64 | #define htovl(l) (l)
|
|---|
| 65 | #define MY_FORMAT MY_LITTLE_ENDIAN+IEEE_FLOAT
|
|---|
| 66 | #endif
|
|---|
| 67 | #ifdef MIPSEB
|
|---|
| 68 | #define vtohl(l) _swapl(l)
|
|---|
| 69 | #define htovl(l) _swapl(l)
|
|---|
| 70 | #define vtohs(s) _swaps(s)
|
|---|
| 71 | #define htovs(s) _swaps(s)
|
|---|
| 72 | #define MY_FORMAT MY_BIG_ENDIAN+IEEE_FLOAT
|
|---|
| 73 | #endif
|
|---|
| 74 | _DIM_PROTO( int _swapl, (int l) );
|
|---|
| 75 | _DIM_PROTO( short _swaps, (short s) );
|
|---|
| 76 |
|
|---|
| 77 | #endif
|
|---|
| 78 |
|
|---|
| 79 | #ifdef WIN32
|
|---|
| 80 | #include <windows.h>
|
|---|
| 81 | #include <process.h>
|
|---|
| 82 | #include <io.h>
|
|---|
| 83 | #include <fcntl.h>
|
|---|
| 84 | #include <Winsock.h>
|
|---|
| 85 | #include <stddef.h>
|
|---|
| 86 | #include <stdlib.h>
|
|---|
| 87 | #include <stdio.h>
|
|---|
| 88 | #define DIM_NOSHARE
|
|---|
| 89 | #define RE_ENABLE_AST
|
|---|
| 90 | #define RE_DISABLE_AST
|
|---|
| 91 | #ifdef MIPSEL
|
|---|
| 92 | #define vtohl(l) (l)
|
|---|
| 93 | #define htovl(l) (l)
|
|---|
| 94 | #define MY_FORMAT MY_LITTLE_ENDIAN+IEEE_FLOAT
|
|---|
| 95 | #endif
|
|---|
| 96 | #ifdef MIPSEB
|
|---|
| 97 | #define vtohl(l) _swapl(l)
|
|---|
| 98 | #define htovl(l) _swapl(l)
|
|---|
| 99 | #define vtohs(s) _swaps(s)
|
|---|
| 100 | #define htovs(s) _swaps(s)
|
|---|
| 101 | #define MY_FORMAT MY_BIG_ENDIAN+IEEE_FLOAT
|
|---|
| 102 | #endif
|
|---|
| 103 | _DIM_PROTO( int _swapl, (int l) );
|
|---|
| 104 | _DIM_PROTO( short _swaps, (short s) );
|
|---|
| 105 | #endif
|
|---|
| 106 |
|
|---|
| 107 | #ifdef OSK
|
|---|
| 108 | #include <types.h>
|
|---|
| 109 | #ifndef _UCC
|
|---|
| 110 | #include <machine/types.h>
|
|---|
| 111 | #else
|
|---|
| 112 | #define register
|
|---|
| 113 | #endif
|
|---|
| 114 | #include <inet/in.h>
|
|---|
| 115 | #include <time.h>
|
|---|
| 116 | #include <stdio.h>
|
|---|
| 117 | #include <string.h>
|
|---|
| 118 | #define DIM_NOSHARE
|
|---|
| 119 | #define RE_ENABLE_AST sigmask(DEC_LEVEL);
|
|---|
| 120 | #define RE_DISABLE_AST sigmask(INC_LEVEL);
|
|---|
| 121 | #define vtohl(l) _swapl(l)
|
|---|
| 122 | #define htovl(l) _swapl(l)
|
|---|
| 123 | #define vtohs(s) _swaps(s)
|
|---|
| 124 | #define htovs(s) _swaps(s)
|
|---|
| 125 | #define MY_FORMAT MY_BIG_ENDIAN+IEEE_FLOAT+MY_OS9
|
|---|
| 126 | typedef unsigned short ushort;
|
|---|
| 127 | _DIM_PROTO( char *getenv, (char *name) );
|
|---|
| 128 | _DIM_PROTO( void *malloc, (unsigned size) );
|
|---|
| 129 | _DIM_PROTO( void *realloc, (void *ptr, unsigned size) );
|
|---|
| 130 | _DIM_PROTO( int _swapl, (int l) );
|
|---|
| 131 | _DIM_PROTO( short _swaps, (short s) );
|
|---|
| 132 | #endif
|
|---|
| 133 |
|
|---|
| 134 | #define TRUE 1
|
|---|
| 135 | #define FALSE 0
|
|---|
| 136 |
|
|---|
| 137 | #define DNS_TASK "DIM_DNS"
|
|---|
| 138 | #define DNS_PORT 2505 /* Name server port */
|
|---|
| 139 | #define SEEK_PORT 0 /* server should seek a port */
|
|---|
| 140 |
|
|---|
| 141 | #define MIN_BIOCNT 50
|
|---|
| 142 | #ifdef OSK
|
|---|
| 143 | #define DIS_DNS_TMOUT_MIN 5
|
|---|
| 144 | #define DIS_DNS_TMOUT_MAX 10
|
|---|
| 145 | #define DIC_DNS_TMOUT_MIN 5
|
|---|
| 146 | #define DIC_DNS_TMOUT_MAX 10
|
|---|
| 147 | #define MAX_SERVICE_UNIT 32
|
|---|
| 148 | #define MAX_REGISTRATION_UNIT 100
|
|---|
| 149 | #define CONN_BLOCK 32
|
|---|
| 150 | #define MAX_CONNS 32
|
|---|
| 151 | #define ID_BLOCK 64
|
|---|
| 152 | #define TCP_RCV_BUF_SIZE 4096
|
|---|
| 153 | #define TCP_SND_BUF_SIZE 4096
|
|---|
| 154 | #else
|
|---|
| 155 | #define DIS_DNS_TMOUT_MIN 5
|
|---|
| 156 | #define DIS_DNS_TMOUT_MAX 10
|
|---|
| 157 | #define DIC_DNS_TMOUT_MIN 5
|
|---|
| 158 | #define DIC_DNS_TMOUT_MAX 10
|
|---|
| 159 | #define MAX_SERVICE_UNIT 100
|
|---|
| 160 | #define MAX_REGISTRATION_UNIT 100
|
|---|
| 161 | #define CONN_BLOCK 256
|
|---|
| 162 | #define MAX_CONNS 1024
|
|---|
| 163 | #define ID_BLOCK 512
|
|---|
| 164 | #define TCP_RCV_BUF_SIZE 16384/*32768*//*65536*/
|
|---|
| 165 | #define TCP_SND_BUF_SIZE 16384/*32768*//*65536*/
|
|---|
| 166 | #endif
|
|---|
| 167 | #define DID_DNS_TMOUT_MIN 5
|
|---|
| 168 | #define DID_DNS_TMOUT_MAX 10
|
|---|
| 169 | /*
|
|---|
| 170 | #define WATCHDOG_TMOUT_MIN 120
|
|---|
| 171 | #define WATCHDOG_TMOUT_MAX 180
|
|---|
| 172 | */
|
|---|
| 173 | #define WATCHDOG_TMOUT_MIN 60
|
|---|
| 174 | #define WATCHDOG_TMOUT_MAX 90
|
|---|
| 175 | /*
|
|---|
| 176 | #define WATCHDOG_TMOUT_MIN 15
|
|---|
| 177 | #define WATCHDOG_TMOUT_MAX 25
|
|---|
| 178 | */
|
|---|
| 179 | #define MAX_NODE_NAME 40
|
|---|
| 180 | #define MAX_TASK_NAME 40
|
|---|
| 181 | #define MAX_NAME 132
|
|---|
| 182 | /*
|
|---|
| 183 | #define MAX_CMND 16384
|
|---|
| 184 | #define MAX_IO_DATA 65535
|
|---|
| 185 | #define MAX_IO_DATA (TCP_SND_BUF_SIZE - 16)
|
|---|
| 186 | */
|
|---|
| 187 | typedef enum { DNS_DIS_REGISTER, DNS_DIS_KILL, DNS_DIS_STOP,
|
|---|
| 188 | DNS_DIS_EXIT } DNS_DIS_TYPES;
|
|---|
| 189 | typedef enum { RD_HDR, RD_DATA, RD_DUMMY } CONN_STATE;
|
|---|
| 190 | typedef enum { NOSWAP, SWAPS, SWAPL, SWAPD} SWAP_TYPE;
|
|---|
| 191 |
|
|---|
| 192 | #define DECNET 0 /* Decnet as transport layer */
|
|---|
| 193 | #define TCPIP 1 /* Tcpip as transport layer */
|
|---|
| 194 | #define BOTH 2 /* Both protocols allowed */
|
|---|
| 195 |
|
|---|
| 196 | #define STA_DISC (-1) /* Connection lost */
|
|---|
| 197 | #define STA_DATA 0 /* Data received */
|
|---|
| 198 | #define STA_CONN 1 /* Connection made */
|
|---|
| 199 |
|
|---|
| 200 | #define START_PORT_RANGE 5100 /* Lowest port to use */
|
|---|
| 201 | #define STOP_PORT_RANGE 10000 /* Highest port to use */
|
|---|
| 202 | #define TEST_TIME_OSK 15 /* Interval to test conn. */
|
|---|
| 203 | #define TEST_TIME_VMS 30 /* Interval to test conn. */
|
|---|
| 204 | #define TEST_WRITE_TAG 25 /* DTQ tag for test writes */
|
|---|
| 205 |
|
|---|
| 206 | #define OPN_MAGIC 0xc0dec0de /* Magic value 1st packet */
|
|---|
| 207 | #define HDR_MAGIC 0xfeadfead /* Magic value in header */
|
|---|
| 208 | #define LONG_HDR_MAGIC 0xfeadc0de /* Magic value in long header*/
|
|---|
| 209 | #define TST_MAGIC 0x11131517 /* Magic value, test write */
|
|---|
| 210 | #define TRP_MAGIC 0x71513111 /* Magic value, test reply */
|
|---|
| 211 |
|
|---|
| 212 | /* String Format */
|
|---|
| 213 |
|
|---|
| 214 | typedef struct{
|
|---|
| 215 | int par_num;
|
|---|
| 216 | short par_bytes;
|
|---|
| 217 | short flags; /* bits 0-1 is type of swap, bit 4 id float conversion */
|
|---|
| 218 | }FORMAT_STR;
|
|---|
| 219 |
|
|---|
| 220 | /* Packet sent by the client to the server inside DNA */
|
|---|
| 221 | typedef struct{
|
|---|
| 222 | int code;
|
|---|
| 223 | char node[MAX_NODE_NAME];
|
|---|
| 224 | char task[MAX_TASK_NAME];
|
|---|
| 225 | } DNA_NET;
|
|---|
| 226 |
|
|---|
| 227 | /* Packet sent by the client to the server */
|
|---|
| 228 | typedef struct{
|
|---|
| 229 | int size;
|
|---|
| 230 | char service_name[MAX_NAME];
|
|---|
| 231 | int service_id;
|
|---|
| 232 | int type;
|
|---|
| 233 | int timeout;
|
|---|
| 234 | int format;
|
|---|
| 235 | int buffer[1];
|
|---|
| 236 | } DIC_PACKET;
|
|---|
| 237 |
|
|---|
| 238 | #define DIC_HEADER (MAX_NAME + 20)
|
|---|
| 239 |
|
|---|
| 240 | /* Packets sent by the server to the client */
|
|---|
| 241 | typedef struct{
|
|---|
| 242 | int size;
|
|---|
| 243 | int service_id;
|
|---|
| 244 | int buffer[1];
|
|---|
| 245 | } DIS_PACKET;
|
|---|
| 246 |
|
|---|
| 247 | #define DIS_HEADER 8
|
|---|
| 248 |
|
|---|
| 249 | typedef struct{
|
|---|
| 250 | int size;
|
|---|
| 251 | int service_id;
|
|---|
| 252 | int time_stamp[2];
|
|---|
| 253 | int quality;
|
|---|
| 254 | int reserved[3];
|
|---|
| 255 | int buffer[1];
|
|---|
| 256 | } DIS_STAMPED_PACKET;
|
|---|
| 257 |
|
|---|
| 258 | #define DIS_STAMPED_HEADER 32
|
|---|
| 259 |
|
|---|
| 260 | /* Packet sent by the server to the name_server */
|
|---|
| 261 | typedef struct{
|
|---|
| 262 | char service_name[MAX_NAME];
|
|---|
| 263 | int service_id;
|
|---|
| 264 | char service_def[MAX_NAME];
|
|---|
| 265 | } SERVICE_REG;
|
|---|
| 266 |
|
|---|
| 267 | typedef struct{
|
|---|
| 268 | int size;
|
|---|
| 269 | SRC_TYPES src_type;
|
|---|
| 270 | char node_name[MAX_NODE_NAME];
|
|---|
| 271 | char task_name[MAX_TASK_NAME-4];
|
|---|
| 272 | char node_addr[4];
|
|---|
| 273 | int pid;
|
|---|
| 274 | int port;
|
|---|
| 275 | int protocol;
|
|---|
| 276 | int format;
|
|---|
| 277 | int n_services;
|
|---|
| 278 | SERVICE_REG services[MAX_SERVICE_UNIT];
|
|---|
| 279 | } DIS_DNS_PACKET;
|
|---|
| 280 |
|
|---|
| 281 | #define DIS_DNS_HEADER (MAX_NODE_NAME + MAX_TASK_NAME + 28)
|
|---|
| 282 |
|
|---|
| 283 | /* Packet sent by the name_server to the server */
|
|---|
| 284 | typedef struct {
|
|---|
| 285 | int size;
|
|---|
| 286 | int type;
|
|---|
| 287 | } DNS_DIS_PACKET;
|
|---|
| 288 |
|
|---|
| 289 | #define DNS_DIS_HEADER 8
|
|---|
| 290 |
|
|---|
| 291 | /* Packet sent by the client to the name_server */
|
|---|
| 292 | typedef struct{
|
|---|
| 293 | char service_name[MAX_NAME];
|
|---|
| 294 | int service_id;
|
|---|
| 295 | } SERVICE_REQ;
|
|---|
| 296 |
|
|---|
| 297 | typedef struct{
|
|---|
| 298 | int size;
|
|---|
| 299 | SRC_TYPES src_type;
|
|---|
| 300 | SERVICE_REQ service;
|
|---|
| 301 | } DIC_DNS_PACKET;
|
|---|
| 302 |
|
|---|
| 303 | /* Packet sent by the name_server to the client */
|
|---|
| 304 | typedef struct {
|
|---|
| 305 | int size;
|
|---|
| 306 | int service_id;
|
|---|
| 307 | char service_def[MAX_NAME];
|
|---|
| 308 | char node_name[MAX_NODE_NAME];
|
|---|
| 309 | char task_name[MAX_TASK_NAME-4];
|
|---|
| 310 | char node_addr[4];
|
|---|
| 311 | int pid;
|
|---|
| 312 | int port;
|
|---|
| 313 | int protocol;
|
|---|
| 314 | int format;
|
|---|
| 315 | } DNS_DIC_PACKET;
|
|---|
| 316 |
|
|---|
| 317 | #define DNS_DIC_HEADER (MAX_NODE_NAME + MAX_TASK_NAME + MAX_NAME + 24)
|
|---|
| 318 |
|
|---|
| 319 | typedef struct {
|
|---|
| 320 | char name[MAX_NAME];
|
|---|
| 321 | char node[MAX_NODE_NAME];
|
|---|
| 322 | char task[MAX_TASK_NAME];
|
|---|
| 323 | int type;
|
|---|
| 324 | int status;
|
|---|
| 325 | int n_clients;
|
|---|
| 326 | } DNS_SERV_INFO;
|
|---|
| 327 |
|
|---|
| 328 | typedef struct {
|
|---|
| 329 | char name[MAX_NAME];
|
|---|
| 330 | int type;
|
|---|
| 331 | int status;
|
|---|
| 332 | int n_clients;
|
|---|
| 333 | } DNS_SERVICE_INFO;
|
|---|
| 334 |
|
|---|
| 335 | typedef struct {
|
|---|
| 336 | char node[MAX_NODE_NAME];
|
|---|
| 337 | char task[MAX_TASK_NAME];
|
|---|
| 338 | int pid;
|
|---|
| 339 | int n_services;
|
|---|
| 340 | } DNS_SERVER_INFO;
|
|---|
| 341 |
|
|---|
| 342 | typedef struct {
|
|---|
| 343 | DNS_SERVER_INFO server;
|
|---|
| 344 | DNS_SERVICE_INFO services[1];
|
|---|
| 345 | } DNS_DID;
|
|---|
| 346 |
|
|---|
| 347 | typedef struct {
|
|---|
| 348 | char node[MAX_NODE_NAME];
|
|---|
| 349 | char task[MAX_TASK_NAME];
|
|---|
| 350 | } DNS_CLIENT_INFO;
|
|---|
| 351 |
|
|---|
| 352 | typedef struct {
|
|---|
| 353 | int header_size;
|
|---|
| 354 | int data_size;
|
|---|
| 355 | int header_magic;
|
|---|
| 356 | } DNA_HEADER;
|
|---|
| 357 |
|
|---|
| 358 | typedef struct {
|
|---|
| 359 | int header_size;
|
|---|
| 360 | int data_size;
|
|---|
| 361 | int header_magic;
|
|---|
| 362 | int time_stamp[2];
|
|---|
| 363 | int quality;
|
|---|
| 364 | } DNA_LONG_HEADER;
|
|---|
| 365 |
|
|---|
| 366 | /* Connection handling */
|
|---|
| 367 |
|
|---|
| 368 | typedef struct timer_entry{
|
|---|
| 369 | struct timer_entry *next;
|
|---|
| 370 | struct timer_entry *prev;
|
|---|
| 371 | struct timer_entry *next_done;
|
|---|
| 372 | int time;
|
|---|
| 373 | int time_left;
|
|---|
| 374 | void (*user_routine)();
|
|---|
| 375 | long tag;
|
|---|
| 376 | } TIMR_ENT;
|
|---|
| 377 |
|
|---|
| 378 | typedef struct {
|
|---|
| 379 | int busy;
|
|---|
| 380 | void (*read_ast)();
|
|---|
| 381 | void (*error_ast)();
|
|---|
| 382 | int *buffer;
|
|---|
| 383 | int buffer_size;
|
|---|
| 384 | char *curr_buffer;
|
|---|
| 385 | int curr_size;
|
|---|
| 386 | int full_size;
|
|---|
| 387 | int protocol;
|
|---|
| 388 | CONN_STATE state;
|
|---|
| 389 | int writing;
|
|---|
| 390 | int saw_init;
|
|---|
| 391 | } DNA_CONNECTION;
|
|---|
| 392 |
|
|---|
| 393 | extern DllExp DIM_NOSHARE DNA_CONNECTION *Dna_conns;
|
|---|
| 394 |
|
|---|
| 395 | typedef struct {
|
|---|
| 396 | int channel;
|
|---|
| 397 | int mbx_channel;
|
|---|
| 398 | void (*read_rout)();
|
|---|
| 399 | char *buffer;
|
|---|
| 400 | int size;
|
|---|
| 401 | unsigned short *iosb_r;
|
|---|
| 402 | unsigned short *iosb_w;
|
|---|
| 403 | char node[MAX_NODE_NAME];
|
|---|
| 404 | char task[MAX_TASK_NAME];
|
|---|
| 405 | int port;
|
|---|
| 406 | int reading;
|
|---|
| 407 | int timeout;
|
|---|
| 408 | TIMR_ENT *timr_ent;
|
|---|
| 409 | time_t last_used;
|
|---|
| 410 | } NET_CONNECTION;
|
|---|
| 411 |
|
|---|
| 412 | extern DllExp DIM_NOSHARE NET_CONNECTION *Net_conns;
|
|---|
| 413 |
|
|---|
| 414 | typedef struct {
|
|---|
| 415 | char node_name[MAX_NODE_NAME];
|
|---|
| 416 | char task_name[MAX_TASK_NAME];
|
|---|
| 417 | int port;
|
|---|
| 418 | int pid;
|
|---|
| 419 | char *service_head;
|
|---|
| 420 | } DIC_CONNECTION;
|
|---|
| 421 |
|
|---|
| 422 | extern DIM_NOSHARE DIC_CONNECTION *Dic_conns;
|
|---|
| 423 |
|
|---|
| 424 | typedef struct {
|
|---|
| 425 | SRC_TYPES src_type;
|
|---|
| 426 | char node_name[MAX_NODE_NAME];
|
|---|
| 427 | char task_name[MAX_TASK_NAME-4];
|
|---|
| 428 | char node_addr[4];
|
|---|
| 429 | int pid;
|
|---|
| 430 | int port;
|
|---|
| 431 | char *service_head;
|
|---|
| 432 | char *node_head;
|
|---|
| 433 | int protocol;
|
|---|
| 434 | int validity;
|
|---|
| 435 | int n_services;
|
|---|
| 436 | int old_n_services;
|
|---|
| 437 | TIMR_ENT *timr_ent;
|
|---|
| 438 | int already;
|
|---|
| 439 | char long_task_name[MAX_TASK_NAME*2];
|
|---|
| 440 | } DNS_CONNECTION;
|
|---|
| 441 |
|
|---|
| 442 | extern DllExp DIM_NOSHARE DNS_CONNECTION *Dns_conns;
|
|---|
| 443 |
|
|---|
| 444 | extern DllExp DIM_NOSHARE int Curr_N_Conns;
|
|---|
| 445 |
|
|---|
| 446 | /* Client definitions needed by dim_jni.c (from H.Essel GSI) */
|
|---|
| 447 | typedef enum {
|
|---|
| 448 | NOT_PENDING, WAITING_DNS_UP, WAITING_DNS_ANSWER, WAITING_SERVER_UP,
|
|---|
| 449 | WAITING_CMND_ANSWER, DELETED
|
|---|
| 450 | } PENDING_STATES;
|
|---|
| 451 |
|
|---|
| 452 | typedef struct dic_serv {
|
|---|
| 453 | struct dic_serv *next;
|
|---|
| 454 | struct dic_serv *prev;
|
|---|
| 455 | char serv_name[MAX_NAME];
|
|---|
| 456 | int serv_id;
|
|---|
| 457 | FORMAT_STR format_data[MAX_NAME/4];
|
|---|
| 458 | char def[MAX_NAME];
|
|---|
| 459 | int format;
|
|---|
| 460 | int type;
|
|---|
| 461 | int timeout;
|
|---|
| 462 | int curr_timeout;
|
|---|
| 463 | int *serv_address;
|
|---|
| 464 | int serv_size;
|
|---|
| 465 | int *fill_address;
|
|---|
| 466 | int fill_size;
|
|---|
| 467 | void (*user_routine)();
|
|---|
| 468 | long tag;
|
|---|
| 469 | TIMR_ENT *timer_ent;
|
|---|
| 470 | int conn_id;
|
|---|
| 471 | PENDING_STATES pending;
|
|---|
| 472 | int tmout_done;
|
|---|
| 473 | int stamped;
|
|---|
| 474 | int time_stamp[2];
|
|---|
| 475 | int quality;
|
|---|
| 476 | int tid;
|
|---|
| 477 | } DIC_SERVICE;
|
|---|
| 478 |
|
|---|
| 479 | /* PROTOTYPES */
|
|---|
| 480 |
|
|---|
| 481 | /* DNA */
|
|---|
| 482 | _DIM_PROTOE( int dna_start_read, (int conn_id, int size) );
|
|---|
| 483 | _DIM_PROTOE( void dna_test_write, (int conn_id) );
|
|---|
| 484 | _DIM_PROTOE( int dna_write, (int conn_id, void *buffer, int size) );
|
|---|
| 485 | _DIM_PROTOE( int dna_write_nowait, (int conn_id, void *buffer, int size) );
|
|---|
| 486 | _DIM_PROTOE( int dna_open_server, (char *task, void (*read_ast)(), int *protocol,
|
|---|
| 487 | int *port, void (*error_ast)()) );
|
|---|
| 488 | _DIM_PROTOE( int dna_get_node_task, (int conn_id, char *node, char *task) );
|
|---|
| 489 | _DIM_PROTOE( int dna_open_client, (char *server_node, char *server_task, int port,
|
|---|
| 490 | int server_protocol, void (*read_ast)(), void (*error_ast)(), SRC_TYPES src_type ));
|
|---|
| 491 | _DIM_PROTOE( int dna_close, (int conn_id) );
|
|---|
| 492 | _DIM_PROTOE( void dna_report_error, (int conn_id, int code, char *routine_name) );
|
|---|
| 493 |
|
|---|
| 494 |
|
|---|
| 495 | /* TCPIP */
|
|---|
| 496 | _DIM_PROTOE( int tcpip_open_client, (int conn_id, char *node, char *task,
|
|---|
| 497 | int port) );
|
|---|
| 498 | _DIM_PROTOE( int tcpip_open_server, (int conn_id, char *task, int *port) );
|
|---|
| 499 | _DIM_PROTOE( int tcpip_open_connection, (int conn_id, int channel) );
|
|---|
| 500 | _DIM_PROTOE( int tcpip_start_read, (int conn_id, char *buffer, int size,
|
|---|
| 501 | void (*ast_routine)()) );
|
|---|
| 502 | _DIM_PROTOE( int tcpip_start_listen, (int conn_id, void (*ast_routine)()) );
|
|---|
| 503 | _DIM_PROTOE( int tcpip_write, (int conn_id, char *buffer, int size) );
|
|---|
| 504 | _DIM_PROTOE( void tcpip_get_node_task, (int conn_id, char *node, char *task) );
|
|---|
| 505 | _DIM_PROTOE( int tcpip_close, (int conn_id) );
|
|---|
| 506 | _DIM_PROTOE( int tcpip_failure, (int code) );
|
|---|
| 507 | _DIM_PROTOE( void tcpip_report_error, (int code) );
|
|---|
| 508 |
|
|---|
| 509 |
|
|---|
| 510 | /* DTQ */
|
|---|
| 511 | _DIM_PROTOE( int dtq_create, (void) );
|
|---|
| 512 | _DIM_PROTOE( int dtq_delete, (int queue_id) );
|
|---|
| 513 | _DIM_PROTOE( TIMR_ENT *dtq_add_entry, (int queue_id, int time,
|
|---|
| 514 | void (*user_routine)(), long tag) );
|
|---|
| 515 | _DIM_PROTOE( int dtq_clear_entry, (TIMR_ENT *entry) );
|
|---|
| 516 | _DIM_PROTOE( int dtq_rem_entry, (int queue_id, TIMR_ENT *entry) );
|
|---|
| 517 |
|
|---|
| 518 | /* UTIL */
|
|---|
| 519 | typedef struct dll {
|
|---|
| 520 | struct dll *next;
|
|---|
| 521 | struct dll *prev;
|
|---|
| 522 | char user_info[1];
|
|---|
| 523 | } DLL;
|
|---|
| 524 |
|
|---|
| 525 | typedef struct sll {
|
|---|
| 526 | struct sll *next;
|
|---|
| 527 | char user_info[1];
|
|---|
| 528 | } SLL;
|
|---|
| 529 |
|
|---|
| 530 | _DIM_PROTO( void DimDummy, () );
|
|---|
| 531 | _DIM_PROTOE( void conn_arr_create, (SRC_TYPES type) );
|
|---|
| 532 | _DIM_PROTOE( int conn_get, (void) );
|
|---|
| 533 | _DIM_PROTOE( void conn_free, (int conn_id) );
|
|---|
| 534 | _DIM_PROTOE( void *arr_increase, (void *conn_ptr, int conn_size, int n_conns) );
|
|---|
| 535 | _DIM_PROTOE( void id_arr_create, () );
|
|---|
| 536 | _DIM_PROTOE( void *id_arr_increase,(void *id_ptr, int id_size, int n_ids) );
|
|---|
| 537 |
|
|---|
| 538 | _DIM_PROTOE( void dll_init, ( DLL *head ) );
|
|---|
| 539 | _DIM_PROTOE( void dll_insert_queue, ( DLL *head, DLL *item ) );
|
|---|
| 540 | _DIM_PROTOE( void dll_insert_after, ( DLL *after, DLL *item ) );
|
|---|
| 541 | _DIM_PROTOE( DLL *dll_search, ( DLL *head, char *data, int size ) );
|
|---|
| 542 | _DIM_PROTOE( DLL *dll_get_next, ( DLL *head, DLL *item ) );
|
|---|
| 543 | _DIM_PROTOE( DLL *dll_get_prev, ( DLL *head, DLL *item ) );
|
|---|
| 544 | _DIM_PROTOE( int dll_empty, ( DLL *head ) );
|
|---|
| 545 | _DIM_PROTOE( void dll_remove, ( DLL *item ) );
|
|---|
| 546 |
|
|---|
| 547 | _DIM_PROTOE( void sll_init, ( SLL *head ) );
|
|---|
| 548 | _DIM_PROTOE( int sll_insert_queue, ( SLL *head, SLL *item ) );
|
|---|
| 549 | _DIM_PROTOE( SLL *sll_search, ( SLL *head, char *data, int size ) );
|
|---|
| 550 | _DIM_PROTOE( SLL *sll_get_next, ( SLL *item ) );
|
|---|
| 551 | _DIM_PROTOE( int sll_empty, ( SLL *head ) );
|
|---|
| 552 | _DIM_PROTOE( int sll_remove, ( SLL *head, SLL *item ) );
|
|---|
| 553 | _DIM_PROTOE( SLL *sll_remove_head, ( SLL *head ) );
|
|---|
| 554 | _DIM_PROTOE( SLL *sll_search_next_remove, ( SLL *item, int offset, char *data, int size ) );
|
|---|
| 555 | _DIM_PROTOE( SLL *sll_get_head, ( SLL *head ) );
|
|---|
| 556 |
|
|---|
| 557 | _DIM_PROTOE( int HashFunction, ( char *name, int max ) );
|
|---|
| 558 |
|
|---|
| 559 | _DIM_PROTOE( int copy_swap_buffer_out, (int format, FORMAT_STR *format_data,
|
|---|
| 560 | void *buff_out, void *buff_in, int size) );
|
|---|
| 561 | _DIM_PROTOE( int copy_swap_buffer_in, (FORMAT_STR *format_data, void *buff_out,
|
|---|
| 562 | void *buff_in, int size) );
|
|---|
| 563 | _DIM_PROTOE( int get_node_name, (char *node_name) );
|
|---|
| 564 |
|
|---|
| 565 | _DIM_PROTOE( int get_dns_port_number, () );
|
|---|
| 566 |
|
|---|
| 567 | _DIM_PROTOE( int get_dns_node_name, ( char *node_name ) );
|
|---|
| 568 |
|
|---|
| 569 | _DIM_PROTOE( int get_dns_accepted_domains, ( char *domains ) );
|
|---|
| 570 | _DIM_PROTOE( int get_dns_accepted_nodes, ( char *nodes ) );
|
|---|
| 571 |
|
|---|
| 572 | _DIM_PROTO( double _swapd_by_addr, (double *d) );
|
|---|
| 573 | _DIM_PROTO( int _swapl_by_addr, (int *l) );
|
|---|
| 574 | _DIM_PROTO( short _swaps_by_addr, (short *s) );
|
|---|
| 575 | _DIM_PROTO( void _swapd_buffer, (double *dout, double *din, int n) );
|
|---|
| 576 | _DIM_PROTO( void _swapl_buffer, (int *lout, int *lin, int n) );
|
|---|
| 577 | _DIM_PROTO( void _swaps_buffer, (short *sout, short *sin, int n) );
|
|---|
| 578 |
|
|---|
| 579 | #define SIZEOF_CHAR 1
|
|---|
| 580 | #define SIZEOF_SHORT 2
|
|---|
| 581 | #define SIZEOF_LONG 4
|
|---|
| 582 | #define SIZEOF_FLOAT 4
|
|---|
| 583 | #define SIZEOF_DOUBLE 8
|
|---|
| 584 |
|
|---|
| 585 | #if defined(OSK) && !defined(_UCC)
|
|---|
| 586 | # define inc_pter(p,i) (char *)p += (i)
|
|---|
| 587 | #else
|
|---|
| 588 | # define inc_pter(p,i) p = (void *)((char *)p + (i))
|
|---|
| 589 | #endif
|
|---|
| 590 |
|
|---|
| 591 | #endif
|
|---|