added mio_skad_init_for_ip_with_bytes()
This commit is contained in:
parent
56315ef7c5
commit
b1c205626a
@ -164,8 +164,8 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/ar-lib \
|
|||||||
$(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \
|
$(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \
|
||||||
$(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \
|
$(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \
|
||||||
$(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing ac/ar-lib \
|
$(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing ac/ar-lib \
|
||||||
ac/compile ac/config.guess ac/config.sub ac/install-sh \
|
ac/compile ac/config.guess ac/config.sub ac/depcomp \
|
||||||
ac/ltmain.sh ac/missing
|
ac/install-sh ac/ltmain.sh ac/missing
|
||||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
distdir = $(PACKAGE)-$(VERSION)
|
distdir = $(PACKAGE)-$(VERSION)
|
||||||
top_distdir = $(distdir)
|
top_distdir = $(distdir)
|
||||||
|
@ -147,6 +147,13 @@ MIO_EXPORT void mio_skad_init_for_ip6 (
|
|||||||
int scope_id
|
int scope_id
|
||||||
);
|
);
|
||||||
|
|
||||||
|
MIO_EXPORT void mio_skad_init_for_ip_with_bytes (
|
||||||
|
mio_skad_t* skad,
|
||||||
|
mio_uint16_t port,
|
||||||
|
const mio_uint8_t* bytes,
|
||||||
|
mio_oow_t len
|
||||||
|
);
|
||||||
|
|
||||||
MIO_EXPORT void mio_skad_init_for_eth (
|
MIO_EXPORT void mio_skad_init_for_eth (
|
||||||
mio_skad_t* skad,
|
mio_skad_t* skad,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
|
@ -1385,11 +1385,10 @@ void mio_skad_init_for_ip4 (mio_skad_t* skad, mio_uint16_t port, mio_ip4ad_t* ip
|
|||||||
{
|
{
|
||||||
#if (MIO_SIZEOF_STRUCT_SOCKADDR_IN > 0)
|
#if (MIO_SIZEOF_STRUCT_SOCKADDR_IN > 0)
|
||||||
struct sockaddr_in* sin = (struct sockaddr_in*)skad;
|
struct sockaddr_in* sin = (struct sockaddr_in*)skad;
|
||||||
|
|
||||||
MIO_MEMSET (sin, 0, MIO_SIZEOF(*sin));
|
MIO_MEMSET (sin, 0, MIO_SIZEOF(*sin));
|
||||||
sin->sin_family = AF_INET;
|
sin->sin_family = AF_INET;
|
||||||
sin->sin_port = htons(port);
|
sin->sin_port = mio_hton16(port);
|
||||||
if (ip4ad) MIO_MEMCPY (&sin->sin_addr, ip4ad, MIO_IP4ADDR_LEN);
|
if (ip4ad) MIO_MEMCPY (&sin->sin_addr, ip4ad->v, MIO_IP4ADDR_LEN);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1397,15 +1396,46 @@ void mio_skad_init_for_ip6 (mio_skad_t* skad, mio_uint16_t port, mio_ip6ad_t* ip
|
|||||||
{
|
{
|
||||||
#if (MIO_SIZEOF_STRUCT_SOCKADDR_IN6 > 0)
|
#if (MIO_SIZEOF_STRUCT_SOCKADDR_IN6 > 0)
|
||||||
struct sockaddr_in6* sin = (struct sockaddr_in6*)skad;
|
struct sockaddr_in6* sin = (struct sockaddr_in6*)skad;
|
||||||
|
|
||||||
MIO_MEMSET (sin, 0, MIO_SIZEOF(*sin));
|
MIO_MEMSET (sin, 0, MIO_SIZEOF(*sin));
|
||||||
sin->sin6_family = AF_INET;
|
sin->sin6_family = AF_INET6;
|
||||||
sin->sin6_port = htons(port);
|
sin->sin6_port = mio_hton16(port);
|
||||||
sin->sin6_scope_id = scope_id;
|
sin->sin6_scope_id = scope_id;
|
||||||
if (ip6ad) MIO_MEMCPY (&sin->sin6_addr, ip6ad, MIO_IP6ADDR_LEN);
|
if (ip6ad) MIO_MEMCPY (&sin->sin6_addr, ip6ad->v, MIO_IP6ADDR_LEN);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mio_skad_init_for_ip_with_bytes (mio_skad_t* skad, mio_uint16_t port, const mio_uint8_t* bytes, mio_oow_t len)
|
||||||
|
{
|
||||||
|
switch (len)
|
||||||
|
{
|
||||||
|
#if (MIO_SIZEOF_STRUCT_SOCKADDR_IN > 0)
|
||||||
|
case MIO_IP4ADDR_LEN:
|
||||||
|
{
|
||||||
|
struct sockaddr_in* sin = (struct sockaddr_in*)skad;
|
||||||
|
MIO_MEMSET (sin, 0, MIO_SIZEOF(*sin));
|
||||||
|
sin->sin_family = AF_INET;
|
||||||
|
sin->sin_port = mio_hton16(port);
|
||||||
|
MIO_MEMCPY (&sin->sin_addr, bytes, len);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if (MIO_SIZEOF_STRUCT_SOCKADDR_IN6 > 0)
|
||||||
|
case MIO_IP6ADDR_LEN:
|
||||||
|
{
|
||||||
|
struct sockaddr_in6* sin = (struct sockaddr_in6*)skad;
|
||||||
|
MIO_MEMSET (sin, 0, MIO_SIZEOF(*sin));
|
||||||
|
sin->sin6_family = AF_INET6;
|
||||||
|
sin->sin6_port = mio_hton16(port);
|
||||||
|
MIO_MEMCPY (&sin->sin6_addr, bytes, len);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void mio_skad_init_for_eth (mio_skad_t* skad, int ifindex, mio_ethaddr_t* ethaddr)
|
void mio_skad_init_for_eth (mio_skad_t* skad, int ifindex, mio_ethaddr_t* ethaddr)
|
||||||
{
|
{
|
||||||
#if defined(AF_PACKET) && (MIO_SIZEOF_STRUCT_SOCKADDR_LL > 0)
|
#if defined(AF_PACKET) && (MIO_SIZEOF_STRUCT_SOCKADDR_LL > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user