OpenSS7
SS7 for the
Common Man

© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved.
Last modified:

Home Overview Status News Documentation Resources About
   
 Overview
 Status
 News
 Documentation
 Resources
 About

   
Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> strss7/lib/libsocket/socket.h


File /code/strss7/lib/libsocket/socket.h




#ifndef _SYS_SOCKET_H
#define _SYS_SOCKET_H

#include <sys/uio.h>

#ident "@(#) $Name:  $($Revision: 0.8 $) Copyright (c) 1997-2002 OpenSS7 Corporation."

typedef size_t socklen_t;
typedef unsigned int sa_family_t;

struct sockaddr
{
	sa_family_t	sa_family;  /* address family */
	char		sa_data[0]; /* socket address (variable-length data) */
};

/*
 * Desired design of maximum size and alignment
 */
#define _SS_MAXSIZE 128 /* Implementation specific max size */
#define _SS_ALIGNSIZE (sizeof (int64_t))
               /* Implementation specific desired alignment */
/*
 * Definitions used for sockaddr_storage structure paddings design.
 */
#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof (sa_family_t))
#define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (sa_family_t) + _SS_PAD1SIZE + _SS_ALIGNSIZE))

struct sockaddr_storage
{
    sa_family_t  ss_family;     /* address family */
    /* Following fields are implementation specific */
    char _ss_pad1[_SS_PAD1SIZE];
              /* 6 byte pad, this is to make implementation */
              /* specific pad up to alignment field that */
              /* follows explicit in the data structure */
    int64_t _ss_align;     /* field to force desired structure */
                           /* storage alignment */
    char _ss_pad2[_SS_PAD2SIZE];
              /* 112 byte pad to achieve desired size, */
              /* _SS_MAXSIZE value minus size of ss_family */
              /* __ss_pad1, __ss_align fields is 112 */
};

struct msghdr
{
	void		*msg_name	/* optional address		*/
	socklen_t	msg_namelen	/* size of address		*/
	struct iovec	*msg_iov	/* scatter/gather array		*/
	int		msg_iovlen	/* members in msg_iov		*/
	void		*msg_control	/* ancillary data, see below	*/
	socklen_t	msg_controllen	/* ancillary data buffer len	*/
	int		msg_flags	/* flags on received message	*/
	/* impelemntation specific elements */
};


     The <sys/socket.h> header defines the cmsghdr structure that
     includes at least the following members:

struct cmsghdr
{
	socklen_t	cmsg_len	/* data byte count, including the cmsghdr	*/
	int		cmsg_level	/* originating protocol				*/
	int		cmsg_type	/* protocol-specific type			*/
};

#define SOL_SOCKET

#define	SCM_RIGHTS	0x01	/* rw: access rights (array of int)	*/
#define SCM_CREDENTIALS	0x02	/* rw: struct ucred			*/
#define SCM_CONNECT	0x03	/* rw: struct scm_connect		*/

/*
 *  CMSG_DATA(msg)
 *	If the argument is a pointer to a cmsghdr structure, this macro
 *	returns an unsigned character pointer to the data array associated
 *	with the cmsghdr structure.
 *
 *  CMSG_NXTHDR(mhdr, cmsg)
 *	If the first argument is a pointer to a msghdr structure and the
 *	second argument is a pointer to a cmsghdr structure in the ancillary
 *	data, pointed to by the msg_control field of that msghdr structure,
 *	this macro returns a pointer to the next cmsghdr structure, or a null
 *	pointer if this structure is the last cmsghdr in the ancillary data.
 *
 *  CMSG_FIRSTHDR(msg)
 *	If the argument is a pointer to a msghdr structure, this macro returns
 *	a pointer to the first cmsghdr structure in the ancillary data
 *	associated with this msghdr structure, or a null pointer if there is
 *	no ancillary data associated with the msghdr structure.
 */

#define __CMSG_NXTHDR(ctl, len, cmsg) __cmsg_nxthdr((ctl),(len),(cmsg))
#define CMSG_NXTHDR(mhdr, cmsg) cmsg_nxthdr((mhdr), (cmsg))

#define CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) )

#define CMSG_DATA(cmsg)	((void *)((char *)(cmsg) + CMSG_ALIGN(sizeof(struct cmsghdr))))
#define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len))
#define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))

#define __CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct cmsghdr) ? \
				  (struct cmsghdr *)(ctl) : \
				  (struct cmsghdr *)NULL)
#define CMSG_FIRSTHDR(msg)	__CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)

struct linger
{
	int	l_onoff		/* indicates whether linger option is enabled	*/
	int	l_linger	/* linger time, in seconds			*/
};

#define SOCK_DGRAM	1		/* Datagram socket		*/
#define SOCK_STREAM	2		/* Byte-stream socket		*/
#define SOCK_SEQPACKET	3		/* Sequenced-packet socket	*/
#define SOCK_RDM	4		/* reliably-delivered message	*/
#define SOCK_RAW	5		/* raw socket			*/

#define SOL_SOCKET	1

#define SO_ACCEPTCONN		/* Socket is accepting connections.			*/
#define SO_BROADCAST	6	/* Transmission of broadcast messages is supported.	*/
#define SO_DEBUG	1	/* Debugging information is being recorded.		*/
#define SO_DONTROUTE	5	/* bypass normal routing				*/
#define SO_ERROR	4	/* Socket error status.					*/
#define SO_KEEPALIVE	9	/* Connections are kept alive with periodic messages.	*/
#define SO_LINGER	13	/* Socket lingers on close.				*/
#define SO_OOBINLINE	10	/* Out-of-band data is transmitted in line.		*/
#define SO_RCVBUF	8	/* Receive buffer size.					*/
#define SO_RCVLOWAT	18	/* receive "low water mark"				*/
#define SO_RCVTIMEO	20	/* receive timeout					*/
#define SO_REUSEADDR	2	/* Reuse of local addresses is supported.		*/
#define SO_SNDBUF	7	/* Send buffer size.					*/
#define SO_SNDLOWAT	19	/* send "low water mark"				*/
#define SO_SNDTIMEO	21	/* send timeout						*/
#define SO_TYPE		3	/* Socket type.						*/

#define SO_NO_CHECK	11
#define SO_PRIORITY	12
#define SO_BSDCOMPAT	14
#define SO_PASSCRED	16
#define SO_PEERCRED	17

#define MSG_CTRUNC	1	/* Control data truncated.				*/
#define MSG_DONTROUTE	2	/* Send without using routing tables.			*/
#define MSG_EOR		3	/* Terminates a record (if supported by the protocol).	*/
#define MSG_OOB		4	/* Out-of-band data.					*/
#define MSG_PEEK	5	/* Leave received data in queue.			*/
#define MSG_TRUNC	6	/* Normal data truncated.				*/
#define MSG_WAITALL	7	/* Wait for complete message.				*/

#define AF_UNIX		1	/* UNIX domain sockets					*/
#define AF_UNSPEC	2	/* Unspecified						*/
#define AF_INET		3	/* Internet domain sockets for use with IPv4 addresses	*/
#define AF_INET6	4	/* Internet domain sockets for use with IPv6 addresses	*/

#define SHUT_RD		1	/* Disables further receive operations.			*/
#define SHUT_WR		2	/* Disables further send operations.			*/
#define SHUT_RDWR	3	/* Disables further send and receive operations.	*/

int	accept		(int socket, struct sockaddr *address, socklen_t *address_len);
int	bind		(int socket, const struct sockaddr *address, socklen_t address_len);
int	connect		(int socket, const struct sockaddr *address, socklen_t address_len);
int	getpeername	(int socket, struct sockaddr *address, socklen_t *address_len);
int	getsockname	(int socket, struct sockaddr *address, socklen_t *address_len);
int	getsockopt	(int socket, int level, int option_name, void *option_value, socklen_t *option_len);
int	listen		(int socket, int backlog);
ssize_t	recv		(int socket, void *buffer, size_t length, int flags);
ssize_t	recvfrom	(int socket, void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len);
ssize_t	recvmsg		(int socket, struct msghdr *message, int flags);
ssize_t	send		(int socket, const void *message, size_t length, int flags);
ssize_t	sendmsg		(int socket, const struct msghdr *message, int flags);
ssize_t	sendto		(int socket, const void *message, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len);
int	setsockopt	(int socket, int level, int option_name, const void *option_value, socklen_t option_len);
int	shutdown	(int socket, int how);
int	socket		(int domain, int type, int protocol);
int	socketpair	(int domain, int type, int protocol, int socket_vector[2]);

#endif /* _SYS_SOCKET_H */


Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> strss7/lib/libsocket/socket.h

OpenSS7
SS7 for the
Common Man
Home Overview Status News Documentation Resources About

© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved.
Last modified: