00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _SYS_SOCKET_H_
00036 #define _SYS_SOCKET_H_
00037
00038 #include <sys/cdefs.h>
00039 #include <sys/types.h>
00040 #include <sys/_types.h>
00041 #include <sys/_iovec.h>
00042 #define _NO_NAMESPACE_POLLUTION
00043 #include <machine/param.h>
00044 #undef _NO_NAMESPACE_POLLUTION
00045
00046
00047
00048
00049
00050
00051
00052
00053 #if __BSD_VISIBLE
00054 #ifndef _GID_T_DECLARED
00055 typedef __gid_t gid_t;
00056 #define _GID_T_DECLARED
00057 #endif
00058
00059 #ifndef _OFF_T_DECLARED
00060 typedef __off_t off_t;
00061 #define _OFF_T_DECLARED
00062 #endif
00063
00064 #ifndef _PID_T_DECLARED
00065 typedef __pid_t pid_t;
00066 #define _PID_T_DECLARED
00067 #endif
00068 #endif
00069
00070 #ifndef _SA_FAMILY_T_DECLARED
00071 typedef __sa_family_t sa_family_t;
00072 #define _SA_FAMILY_T_DECLARED
00073 #endif
00074
00075 #ifndef _SOCKLEN_T_DECLARED
00076 typedef __socklen_t socklen_t;
00077 #define _SOCKLEN_T_DECLARED
00078 #endif
00079
00080 #ifndef _SSIZE_T_DECLARED
00081 typedef __ssize_t ssize_t;
00082 #define _SSIZE_T_DECLARED
00083 #endif
00084
00085 #if __BSD_VISIBLE
00086 #ifndef _UID_T_DECLARED
00087 typedef __uid_t uid_t;
00088 #define _UID_T_DECLARED
00089 #endif
00090 #endif
00091
00092
00093
00094
00095 #define SOCK_STREAM 1
00096 #define SOCK_DGRAM 2
00097 #ifdef __SYMBIAN32__
00098 #define SOCK_RAW 4
00099 #else
00100 #define SOCK_RAW 3
00101
00102 #endif
00103 #if __BSD_VISIBLE
00104 #define SOCK_RDM 4
00105 #endif
00106 #ifdef __SYMBIAN32__
00107 #define SOCK_SEQPACKET 3
00108 #else
00109 #define SOCK_SEQPACKET 5
00110
00111 #endif
00112
00113
00114
00115
00116 #define SO_DEBUG 0x0001
00117 #define SO_ACCEPTCONN 0x0002
00118 #ifdef __SYMBIAN32__
00119 #define SO_REUSEADDR 0x406
00120 #else
00121 #define SO_REUSEADDR 0x0004
00122
00123 #endif
00124 #ifdef __SYMBIAN32__
00125 #define SO_KEEPALIVE 0x305
00126 #else
00127 #define SO_KEEPALIVE 0x0008
00128
00129 #endif
00130 #define SO_DONTROUTE 0x0010
00131 #ifdef __SYMBIAN32__
00132 #define SO_BROADCAST -1
00133 #else
00134 #define SO_BROADCAST 0x0020
00135
00136 #endif
00137 #if __BSD_VISIBLE
00138 #ifdef __SYMBIAN32__
00139 #define SO_USELOOPBACK -2
00140 #else
00141 #define SO_USELOOPBACK 0x0040
00142
00143 #endif
00144 #endif
00145 #ifdef __SYMBIAN32__
00146 #define SO_LINGER -3
00147 #else
00148 #define SO_LINGER 0x0080
00149
00150 #endif
00151 #ifdef __SYMBIAN32__
00152 #define SO_OOBINLINE 0x315
00153 #else
00154 #define SO_OOBINLINE 0x0100
00155
00156 #endif
00157 #if __BSD_VISIBLE
00158 #define SO_REUSEPORT 0x0200
00159 #define SO_TIMESTAMP 0x0400
00160 #define SO_NOSIGPIPE 0x0800
00161 #define SO_ACCEPTFILTER 0x1000
00162 #define SO_BINTIME 0x2000
00163 #endif
00164
00165
00166
00167
00168 #ifdef __SYMBIAN32__
00169 #define SO_SNDBUF 3
00170 #else
00171 #define SO_SNDBUF 0x1001
00172
00173 #endif
00174 #ifdef __SYMBIAN32__
00175 #define SO_RCVBUF 2
00176 #else
00177 #define SO_RCVBUF 0x1002
00178
00179 #endif
00180 #define SO_SNDLOWAT 0x1003
00181 #define SO_RCVLOWAT 0x1004
00182 #define SO_SNDTIMEO 0x1005
00183 #define SO_RCVTIMEO 0x1006
00184 #ifdef __SYMBIAN32__
00185 #define SO_ERROR 9
00186 #else
00187 #define SO_ERROR 0x1007
00188
00189 #endif
00190 #define SO_TYPE 0x1008
00191 #if __BSD_VISIBLE
00192 #define SO_LABEL 0x1009
00193 #define SO_PEERLABEL 0x1010
00194 #define SO_LISTENQLIMIT 0x1011
00195 #define SO_LISTENQLEN 0x1012
00196 #define SO_LISTENINCQLEN 0x1013
00197 #endif
00198
00199
00200
00201
00202 struct linger {
00203 int l_onoff;
00204 int l_linger;
00205 };
00206
00207 #if __BSD_VISIBLE
00208 struct accept_filter_arg {
00209 char af_name[16];
00210 char af_arg[256-16];
00211 };
00212 #endif
00213
00214
00215
00216
00217 #ifdef __SYMBIAN32__
00218 #define SOL_SOCKET 1
00219 #else
00220 #define SOL_SOCKET 0xffff
00221
00222 #endif
00223
00224
00225
00226 #define AF_UNSPEC 0
00227 #if __BSD_VISIBLE
00228 #ifdef __SYMBIAN32__
00229 #define AF_LOCAL 0x666
00230 #else
00231 #define AF_LOCAL AF_UNIX
00232
00233 #endif
00234 #endif
00235 #define AF_UNIX 1
00236 #ifdef __SYMBIAN32__
00237 #define AF_INET 0x0800
00238 #else
00239 #define AF_INET 2
00240
00241 #endif
00242 #if __BSD_VISIBLE
00243 #define AF_IMPLINK 3
00244 #define AF_PUP 4
00245 #define AF_CHAOS 5
00246 #define AF_NETBIOS 6
00247 #define AF_ISO 7
00248 #define AF_OSI AF_ISO
00249 #define AF_ECMA 8
00250 #define AF_DATAKIT 9
00251 #define AF_CCITT 10
00252 #define AF_SNA 11
00253 #define AF_DECnet 12
00254 #define AF_DLI 13
00255 #define AF_LAT 14
00256 #define AF_HYLINK 15
00257 #define AF_APPLETALK 16
00258 #define AF_ROUTE 17
00259 #define AF_LINK 18
00260 #define pseudo_AF_XTP 19
00261 #define AF_COIP 20
00262 #define AF_CNT 21
00263 #define pseudo_AF_RTIP 22
00264 #define AF_IPX 23
00265 #define AF_SIP 24
00266 #define pseudo_AF_PIP 25
00267 #define AF_ISDN 26
00268 #define AF_E164 AF_ISDN
00269 #define pseudo_AF_KEY 27
00270 #endif
00271 #ifdef __SYMBIAN32__
00272 #define AF_INET6 0x0806
00273 #else
00274 #define AF_INET6 28
00275 #endif
00276 #if __BSD_VISIBLE
00277 #define AF_NATM 29
00278 #define AF_ATM 30
00279 #define pseudo_AF_HDRCMPLT 31
00280
00281
00282 #define AF_NETGRAPH 32
00283 #define AF_SLOW 33
00284 #define AF_SCLUSTER 34
00285 #define AF_ARP 35
00286 #define AF_BLUETOOTH 36
00287 #define AF_MAX 37
00288 #endif
00289 #ifdef __SYMBIAN32__
00290 #define AF_IRDA 0x0100
00291 #define AF_PLP 273
00292
00293 #endif
00294
00295 #ifndef __SYMBIAN32__
00296
00297
00298
00299
00300 struct sockaddr {
00301 unsigned char sa_len;
00302 sa_family_t sa_family;
00303 char sa_data[14];
00304 };
00305 #else
00306
00311 struct sockaddr {
00312 u_short sa_family;
00313 u_short sa_port;
00314 char sa_data[24];
00315 unsigned char sa_len;
00316 };
00317
00318 #endif
00319
00320 #if __BSD_VISIBLE
00321 #define SOCK_MAXADDRLEN 255
00322
00323
00324
00325
00326
00327 struct sockproto {
00328 unsigned short sp_family;
00329 unsigned short sp_protocol;
00330 };
00331 #endif
00332
00333
00334
00335
00336 #define _SS_MAXSIZE 128U
00337 #define _SS_ALIGNSIZE (sizeof(__int64_t))
00338 #define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) - \
00339 sizeof(sa_family_t))
00340 #define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) - \
00341 sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE)
00342
00343 struct sockaddr_storage {
00344 unsigned char ss_len;
00345 sa_family_t ss_family;
00346 char __ss_pad1[_SS_PAD1SIZE];
00347 __int64_t __ss_align;
00348 char __ss_pad2[_SS_PAD2SIZE];
00349 };
00350
00351 #if __BSD_VISIBLE
00352
00353
00354
00355 #define PF_UNSPEC AF_UNSPEC
00356 #define PF_LOCAL AF_LOCAL
00357 #define PF_UNIX PF_LOCAL
00358 #define PF_INET AF_INET
00359 #define PF_IMPLINK AF_IMPLINK
00360 #define PF_PUP AF_PUP
00361 #define PF_CHAOS AF_CHAOS
00362 #define PF_NETBIOS AF_NETBIOS
00363 #define PF_ISO AF_ISO
00364 #define PF_OSI AF_ISO
00365 #define PF_ECMA AF_ECMA
00366 #define PF_DATAKIT AF_DATAKIT
00367 #define PF_CCITT AF_CCITT
00368 #define PF_SNA AF_SNA
00369 #define PF_DECnet AF_DECnet
00370 #define PF_DLI AF_DLI
00371 #define PF_LAT AF_LAT
00372 #define PF_HYLINK AF_HYLINK
00373 #define PF_APPLETALK AF_APPLETALK
00374 #define PF_ROUTE AF_ROUTE
00375 #define PF_LINK AF_LINK
00376 #define PF_XTP pseudo_AF_XTP
00377 #define PF_COIP AF_COIP
00378 #define PF_CNT AF_CNT
00379 #define PF_SIP AF_SIP
00380 #define PF_IPX AF_IPX
00381 #define PF_RTIP pseudo_AF_RTIP
00382 #define PF_PIP pseudo_AF_PIP
00383 #define PF_ISDN AF_ISDN
00384 #define PF_KEY pseudo_AF_KEY
00385 #define PF_INET6 AF_INET6
00386 #define PF_NATM AF_NATM
00387 #define PF_ATM AF_ATM
00388 #define PF_NETGRAPH AF_NETGRAPH
00389 #define PF_SLOW AF_SLOW
00390 #define PF_SCLUSTER AF_SCLUSTER
00391 #define PF_ARP AF_ARP
00392 #define PF_BLUETOOTH AF_BLUETOOTH
00393
00394 #define PF_MAX AF_MAX
00395
00396 #ifdef __SYMBIAN32__
00397 #define PF_IRDA AF_IRDA
00398 #define PF_PLP AF_PLP
00399
00400 #endif
00401
00402
00403
00404
00405
00406
00407
00408
00409 #define NET_MAXID AF_MAX
00410
00411 #define CTL_NET_NAMES { \
00412 { 0, 0 }, \
00413 { "unix", CTLTYPE_NODE }, \
00414 { "inet", CTLTYPE_NODE }, \
00415 { "implink", CTLTYPE_NODE }, \
00416 { "pup", CTLTYPE_NODE }, \
00417 { "chaos", CTLTYPE_NODE }, \
00418 { "xerox_ns", CTLTYPE_NODE }, \
00419 { "iso", CTLTYPE_NODE }, \
00420 { "emca", CTLTYPE_NODE }, \
00421 { "datakit", CTLTYPE_NODE }, \
00422 { "ccitt", CTLTYPE_NODE }, \
00423 { "ibm_sna", CTLTYPE_NODE }, \
00424 { "decnet", CTLTYPE_NODE }, \
00425 { "dec_dli", CTLTYPE_NODE }, \
00426 { "lat", CTLTYPE_NODE }, \
00427 { "hylink", CTLTYPE_NODE }, \
00428 { "appletalk", CTLTYPE_NODE }, \
00429 { "route", CTLTYPE_NODE }, \
00430 { "link_layer", CTLTYPE_NODE }, \
00431 { "xtp", CTLTYPE_NODE }, \
00432 { "coip", CTLTYPE_NODE }, \
00433 { "cnt", CTLTYPE_NODE }, \
00434 { "rtip", CTLTYPE_NODE }, \
00435 { "ipx", CTLTYPE_NODE }, \
00436 { "sip", CTLTYPE_NODE }, \
00437 { "pip", CTLTYPE_NODE }, \
00438 { "isdn", CTLTYPE_NODE }, \
00439 { "key", CTLTYPE_NODE }, \
00440 { "inet6", CTLTYPE_NODE }, \
00441 { "natm", CTLTYPE_NODE }, \
00442 { "atm", CTLTYPE_NODE }, \
00443 { "hdrcomplete", CTLTYPE_NODE }, \
00444 { "netgraph", CTLTYPE_NODE }, \
00445 { "snp", CTLTYPE_NODE }, \
00446 { "scp", CTLTYPE_NODE }, \
00447 }
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457 #define NET_RT_DUMP 1
00458 #define NET_RT_FLAGS 2
00459 #define NET_RT_IFLIST 3
00460 #define NET_RT_IFMALIST 4
00461 #define NET_RT_MAXID 5
00462
00463 #define CTL_NET_RT_NAMES { \
00464 { 0, 0 }, \
00465 { "dump", CTLTYPE_STRUCT }, \
00466 { "flags", CTLTYPE_STRUCT }, \
00467 { "iflist", CTLTYPE_STRUCT }, \
00468 { "ifmalist", CTLTYPE_STRUCT }, \
00469 }
00470 #endif
00471
00472
00473
00474
00475 #ifdef __SYMBIAN32__
00476 #define SOMAXCONN 5
00477 #else
00478 #define SOMAXCONN 128
00479
00480 #endif
00481
00482
00483
00484
00485
00486 struct msghdr {
00487 void *msg_name;
00488 socklen_t msg_namelen;
00489 struct iovec *msg_iov;
00490 int msg_iovlen;
00491 void *msg_control;
00492 socklen_t msg_controllen;
00493 int msg_flags;
00494 };
00495
00496 #define MSG_OOB 0x1
00497 #define MSG_PEEK 0x2
00498 #define MSG_DONTROUTE 0x4
00499 #define MSG_EOR 0x8
00500 #define MSG_TRUNC 0x10
00501 #define MSG_CTRUNC 0x20
00502 #define MSG_WAITALL 0x40
00503 #if __BSD_VISIBLE
00504 #define MSG_DONTWAIT 0x80
00505 #define MSG_EOF 0x100
00506 #define MSG_NBIO 0x4000
00507 #define MSG_COMPAT 0x8000
00508 #endif
00509 #ifdef _KERNEL
00510 #define MSG_SOCALLBCK 0x10000
00511 #endif
00512 #if __BSD_VISIBLE
00513 #define MSG_NOSIGNAL 0x20000
00514 #endif
00515
00516
00517
00518
00519
00520
00521
00522 struct cmsghdr {
00523 socklen_t cmsg_len;
00524 int cmsg_level;
00525 int cmsg_type;
00526
00527 };
00528
00529 #if __BSD_VISIBLE
00530
00531
00532
00533
00534
00535 #define CMGROUP_MAX 16
00536
00537
00538
00539
00540
00541
00542
00543
00544 struct cmsgcred {
00545 pid_t cmcred_pid;
00546 uid_t cmcred_uid;
00547 uid_t cmcred_euid;
00548 gid_t cmcred_gid;
00549 short cmcred_ngroups;
00550 gid_t cmcred_groups[CMGROUP_MAX];
00551 };
00552
00553
00554
00555
00556 struct sockcred {
00557 uid_t sc_uid;
00558 uid_t sc_euid;
00559 gid_t sc_gid;
00560 gid_t sc_egid;
00561 int sc_ngroups;
00562 gid_t sc_groups[1];
00563 };
00564
00565
00566
00567
00568 #define SOCKCREDSIZE(ngrps) \
00569 (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))
00570
00571 #endif
00572
00573
00574 #define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \
00575 _ALIGN(sizeof(struct cmsghdr)))
00576
00577
00578 #define CMSG_NXTHDR(mhdr, cmsg) \
00579 (((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \
00580 _ALIGN(sizeof(struct cmsghdr)) > \
00581 (char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \
00582 (struct cmsghdr *)0 : \
00583 (struct cmsghdr *)((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len)))
00584
00585
00586
00587
00588
00589 #define CMSG_FIRSTHDR(mhdr) \
00590 ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \
00591 (struct cmsghdr *)(mhdr)->msg_control : \
00592 (struct cmsghdr *)NULL)
00593
00594 #if __BSD_VISIBLE
00595
00596 #define CMSG_SPACE(l) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
00597 #define CMSG_LEN(l) (_ALIGN(sizeof(struct cmsghdr)) + (l))
00598 #endif
00599
00600 #ifdef _KERNEL
00601 #define CMSG_ALIGN(n) _ALIGN(n)
00602 #endif
00603
00604
00605 #define SCM_RIGHTS 0x01
00606 #if __BSD_VISIBLE
00607 #define SCM_TIMESTAMP 0x02
00608 #define SCM_CREDS 0x03
00609 #define SCM_BINTIME 0x04
00610 #endif
00611
00612 #if __BSD_VISIBLE
00613
00614
00615
00616 struct osockaddr {
00617 unsigned short sa_family;
00618 char sa_data[14];
00619 };
00620
00621
00622
00623
00624 struct omsghdr {
00625 char *msg_name;
00626 int msg_namelen;
00627 struct iovec *msg_iov;
00628 int msg_iovlen;
00629 char *msg_accrights;
00630 int msg_accrightslen;
00631 };
00632 #endif
00633
00634
00635
00636
00637 #define SHUT_RD 0
00638 #define SHUT_WR 1
00639 #define SHUT_RDWR 2
00640
00641 #if __BSD_VISIBLE
00642
00643
00644
00645 struct sf_hdtr {
00646 struct iovec *headers;
00647 int hdr_cnt;
00648 struct iovec *trailers;
00649 int trl_cnt;
00650 };
00651
00652
00653
00654
00655 #define SF_NODISKIO 0x00000001
00656 #endif
00657
00658 #ifndef _KERNEL
00659
00660 #include <sys/cdefs.h>
00661
00662 __BEGIN_DECLS
00663 IMPORT_C int accept(int, struct sockaddr * __restrict, socklen_t * __restrict);
00664 IMPORT_C int bind(int, const struct sockaddr *, socklen_t);
00665 IMPORT_C int connect(int, const struct sockaddr *, socklen_t);
00666 IMPORT_C int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict);
00667 IMPORT_C int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict);
00668 IMPORT_C int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict);
00669 IMPORT_C int listen(int, int);
00670 IMPORT_C ssize_t recv(int, void *, size_t, int);
00671 IMPORT_C ssize_t recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, socklen_t * __restrict);
00672 IMPORT_C ssize_t recvmsg(int, struct msghdr *, int);
00673 IMPORT_C ssize_t send(int, const void *, size_t, int);
00674 IMPORT_C ssize_t sendto(int, const void *,
00675 size_t, int, const struct sockaddr *, socklen_t);
00676 IMPORT_C ssize_t sendmsg(int, const struct msghdr *, int);
00677 IMPORT_C int setsockopt(int, int, int, const void *, socklen_t);
00678 IMPORT_C int shutdown(int, int);
00679 IMPORT_C int sockatmark(int);
00680 IMPORT_C int socket(int, int, int);
00681 __END_DECLS
00682
00683 #endif
00684
00685 #endif