-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsocket_h.rpgle
1760 lines (1630 loc) · 78 KB
/
socket_h.rpgle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*- +
* Copyright (c) 1998-2008 Scott C. Klement +
* All rights reserved. +
* +
* Redistribution and use in source and binary forms, with or without +
* modification, are permitted provided that the following conditions +
* are met: +
* 1. Redistributions of source code must retain the above copyright +
* notice, this list of conditions and the following disclaimer. +
* 2. Redistributions in binary form must reproduce the above copyright +
* notice, this list of conditions and the following disclaimer in the +
* documentation and/or other materials provided with the distribution. +
* +
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +
* SUCH DAMAGE. +
* +
*/ +
***********************************************************************
* Header file for the Socket API.
*
* To use this, you must /COPY SOCKET_H into the D specs of your
* ILE RPG source member.
* (or whatever the appropriate source lib/file, member is)
*
* Most of the major socket functions and structures are prototyped
* here. There may be some that I missed (because I havent needed
* them) if you need them, you'll have to add them yourself :)
* SCK 08/06/1998
***********************************************************************
D/if defined(SOCKET_H)
D/eof
D/endif
D/define SOCKET_H
***********************************************************************
** C O N S T A N T S
***********************************************************************
D IPVERSION C CONST(4)
*************************************************
* Address families.
*************************************************
D AF_UNSPEC C CONST(0)
* Unix domain
D AF_UNIX C CONST(1)
* Internet domain (IPv4)
D AF_INET C CONST(2)
* Network Services domain
D AF_NS C CONST(6)
* IPv6
D AF_INET6 C CONST(24)
* Unix w/CCSID support
D AF_UNIX_CCSID C CONST(98)
* Telephony domain
D AF_TELEPHONY C CONST(99)
*************************************************
* Socket Types:
*************************************************
D* stream socket (TCP)
D SOCK_STREAM C CONST(1)
D* datagram socket (UDP)
D SOCK_DGRAM C CONST(2)
D* raw socket
D SOCK_RAW C CONST(3)
D* sequential packet
D SOCK_SEQPACKET C CONST(5)
*************************************************
* Protocol families.
*************************************************
D PF_UNSPEC C CONST(0)
* Unix domain
D PF_UNIX C CONST(1)
* Internet domain (IPv4)
D PF_INET C CONST(2)
* Network Services domain
D PF_NS C CONST(6)
* IPv6
D PF_INET6 C CONST(24)
* Unix w/CCSID support
D PF_UNIX_CCSID C CONST(98)
* Telephony domain
D PF_TELEPHONY C CONST(99)
*************************************************
* Socket-Level options (setsockopt/getsockopt)
*************************************************
D* allow broadcast msgs
D SO_BROADCAST C 5
D* record debug information
D SO_DEBUG C 10
D* disable routing
D SO_DONTROUTE C 15
D* error status
D SO_ERROR C 20
D* keep connections alive
D SO_KEEPALIVE C 25
D* linger upon close
D SO_LINGER C 30
D* out-of-band data inline
D SO_OOBINLINE C 35
D* receive buffer size
D SO_RCVBUF C 40
D* receive low water mark
D SO_RCVLOWAT C 45
D* receive timeout value
D SO_RCVTIMEO C 50
D* re-use local address
D SO_REUSEADDR C 55
D* send buffer size
D SO_SNDBUF C 60
D* send low water mark
D SO_SNDLOWAT C 65
D* send timeout value
D SO_SNDTIMEO C 70
D* socket type
D SO_TYPE C 75
D* send loopback
D SO_USELOOPBACK C 80
D* send loopback
D SO_ACCEPTCONN C 85
*************************************************
* flag parameter values (send/sendto/recv/recvfrom)
*************************************************
D* dont route
D MSG_DONTROUTE C CONST(1)
D* out-of-band data
D MSG_OOB C CONST(4)
D* keep data in buffer
D MSG_PEEK C CONST(8)
D* data discarded
D MSG_TRUNC C CONST(16)
D* control data discard
D MSG_CTRUNC C CONST(32)
D* wait for full req
D MSG_WAITALL C CONST(64)
D* end of record
D MSG_EOR C CONST(128)
D* maximum iovecs
D MSG_MAXIOVLEN C CONST(16)
D* socket layer
D SOL_SOCKET C CONST(-1)
D* max queued conns
D SOMAXCONN C CONST(512)
*************************************************
* Flag constants for send_file API
*************************************************
D SF_CLOSE C 1
D SF_REUSE C 2
*************************************************
* Flags for shutdown API
*************************************************
D SHUT_RD C 0
D SHUT_WR C 1
D SHUT_RDWR C 2
*************************************************
* Internet Family Protocols
*************************************************
D IPPROTO_IP...
D C CONST(0)
D IPPROTO_HOPOPTS...
D C CONST(0)
D IPPROTO_ICMP...
D C CONST(1)
D IPPROTO_TCP...
D C CONST(6)
D IPPROTO_EGP...
D C CONST(8)
D IPPROTO_PUP...
D C CONST(12)
D IPPROTO_UDP...
D C CONST(17)
D IPPROTO_IPV6...
D C CONST(41)
D IPPROTO_ROUTING...
D C CONST(43)
D IPPROTO_FRAGMENT...
D C CONST(44)
D IPPROTO_ESP...
D C CONST(50)
D IPPROTO_AH...
D C CONST(51)
D IPPROTO_ICMPV6...
D C CONST(58)
D IPPROTO_NONE...
D C CONST(59)
D IPPROTO_DSTOPTS...
D C CONST(60)
D IPPROTO_RAW...
D C CONST(255)
D IPPROTO_MAX...
D C CONST(256)
** IP-Level (IPPROTO_IP) options for setsockopt()/getsockopt()
D* ip options
D IP_OPTIONS...
D C CONST(5)
D IP_TOS...
D C CONST(10)
D IP_TTL...
D C CONST(15)
D IP_MULTICAST_IF...
D C CONST(20)
D IP_MULTICAST_TTL...
D C CONST(25)
D IP_MULTICAST_LOOP...
D C CONST(30)
D IP_ADD_MEMBERSHIP...
D C CONST(35)
D IP_DROP_MEMBERSHIP...
D C CONST(40)
D IP_DONTFRAG...
D C CONST(55)
D IP_RECVLCLIFADDR...
D C CONST(99)
D IPV6_V6ONLY...
D C CONST(100)
D IPV6_RECVHOPLIMIT...
D C CONST(101)
D IPV6_UNICAST_HOPS...
D C CONST(15)
D IPV6_MULTICAST_IF...
D C CONST(20)
D IPV6_MULTICAST_TTL...
D C CONST(25)
D IPV6_MULTICAST_LOOP...
D C CONST(30)
D IPV6_JOIN_GROUP...
D C CONST(35)
D IPV6_LEAVE_GROUP...
D C CONST(40)
D IPV6_CHECKSUM...
D C CONST(105)
D IPV6_HOPLIMIT...
D C CONST(115)
D ICMP6_FILTER...
D C CONST(150)
** TCP level (IPPROTO_TCP) options for setsockopt()/getsockopt()
D TCP_MAXSEG C 5
D TCP_NODELAY C 10
** Types of Service for IP packets
** These are indended to be used in the 'ip' data structure
** defined below.
D* normal
D IPTOS_NORMAL C CONST(x'00')
D* min cost
D IPTOS_MIN C CONST(x'02')
D* reliability
D IPTOS_RELIABLE C CONST(x'04')
D* throughput
D IPTOS_THRUPUT C CONST(x'08')
D* low-delay
D IPTOS_LOWDELAY C CONST(x'10')
** Precedence for Types of Service
** These are indended to be used in the 'ip' data structure
** defined below.
D* net control
D IPTOS_NET C CONST(x'E0')
D* internet control
D IPTOS_INET C CONST(x'C0')
D* critic ecp
D IPTOS_CRIT C CONST(x'A0')
D* flash override
D IPTOS_FOVR C CONST(x'80')
D* flash
D IPTOS_FLAS C CONST(x'60')
D* immediate
D IPTOS_IMME C CONST(x'40')
D* priority
D IPTOS_PTY C CONST(x'20')
D* routine
D IPTOS_ROUT C CONST(x'10')
** "Special" IP Address values
D INADDR_ANY...
D C CONST(0)
D INADDR_BROADCAST...
D C CONST(4294967295)
D INADDR_LOOPBACK...
D C CONST(2130706433)
D INADDR_NONE...
D C CONST(4294967295)
D INADDR_UNSPEC_GROUP...
D C CONST(3758096384)
D INADDR_ALLHOSTS_GROUP...
D C CONST(3758096385)
D INADDR_MAX_LOCAL_GROUP...
D C CONST(3758096639)
D INET_ADDRSTRLEN...
D s 16a based(template)
D INET6_ADDRSTRLEN...
D s 46a based(template)
** ICMP message types
D* echo reply
D ICMP_ECHOREPLY C CONST(x'00')
D* unreachable
D ICMP_UNREACH C CONST(x'03')
D* source quench
D ICMP_SOURCEQUENCH...
D C CONST(x'04')
D* redirect
D ICMP_REDIRECT...
D C CONST(x'05')
D* echo
D ICMP_ECHO C CONST(x'08')
D* time exceeded
D ICMP_TIMXCEED...
D C CONST(x'0B')
D* parameter problem
D ICMP_PARAMPROB C CONST(x'0C')
D* timestamp request
D ICMP_TSTAMP C CONST(x'0D')
D* timestamp req reply
D ICMP_TSTAMPREPLY...
D C CONST(x'0E')
D* info request
D ICMP_IREQ C CONST(x'0F')
D* info request reply
D ICMP_IREQREPLY...
D C CONST(x'10')
D* addr mask request
D ICMP_MASKREQ C CONST(x'11')
D* addr mask req reply
D ICMP_MASKREPLY C CONST(x'12')
** ICMP subtype codes
D* network unreachable
D UNR_NET C CONST(x'00')
D* host unreachable
D UNR_HOST C CONST(x'01')
D* protocol unreachble
D UNR_PROTO C CONST(x'02')
D* port unreachable
D UNR_PORT C CONST(x'03')
D* fragmentation needed
D* and dont fragment
D* flag is set
D UNR_FRAG C CONST(x'04')
D* source route failed
D UNR_SRCF C CONST(x'05')
D* time exceeded in
D* transit
D TIMX_INTRA C CONST(x'00')
D* time exceeded in
D* frag reassembly
D TIMX_REASS C CONST(x'01')
D* redir for network
D REDIR_NET C CONST(x'00')
D* redir for host
D REDIR_HOST C CONST(x'01')
D* redir for TOS & Net
D REDIR_TOSN C CONST(x'02')
D* redir for TOS & Host
D REDIR_TOSH C CONST(x'03')
D/if not defined(FCNTL_CONSTANTS)
** fcntl() commands
D F_DUPFD C CONST(0)
D F_GETFL C CONST(6)
D F_SETFL C CONST(7)
D F_GETOWN C CONST(8)
D F_SETOWN C CONST(9)
** fcntl() flags
D O_NONBLOCK C CONST(128)
D O_NDELAY C CONST(128)
D FNDELAY C CONST(128)
D FASYNC C CONST(512)
D/define FCNTL_CONSTANTS
D/endif
*************************************************
* linger structure
*
* struct linger {
* int l_onoff; Turns ON/OFF
* int l_linger; Linger time in secs
* };
*
*************************************************
D linger DS BASED(p_linger)
D l_onoff 10I 0
D l_linger 10I 0
/if defined(XOPEN_SOURCE)
/if not defined(COMPAT_43)
/define XOPEN_SOURCE_530
/endif
/endif
D socklen_t s 10i 0 based(Template)
**************************************************************
* Socket Address: This is a basic socket address structure
* for any type of network (pre-IPv6)
**************************************************************
/if not defined(XOPEN_SOURCE_520)
D sa_family_t s 5u 0 based(Template)
D sockaddr ds
D sa_family like(sa_family_t)
D sa_data 14a
/else
D sa_family_t s 3u 0 based(Template)
D sa_len_t s 3u 0 based(Template)
D sockaddr ds
D sa_len like(sa_len_t)
D sa_family like(sa_family_t)
D sa_data 14a
/endif
**************************************************************
* Socket Storage: Same as preceding structure, but large
* enough for any address, even in IPv6.
**************************************************************
/if not defined(XOPEN_SOURCE_520)
D sockaddr_storage...
D ds 304 based(p_sockaddr_storage)
D ss_family like(sa_family_t)
/else
D sockaddr_storage...
D ds 304 based(p_sockaddr_storage)
D ss_len like(sa_len_t)
D ss_family like(sa_family_t)
/endif
** Socket Address (Internet)
**
** struct sockaddr_in {
** short sin_family;
** u_short sin_port;
** struct in_addr sin_addr;
** char sin_zero[8];
** };
**
/if not defined(XOPEN_SOURCE_520)
D sockaddr_in DS based(p_sockaddr)
D sin_Family 5u 0
D sin_Port 5U 0
D sin_addr 10U 0
D sin_zero 8A
/else
D sockaddr_in DS based(p_sockaddr)
D sin_Len 3u 0
D sin_Family 3u 0
D sin_Port 5U 0
D sin_addr 10U 0
D sin_zero 8A
/endif
** Socket Address (Internet IPv6)
**
** struct sockaddr_in6 {
** sa_family_t sin6_family; /* AF_INET6 @A5A*/
** in_port_t sin6_port; /* transport layer port # @A5A*/
** uint32_t sin6_flowinfo; /* IPv6 traffic class & flow @A5A*/
** struct in6_addr sin6_addr; /* IPv6 address @A5A*/
** uint32_t sin6_scope_id; /* set of scope interfaces @A5A*/
** };
**
/if not defined(XOPEN_SOURCE_520)
D sockaddr_in6 DS based(Template)
D sin6_family 5u 0
D sin6_port 5U 0
D sin6_flowinfo 10u 0
D sin6_addr 16a
D sin6_scope_id 10u 0
/else
D sockaddr_in6 DS based(Template)
D sin6_len 3u 0
D sin6_family 3u 0
D sin6_port 5U 0
D sin6_flowinfo 10u 0
D sin6_addr 16a
D sin6_scope_id 10u 0
/endif
** Socket Address (Unix domain)
**
** struct sockaddr_un {
** short sun_family;
** char sun_path[126];
** };
**
/if not defined(XOPEN_SOURCE_520)
D sockaddr_un DS qualified based(p_sockaddr)
D sun_Family 5I 0
D sun_Path 126A
/else
D sockaddr_un DS qualified based(p_sockaddr)
D sun_len 3u 0
D sun_family 3u 0
D sun_path 126a
/endif
**
** Host Database Entry (for DNS lookups, etc)
**
** (this is a partial implementation... didn't try to
** figure out how to deal with all possible addresses
** or all possible aliases for a host in RPG)
**
** struct hostent {
** char *h_name;
** char **h_aliases;
** int h_addrtype;
** int h_length;
** char **h_addr_list;
** };
**
** #define h_addr h_addr_list[0]
**
D hostent DS Based(p_hostent)
D h_name *
D h_aliases *
D h_addrtype 5I 0
D h_length 5I 0
D h_addrlist *
D p_h_addr S * Based(h_addrlist)
D h_addr S 10U 0 Based(p_h_addr)
**
** Service Database Entry (which service = which port, etc)
**
** struct servent {
** char *s_name;
** char **s_aliases;
** int s_port;
** char *s_proto;
** };
**
D servent DS Based(p_servent)
D s_name *
D s_aliases *
D s_port 10I 0
D s_proto *
**
** IP structure without any opts (for RAW sockets)
**
** struct ip {
** unsigned ip_v:4; Version (first 4 bits)
** unsigned ip_hl:4; Header length (next 4)
** u_char ip_tos; Type of service
** short ip_len; Total Length
** u_short ip_id; Identification
** short ip_off; Fragment offset field
** u_char ip_ttl; Time to live
** u_char ip_p; Protocol
** u_short ip_sum; Checksum
** struct in_addr ip_src; Source Address
** struct in_addr ip_dst; Destination Address
** };
**
** Note: Since you can't define a variable to be 4 bits long
** in RPG, ip_v_hl is a combination of ip_v and ip_hl.
** with mult/div/mvr and data structures, it should still
** be usable...
**
** Since ip_tos & ip_ttl conflict with the definitions for
** setsockopt() & getsockopt(), we add an extra $ to the end...
D ip DS based(p_ip)
D qualified
D ip_v_hl 1A
D ip_tos 1A
D ip_len 5I 0
D ip_id 5U 0
D ip_off 5I 0
D ip_ttl 1A
D ip_p 1A
D ip_sum 5U 0
D ip_src 10U 0
D ip_dst 10U 0
**
** UDP Packet Header (for RAW sockets)
**
** struct udphdr { /* UDP header */
** u_short uh_sport; /* source port */
** u_short uh_dport; /* destination port */
** short uh_ulen; /* UDP length */
** u_short uh_sum; /* UDP checksum */
** };
**
d udphdr DS based(p_udphdr)
D qualified
D uh_sport 5U 0
D uh_dport 5U 0
D uh_ulen 5I 0
D uh_sum 5U 0
** Internet Control Message Protocol (ICMP) header
** (I THINK I did the unions correctly... but you might want to
** check that out if you're having problems...)
**
** struct icmp { /* ICMP header */
** u_char icmp_type; /* ICMP message type */
** u_char icmp_code; /* type sub code */
** u_short icmp_cksum; /* ICMP checksum */
** union { /* Message type substructures:*/
** u_char ih_pptr; /* Parameter problem pointer*/
** struct in_addr ih_gwaddr; /* Redirect gateway address */
** struct ih_idseq { /* Echo/Timestmp Req/Reply */
** u_short icd_id; /* Indentifier */
** u_short icd_seq; /* Sequence number */
** } ih_idseq;
** int ih_void; /* Unused part of some msgs */
** } icmp_hun;
** union {
** struct id_ts { /* Timestamp substructure */
** u_long its_otime; /* Originate timestamp */
** u_long its_rtime; /* Receive timestamp */
** u_long its_ttime; /* Transmit timestamp */
** } id_ts;
** struct id_ip { /* Imbedded 'original' IP hdr */
** struct ip idi_ip; /* in ICMP error-type msgs. */
** /* Includes IP header,IP opts,*/
** /* and 64 bits of data. */
** } id_ip;
** u_long id_mask; /* Address mask request/reply */
** char id_data[1]; /* Beginning of echo req data */
** } icmp_dun;
** };
D icmp DS based(p_icmp)
D qualified
D icmp_type 1A
D icmp_code 1A
D icmp_cksum 5U 0
D icmp_hun 4A
D ih_gwaddr 10U 0 OVERLAY(icmp_hun:1)
D ih_pptr 1A OVERLAY(icmp_hun:1)
D ih_idseq 4A OVERLAY(icmp_hun:1)
D icd_id 5U 0 OVERLAY(ih_idseq:1)
D icd_seq 5U 0 OVERLAY(ih_idseq:3)
D ih_void 5I 0 OVERLAY(icmp_hun:1)
D icmp_dun 20A
D id_ts 12A OVERLAY(icmp_dun:1)
D its_otime 10U 0 OVERLAY(id_ts:1)
D its_rtime 10U 0 OVERLAY(id_ts:5)
D its_ttime 10U 0 OVERLAY(id_ts:9)
D id_ip 20A OVERLAY(icmp_dun:1)
D idi_ip 20A OVERLAY(id_ip:1)
D id_mask 10U 0 OVERLAY(icmp_dun:1)
D id_data 1A OVERLAY(icmp_dun:1)
**
** Time Value Structure (for the select() function, etc)
**
** struct timeval {
** long tv_sec; /* seconds */
** long tv_usec; /* microseconds */
** };
**
** contrains a structure for specifying a wait time on
** a select() function...
**
** tv_sec = seconds. tv_usec = microseconds
**
/if not defined(TIMEVAL_STRUCT)
D timeval DS based(p_timeval)
D tv_sec 10I 0
D tv_usec 10I 0
/define TIMEVAL_STRUCT
/endif
**
** i/o vector. Can be used to write data from
** different buffers without needing to copy the
** data all into one place first.
** ("scatter/gather" I/O)
**
/if not defined(IOVEC_DS_DEFINED)
D iovec ds based(p_iovec) qualified
D iov_base *
D iov_len 10u 0
/define IOVEC_DS_DEFINED
/endif
**
** msghdr structure for use w/sendmsg() and recvmsg() APIs
**
/if not defined(XOPEN_SOURCE_520)
D msghdr ds based(p_msghdr) qualified
D align
D msg_name *
D msg_namelen 10i 0
D msg_iov *
D msg_iovlen 10i 0
D msg_accrights *
D msg_accrightslen...
D 10i 0
/else
D msghdr ds based(p_msghdr) qualified
D align
D msg_name *
D msg_namelen 10i 0
D msg_iov *
D msg_iovlen 10i 0
D msg_control *
D msg_controllen...
D 10i 0
D msg_flags 10i 0
D cmsghdr ds based(p_cmsghdr) qualified
D cmsg_len 10i 0
D cmsg_level 10i 0
D cmsg_type 10i 0
D SCM_RIGHTS C const(1)
D IP_QOS_CLASSIFICATION_DATA...
D C const(x'80000001')
/endif
***********************************************************************
** S U B P R O C E D U R E P R O T O T Y P E S
***********************************************************************
** --------------------------------------------------------------------
**
** socket--Create Socket
**
** int socket(int address_family,
** int type,
** int protocol)
**
**
** The socket() function is used to create an end point for
** communications. The end point is represented by the
** socket descriptor returned by the socket() function.
**
** --------------------------------------------------------------------
/if not defined(XOPEN_SOURCE_520)
D socket PR 10I 0 ExtProc('socket')
D AddrFamily 10I 0 Value
D SocketType 10I 0 Value
D Protocol 10I 0 Value
/else
D socket PR 10I 0 ExtProc('qso_socket98')
D AddrFamily 10I 0 Value
D SocketType 10I 0 Value
D Protocol 10I 0 Value
/endif
** --------------------------------------------------------------------
**
** setsockopt()--Set Socket Options
**
** int setsockopt(int socket_descriptor,
** int level,
** int option_name,
** char *option_value
** int option_length)
**
** The setsockopt() function is used to set socket options
** (there are many, see the book.)
** --------------------------------------------------------------------
/if not defined(XOPEN_SOURCE_520)
D setsockopt PR 10I 0 ExtProc('setsockopt')
D SocketDesc 10I 0 Value
D Opt_Level 10I 0 Value
D Opt_Name 10I 0 Value
D Opt_Value * Value
D Opt_Len 10I 0 Value
/else
D setsockopt PR 10I 0 ExtProc('qso_setsockopt98')
D SocketDesc 10I 0 Value
D Opt_Level 10I 0 Value
D Opt_Name 10I 0 Value
D Opt_Value * Value
D Opt_Len 10I 0 Value
/endif
** --------------------------------------------------------------------
** getsockopt() -- Retrieve Info about Socket Options
**
** int getsockopt(int socket_descriptor,
** int level,
** int option_name,
** char *option_value,
** int *option_length)
**
** Gets various information about the socket's options.
** (there are many, see the book.)
** --------------------------------------------------------------------
/if not defined(XOPEN_SOURCE_520)
D getsockopt PR 10I 0 extproc('getsockopt')
D SocketDesc 10I 0 VALUE
D Opt_Level 10I 0 VALUE
D Opt_Name 10I 0 VALUE
D Opt_Value * VALUE
D Opt_Length 10I 0
/else
D getsockopt PR 10I 0 extproc('qso_getsockopt98')
D SocketDesc 10I 0 VALUE
D Opt_Level 10I 0 VALUE
D Opt_Name 10I 0 VALUE
D Opt_Value * VALUE
D Opt_Length 10I 0
/endif
** --------------------------------------------------------------------
**
** getsockname()--Get Local Address for Socket
**
** int getsockname(int socket_descriptor,
** struct sockaddr *local_address,
** int *address_length)
**
** struct sockaddr {
** u_short sa_family;
** char sa_data[14];
** };
**
** The getsockname() function is used to retreive the local address
** asociated with a socket.
** --------------------------------------------------------------------
/if not defined(XOPEN_SOURCE_520)
D getsockname PR 10I 0 ExtProc('getsockname')
D SocketDesc 10I 0 Value
D SockAddr like(Sockaddr_storage)
D options(*varsize)
D AddrLength 10I 0
/else
D getsockname PR 10I 0 ExtProc('qso_getsockname98')
D SocketDesc 10I 0 Value
D SockAddr like(Sockaddr_storage)
D options(*varsize)
D AddrLength 10I 0
/endif
** --------------------------------------------------------------------
**
** getpeername()--Retrieve Destination Address of Socket
**
** int getpeername(int socket_descriptor,
** struct sockaddr *local_address,
** int *address_length)
**
** struct sockaddr {
** u_short sa_family;
** char sa_data[14];
** };
**
**
** The getpeername() function is used to retreive the destination
** address to which the socket is connected.
**
** Note: Socket must be connected first.
**
** --------------------------------------------------------------------
/if not defined(XOPEN_SOURCE_520)
D getpeername PR 10I 0 ExtProc('getpeername')
D SocketDesc 10I 0 Value
D p_sockaddr like(Sockaddr_storage)
D options(*varsize)
D AddrLength 10I 0
/else
D getpeername PR 10I 0 ExtProc('qso_getpeername98')
D SocketDesc 10I 0 Value
D p_sockaddr like(Sockaddr_storage)
D options(*varsize)
D AddrLength 10I 0
/endif
** --------------------------------------------------------------------
** bind()--Bind socket to specified adapter and/or port
**
** int bind(int socket_descriptor,
** struct sockaddr *local_address,
** int address_length)
**
** struct sockaddr {
** u_short sa_family;
** char sa_data[14];
** };
**
**
** The bind() function is used to associate a local address
** and port with a socket. This allows you to get only
** socket requests on a specific network adapter, and to
** assign a specific port to your socket.
** For example, if you're writing a telnet server, you'd
** bind to port 23, because thats the standard port for
** telnets to listen on.
** If we bind to an address of 0, it will allow requests on
** any (TCP/IP enabled) network adapter.
**
** --------------------------------------------------------------------
/if not defined(XOPEN_SOURCE_520)
D bind PR 10I 0 ExtProc('bind')
D Sock_Desc 10I 0 Value
D p_Address * value
D AddressLen 10I 0 Value
/else
D bind PR 10I 0 ExtProc('qso_bind98')
D Sock_Desc 10I 0 Value
D p_Address like(sockaddr_storage)
D options(*varsize)
D AddressLen 10I 0 Value
/endif
** --------------------------------------------------------------------
** listen()--Invite Incoming Connections Requests
**
** int listen(int socket_descriptor,
** int back_log)
**
**
** The listen() function is used to indicate a willingness to accept
** incoming connection requests. if a listen() is not done,
** incoming requests are refused.
**
** --------------------------------------------------------------------
/if not defined(XOPEN_SOURCE_520)
D listen PR 10I 0 ExtProc('listen')
D SocketDesc 10I 0 Value
D Back_Log 10I 0 Value
/else
D listen PR 10I 0 ExtProc('qso_listen98')
D SocketDesc 10I 0 Value
D Back_Log 10I 0 Value
/endif
** --------------------------------------------------------------------
** accept()--Wait for Connection Request and Make Connection
**
** int accept(int socket_descriptor,
** struct sockaddr *address,
** int *address_length)
**
** struct sockaddr {
** u_short sa_family;
** char sa_data[14];
** };
**
** The accept() function is used to wait for connection requests.
** accept() takes the first connection request on the queue of
** pending connection requests and creates a new socket to service
** the connection request.
**
** --------------------------------------------------------------------
/if not defined(XOPEN_SOURCE_520)
D accept PR 10I 0 ExtProc('accept')
D Sock_Desc 10I 0 Value
D p_Address * Value
D p_AddrLen 10I 0 options(*omit)
/else
D accept PR 10I 0 ExtProc('accept')
D Sock_Desc 10I 0 Value
D p_Address like(sockaddr_storage)