2017-10-18 16:15:51 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2019-11-19 09:40:26 +00:00
|
|
|
Copyright (c) 2014-2019 Chung, Hyung-Hwan. All rights reserved.
|
2017-10-18 16:15:51 +00:00
|
|
|
|
|
|
|
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 "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 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 _MOO_MOD_SCK_H_
|
|
|
|
#define _MOO_MOD_SCK_H_
|
|
|
|
|
|
|
|
#include <moo.h>
|
|
|
|
|
|
|
|
typedef struct sck_t* oop_sck_t;
|
|
|
|
struct sck_t
|
|
|
|
{
|
|
|
|
MOO_OBJ_HEADER;
|
|
|
|
|
|
|
|
moo_oop_t handle; /* SmallInteger */
|
|
|
|
/* there are more fields in the actual object */
|
|
|
|
};
|
|
|
|
|
2018-01-11 16:29:43 +00:00
|
|
|
#if (MOO_SIZEOF_SOCKLEN_T == 1)
|
|
|
|
#if defined(MOO_SOCKLEN_T_IS_SIGNED)
|
|
|
|
typedef moo_int8_t sck_len_t;
|
|
|
|
#else
|
|
|
|
typedef moo_uint8_t sck_len_t;
|
|
|
|
#endif
|
|
|
|
#elif (MOO_SIZEOF_SOCKLEN_T == 2)
|
|
|
|
#if defined(MOO_SOCKLEN_T_IS_SIGNED)
|
|
|
|
typedef moo_int16_t sck_len_t;
|
|
|
|
#else
|
|
|
|
typedef moo_uint16_t sck_len_t;
|
|
|
|
#endif
|
|
|
|
#elif (MOO_SIZEOF_SOCKLEN_T == 4)
|
|
|
|
#if defined(MOO_SOCKLEN_T_IS_SIGNED)
|
|
|
|
typedef moo_int32_t sck_len_t;
|
|
|
|
#else
|
|
|
|
typedef moo_uint32_t sck_len_t;
|
|
|
|
#endif
|
|
|
|
#elif (MOO_SIZEOF_SOCKLEN_T == 8)
|
|
|
|
#if defined(MOO_SOCKLEN_T_IS_SIGNED)
|
|
|
|
typedef moo_int64_t sck_len_t;
|
|
|
|
#else
|
|
|
|
typedef moo_uint64_t sck_len_t;
|
|
|
|
#endif
|
|
|
|
#else
|
2018-01-19 09:33:47 +00:00
|
|
|
# undef MOO_SIZEOF_SOCKLEN_T
|
2018-01-17 02:57:03 +00:00
|
|
|
# define MOO_SIZEOF_SOCKLEN_T MOO_SIZEOF_INT
|
|
|
|
# define MOO_SOCKLEN_T_IS_SIGNED
|
|
|
|
typedef int sck_len_t;
|
2018-01-11 16:29:43 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (MOO_SIZEOF_SA_FAMILY_T == 1)
|
|
|
|
#if defined(MOO_SA_FAMILY_T_IS_SIGNED)
|
|
|
|
typedef moo_int8_t sck_addr_family_t;
|
|
|
|
#else
|
|
|
|
typedef moo_uint8_t sck_addr_family_t;
|
|
|
|
#endif
|
|
|
|
#elif (MOO_SIZEOF_SA_FAMILY_T == 2)
|
|
|
|
#if defined(MOO_SA_FAMILY_T_IS_SIGNED)
|
|
|
|
typedef moo_int16_t sck_addr_family_t;
|
|
|
|
#else
|
|
|
|
typedef moo_uint16_t sck_addr_family_t;
|
|
|
|
#endif
|
|
|
|
#elif (MOO_SIZEOF_SA_FAMILY_T == 4)
|
|
|
|
#if defined(MOO_SA_FAMILY_T_IS_SIGNED)
|
|
|
|
typedef moo_int32_t sck_addr_family_t;
|
|
|
|
#else
|
|
|
|
typedef moo_uint32_t sck_addr_family_t;
|
|
|
|
#endif
|
|
|
|
#elif (MOO_SIZEOF_SA_FAMILY_T == 8)
|
|
|
|
#if defined(MOO_SA_FAMILY_T_IS_SIGNED)
|
|
|
|
typedef moo_int64_t sck_addr_family_t;
|
|
|
|
#else
|
|
|
|
typedef moo_uint64_t sck_addr_family_t;
|
|
|
|
#endif
|
|
|
|
#else
|
2018-01-19 09:33:47 +00:00
|
|
|
# undef MOO_SIZEOF_SA_FAMILY_T
|
2018-01-19 13:29:15 +00:00
|
|
|
# define MOO_SIZEOF_SA_FAMILY_T MOO_SIZEOF_SHORT
|
|
|
|
# undef MOO_SA_FAMILY_T_IS_SIGNED
|
|
|
|
typedef unsigned short int sck_addr_family_t;
|
2018-01-11 16:29:43 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
struct sck_addr_t
|
|
|
|
{
|
2018-02-01 06:03:01 +00:00
|
|
|
#if defined(MOO_OFFSETOF_SA_FAMILY) && (MOO_OFFSETOF_SA_FAMILY > 0)
|
|
|
|
moo_uint8_t filler[MOO_OFFSETOF_SA_FAMILY];
|
|
|
|
#endif
|
2018-01-11 16:29:43 +00:00
|
|
|
sck_addr_family_t family;
|
|
|
|
moo_uint8_t data[1];
|
|
|
|
};
|
|
|
|
typedef struct sck_addr_t sck_addr_t;
|
2017-12-30 19:07:31 +00:00
|
|
|
|
2017-10-18 16:15:51 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
MOO_EXPORT int moo_mod_sck (moo_t* moo, moo_mod_t* mod);
|
2017-12-30 19:07:31 +00:00
|
|
|
MOO_EXPORT int moo_mod_sck_addr (moo_t* moo, moo_mod_t* mod);
|
2017-10-18 16:15:51 +00:00
|
|
|
|
2018-01-12 16:06:05 +00:00
|
|
|
|
|
|
|
sck_len_t moo_sck_addr_len (sck_addr_t* addr);
|
|
|
|
|
2017-10-18 16:15:51 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|