D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
proc
/
self
/
root
/
home
/
vblioqus
/
karachi777.vip
/
in
/
106014
/
900508
/
Filename :
bsock.zip
back
Copy
PK �j\ �˔� � bsock_addrinfo.hnu ��6�$ /* * bsock_addrinfo - struct addrinfo string manipulation * * Copyright (c) 2011, Glue Logic LLC. All rights reserved. code()gluelogic.com * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 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. * * Neither the name of Glue Logic LLC nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 <COPYRIGHT HOLDER> 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. */ #ifndef INCLUDED_BSOCK_ADDRINFO_H #define INCLUDED_BSOCK_ADDRINFO_H #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <stdbool.h> #ifdef __cplusplus extern "C" { #endif #if defined(_AIX) && !defined(_ALL_SOURCE) /* #define _ALL_SOURCE required for definition of struct addrinfo on AIX (!) */ /* !!Differs!! from Single Unix Specification SUSv6 (from 2004!) * http://pubs.opengroup.org/onlinepubs/009695399/basedefs/netdb.h.html */ struct addrinfo { /* AIX struct addrinfo DIFFERS FROM POSIX STANDARD! */ int ai_flags; int ai_family; int ai_socktype; int ai_protocol; size_t ai_addrlen; /* socklen_t in standard */ char *ai_canonname; /* order swapped with ai_addr in standard */ struct sockaddr *ai_addr; /* order swapped with ai_cannonname in standard*/ struct addrinfo *ai_next; }; #define AI_PASSIVE 0x02 /* specific to AIX */ #endif struct bsock_addrinfo_strs { const char *family; const char *socktype; const char *protocol; const char *service; const char *addr; }; /* ai->ai_addr must be provided containing usable storage of len ai->ai_addrlen * (recommended: #include <sys/socket.h> and use struct sockaddr_storage) */ bool __attribute__((nonnull)) bsock_addrinfo_from_strs(struct addrinfo * const restrict ai, const struct bsock_addrinfo_strs * const restrict aistr); bool __attribute__((nonnull)) bsock_addrinfo_to_strs(const struct addrinfo * const restrict ai, struct bsock_addrinfo_strs * const aistr, char * const restrict buf, const size_t bufsz); bool __attribute__((nonnull)) bsock_addrinfo_split_str(struct bsock_addrinfo_strs * const aistr, char * const restrict str); bool __attribute__((nonnull (2,3))) bsock_addrinfo_recv_ex (const int fd, struct addrinfo * const restrict ai, int * const restrict rfd, char * const restrict ctrlbuf, const size_t ctrlbuf_sz); #define bsock_addrinfo_recv(fd, ai, rfd) \ bsock_addrinfo_recv_ex((fd),(ai),(rfd),0,0) bool __attribute__((nonnull)) bsock_addrinfo_send (const int fd, const struct addrinfo * const restrict ai, const int sfd); #ifdef __cplusplus } #endif #endif PK �j\x��M� � bsock_daemon.hnu ��6�$ /* * bsock_daemon - daemon initialization and signal setup * * Copyright (c) 2011, Glue Logic LLC. All rights reserved. code()gluelogic.com * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 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. * * Neither the name of Glue Logic LLC nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 <COPYRIGHT HOLDER> 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. */ #ifndef INCLUDED_BSOCK_DAEMON_H #define INCLUDED_BSOCK_DAEMON_H #include <sys/types.h> #include <stdbool.h> #ifdef __cplusplus extern "C" { #endif bool bsock_daemon_setuid_stdinit (void); bool bsock_daemon_init (const int supervised, const bool check); int __attribute__((nonnull)) bsock_daemon_init_socket (const char * const restrict sockpath, /*(persistent)*/ const uid_t uid, const gid_t gid, const mode_t mode); size_t bsock_daemon_msg_control_max (void); #ifdef __cplusplus } #endif #endif PK �j\[���� � bsock_bind.hnu ��6�$ /* * bsock_bind - interfaces to bind to reserved ports * * Copyright (c) 2011, Glue Logic LLC. All rights reserved. code()gluelogic.com * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 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. * * Neither the name of Glue Logic LLC nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 <COPYRIGHT HOLDER> 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. */ #ifndef INCLUDED_BSOCK_BIND_H #define INCLUDED_BSOCK_BIND_H #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #ifdef _AIX #include "bsock_addrinfo.h" /* struct addrinfo */ #endif #ifdef __cplusplus extern "C" { #endif int __attribute__((nonnull)) bsock_bind_addrinfo (const int fd, const struct addrinfo * const restrict ai); #ifdef __cplusplus } #endif #endif PK �j\y�2 2 bsock_unix.hnu ��6�$ /* * bsock_unix - unix domain socket sendmsg and recvmsg wrappers * * Copyright (c) 2011, Glue Logic LLC. All rights reserved. code()gluelogic.com * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 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. * * Neither the name of Glue Logic LLC nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 <COPYRIGHT HOLDER> 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. */ #ifndef INCLUDED_BSOCK_UNIX_H #define INCLUDED_BSOCK_UNIX_H #include <sys/types.h> #include <sys/uio.h> #ifdef __cplusplus extern "C" { #endif /* bsock stack allocation for recvmsg() ancillary data * On Linux, maximum length of ancillary data and user control data is set in * /proc/sys/net/core/optmem_max (man 3 cmsg, man 7 socket); customarily 10240. * RFC 3542: Advanced Sockets Application Program Interface (API) for IPv6 * RFC 3542 min ancillary data is 10240; recommends getsockopt SO_SNDBUF * (traditional BSD mbuf is 108, which is way too small for RFC 3542 spec) * * The reason this setting is important is because a client can send many file * descriptors. On Linux, even if recvmsg() reports MSG_CTRUNC, the file * descriptors that the client sent are still received by the server process * (up to sysconf(_SC_OPEN_MAX)), resulting in leakage of file descriptors * unless process takes extra measures to close fds it does not know about. * Such an undertaking is difficult to do correctly since process might not * know which fds have been opened by lower-level libraries, e.g. to syslog, * nscd, /etc/protocols, /etc/services, etc. Setting this buffer size to the * maximum allowed means that MSG_CTRUNC should not be possible. (Take care * if increasing size since buffer is allocated on stack (as of this writing.) * On Linux, client can send the same descriptor many times and it will be * dup'd and received many times by server. On Linux, there appears to be a * maximum of 255 file descriptors that can be sent with sendmsg() over unix * domain sockets, whether in one or many separate ancillary control buffers. * On Linux, these ancillary control buffers appear to be independent of * SO_RCVBUF and SO_SNDBUF sizes of either client or server; limiting size of * SO_RCVBUF and SO_SNDBUF has no effect on size of ancillary control buffers. * In any case, allocating /proc/sys/net/core/optmem_max for ancillary control * buffers prevents the possibility of MSG_CTRUNC on Linux. */ #ifndef BSOCK_ANCILLARY_DATA_MAX #define BSOCK_ANCILLARY_DATA_MAX 10240 #endif int __attribute__((nonnull)) bsock_unix_socket_connect (const char * const restrict sockpath); int __attribute__((nonnull)) bsock_unix_socket_bind_listen (const char * const restrict sockpath, int * const restrict bound); ssize_t __attribute__((nonnull (4))) bsock_unix_recv_fds (const int fd, int * const restrict rfds, unsigned int * const restrict nrfds, struct iovec * const restrict iov, const size_t iovlen); ssize_t __attribute__((nonnull (4,6))) bsock_unix_recv_fds_ex (const int fd, int * const restrict rfds, unsigned int * const restrict nrfds, struct iovec * const restrict iov, const size_t iovlen, char * const restrict ctrlbuf, const size_t ctrlbuf_sz); ssize_t __attribute__((nonnull (4))) bsock_unix_send_fds (const int fd, const int * const restrict sfds, unsigned int nsfds, struct iovec * const restrict iov, const size_t iovlen); int __attribute__((nonnull)) bsock_unix_getpeereid (const int s, uid_t * const restrict euid, gid_t * const restrict egid); #ifdef __cplusplus } #endif #endif PK �j\rpZ�� � bsock_syslog.hnu ��6�$ /* * bsock_syslog - syslog() wrapper for error messages * * Copyright (c) 2011, Glue Logic LLC. All rights reserved. code()gluelogic.com * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 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. * * Neither the name of Glue Logic LLC nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 <COPYRIGHT HOLDER> 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. */ #ifndef INCLUDED_BSOCK_SYSLOG_H #define INCLUDED_BSOCK_SYSLOG_H #include <sys/types.h> /*(for __GNUC_PREREQ(), if available)*/ #ifndef __has_attribute #define __has_attribute(x) 0 #endif #ifndef __GNUC_PREREQ # ifdef __GNUC_PREREQ__ # define __GNUC_PREREQ __GNUC_PREREQ__ # elif defined __GNUC__ && defined __GNUC_MINOR__ # define __GNUC_PREREQ(maj, min) \ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) # else # define __GNUC_PREREQ(maj, min) 0 # endif #endif #if __GNUC_PREREQ(4,3) || __has_attribute(cold) #ifndef __attribute_cold__ #define __attribute_cold__ __attribute__ ((cold)) #endif #endif #ifndef __attribute_cold__ #define __attribute_cold__ #endif #ifdef __cplusplus extern "C" { #endif enum { BSOCK_SYSLOG_DAEMON = 0, BSOCK_SYSLOG_PERROR = 1, BSOCK_SYSLOG_PERROR_NOSYSLOG = 2 }; void __attribute_cold__ bsock_syslog_setlevel (const int level); void __attribute_cold__ bsock_syslog_setlogfd (const int fd); void __attribute_cold__ bsock_syslog_openlog (const char * const ident, const int option, const int facility); void __attribute_cold__ __attribute__((format(printf,3,4))) bsock_syslog (const int errnum, const int priority, const char * const restrict fmt, ...); #ifdef __cplusplus } #endif #endif PK �j\ �˔� � bsock_addrinfo.hnu ��6�$ PK �j\x��M� � bsock_daemon.hnu ��6�$ PK �j\[���� � � bsock_bind.hnu ��6�$ PK �j\y�2 2 ! bsock_unix.hnu ��6�$ PK �j\rpZ�� � w5 bsock_syslog.hnu ��6�$ PK � 7A