adding some dhcp code
This commit is contained in:
parent
4169ef924b
commit
37a3bb5ea8
@ -35,7 +35,7 @@ struct hio_svc_dhcs_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
hio_svc_dhcs_t* hio_svc_dhcs_start (hio_t* hio/*, hio_dev_sck_bind_t* sck_bind*/)
|
hio_svc_dhcs_t* hio_svc_dhcs_start (hio_t* hio, const hio_skad_t* local_binds, hio_oow_t local_nbinds)
|
||||||
{
|
{
|
||||||
hio_svc_dhcs_t* dhcs;
|
hio_svc_dhcs_t* dhcs;
|
||||||
union
|
union
|
||||||
@ -43,31 +43,35 @@ hio_svc_dhcs_t* hio_svc_dhcs_start (hio_t* hio/*, hio_dev_sck_bind_t* sck_bind*/
|
|||||||
hio_dev_sck_make_t m;
|
hio_dev_sck_make_t m;
|
||||||
hio_dev_sck_listen_t l;
|
hio_dev_sck_listen_t l;
|
||||||
} info;
|
} info;
|
||||||
|
hio_oow_t i;
|
||||||
|
|
||||||
dhcs = (hio_svc_dhcs_t*)hio_callocmem(hio, HIO_SIZEOF(*dhcs));
|
dhcs = (hio_svc_dhcs_t*)hio_callocmem(hio, HIO_SIZEOF(*dhcs));
|
||||||
if (HIO_UNLIKELY(!dhcs)) goto oops;
|
if (HIO_UNLIKELY(!dhcs)) goto oops;
|
||||||
|
|
||||||
dhcs->hio = hio;
|
dhcs->hio = hio;
|
||||||
|
|
||||||
HIO_MEMSET (&info, 0, HIO_SIZEOF(info));
|
for (i = 0; i < local_nbinds; i++)
|
||||||
info.m.type = HIO_DEV_SCK_UDP6;
|
{
|
||||||
info.m.options = HIO_DEV_SCK_BIND_REUSEADDR | HIO_DEV_SCK_BIND_REUSEPORT | HIO_DEV_SCK_BIND_IGNERR;
|
HIO_MEMSET (&info, 0, HIO_SIZEOF(info));
|
||||||
//info.m.on_write =
|
info.m.type = HIO_DEV_SCK_UDP6;
|
||||||
//info.m.on_read = ...
|
info.m.options = HIO_DEV_SCK_BIND_REUSEADDR | HIO_DEV_SCK_BIND_REUSEPORT | HIO_DEV_SCK_BIND_IGNERR;
|
||||||
//info.m.on_connect = ...
|
//info.m.on_write =
|
||||||
//info.m.on_disconnect = ...
|
//info.m.on_read = ...
|
||||||
dhcs->sck = hio_dev_sck_make(hio, 0, &info.m);
|
//info.m.on_connect = ...
|
||||||
if (HIO_UNLIKELY(!dhcs->sck)) goto oops;
|
//info.m.on_disconnect = ...
|
||||||
|
dhcs->sck = hio_dev_sck_make(hio, 0, &info.m);
|
||||||
|
if (HIO_UNLIKELY(!dhcs->sck)) goto oops;
|
||||||
|
|
||||||
#if defined(IPV6_RECVPKTINFO)
|
#if defined(IPV6_RECVPKTINFO)
|
||||||
hio_dev_sck_setsockopt (dhcs->sck, IPPROTO_IPV6, IPV6_RECVPKTINFO, &v);
|
hio_dev_sck_setsockopt (dhcs->sck, IPPROTO_IPV6, IPV6_RECVPKTINFO, &v);
|
||||||
#elif defined(IPV6_PKTINFO)
|
#elif defined(IPV6_PKTINFO)
|
||||||
hio_dev_sck_setsockopt (dhcs->sck, IPPROTO_IPV6, IPV6_PKTINFO, &v);
|
hio_dev_sck_setsockopt (dhcs->sck, IPPROTO_IPV6, IPV6_PKTINFO, &v);
|
||||||
#else
|
#else
|
||||||
//# error no ipv6 pktinfo
|
//# error no ipv6 pktinfo
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//hio_dev_sck_bind(dhcs->sck, )
|
hio_dev_sck_bind(dhcs->sck, &local_binds[i]);
|
||||||
|
}
|
||||||
|
|
||||||
HIO_SVCL_APPEND_SVC (&hio->actsvc, (hio_svc_t*)dhcs);
|
HIO_SVCL_APPEND_SVC (&hio->actsvc, (hio_svc_t*)dhcs);
|
||||||
return dhcs;
|
return dhcs;
|
||||||
|
@ -107,7 +107,11 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
HIO_EXPORT hio_svc_dhcs_t* hio_svc_dhcs_start (
|
HIO_EXPORT hio_svc_dhcs_t* hio_svc_dhcs_start (
|
||||||
hio_t* hio
|
hio_t* hio,
|
||||||
|
const hio_skad_t* local_binds,
|
||||||
|
hio_oow_t local_nbinds
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
,
|
,
|
||||||
const hio_skad_t* serv_addr, /* required */
|
const hio_skad_t* serv_addr, /* required */
|
||||||
|
Loading…
Reference in New Issue
Block a user