2020-02-16 14:23:27 +00:00
|
|
|
/*
|
2020-02-20 15:35:16 +00:00
|
|
|
Copyright (c) 2016-2020 Chung, Hyung-Hwan. All rights reserved.
|
2020-02-16 14:23:27 +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
|
2022-06-11 05:32:01 +00:00
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
2020-02-16 14:23:27 +00:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
#ifndef _HIO_NWIF_H_
|
|
|
|
#define _HIO_NWIF_H_
|
2020-02-16 14:23:27 +00:00
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
#include <hio.h>
|
|
|
|
#include <hio-skad.h>
|
2020-02-16 14:23:27 +00:00
|
|
|
|
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
typedef struct hio_ifcfg_t hio_ifcfg_t;
|
2020-02-16 14:23:27 +00:00
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
enum hio_ifcfg_flag_t
|
2020-02-16 14:23:27 +00:00
|
|
|
{
|
2021-07-22 07:43:01 +00:00
|
|
|
HIO_IFCFG_UP = (1 << 0),
|
|
|
|
HIO_IFCFG_RUNNING = (1 << 1),
|
|
|
|
HIO_IFCFG_BCAST = (1 << 2),
|
|
|
|
HIO_IFCFG_PTOP = (1 << 3), /* peer to peer */
|
|
|
|
HIO_IFCFG_LINKUP = (1 << 4),
|
|
|
|
HIO_IFCFG_LINKDOWN = (1 << 5)
|
2020-02-16 14:23:27 +00:00
|
|
|
};
|
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
enum hio_ifcfg_type_t
|
2020-02-16 14:23:27 +00:00
|
|
|
{
|
2021-07-22 07:43:01 +00:00
|
|
|
HIO_IFCFG_IN4 = HIO_AF_INET,
|
|
|
|
HIO_IFCFG_IN6 = HIO_AF_INET6
|
2020-02-16 14:23:27 +00:00
|
|
|
};
|
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
typedef enum hio_ifcfg_type_t hio_ifcfg_type_t;
|
|
|
|
struct hio_ifcfg_t
|
2020-02-16 14:23:27 +00:00
|
|
|
{
|
2021-07-22 07:43:01 +00:00
|
|
|
hio_ifcfg_type_t type; /* in */
|
|
|
|
hio_ooch_t name[64]; /* in/out */
|
2020-02-16 14:23:27 +00:00
|
|
|
unsigned int index; /* in/out */
|
|
|
|
|
|
|
|
/* ---------------- */
|
|
|
|
int flags; /* out */
|
|
|
|
int mtu; /* out */
|
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
hio_skad_t addr; /* out */
|
|
|
|
hio_skad_t mask; /* out */
|
|
|
|
hio_skad_t ptop; /* out */
|
|
|
|
hio_skad_t bcast; /* out */
|
2020-02-16 14:23:27 +00:00
|
|
|
|
|
|
|
/* ---------------- */
|
|
|
|
|
|
|
|
/* TODO: add hwaddr?? */
|
|
|
|
/* i support ethernet only currently */
|
2021-07-22 07:43:01 +00:00
|
|
|
hio_uint8_t ethw[6]; /* out */
|
2020-02-16 14:23:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
HIO_EXPORT int hio_bcstrtoifindex (
|
|
|
|
hio_t* hio,
|
|
|
|
const hio_bch_t* ptr,
|
2020-02-16 14:23:27 +00:00
|
|
|
unsigned int* index
|
|
|
|
);
|
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
HIO_EXPORT int hio_bcharstoifindex (
|
|
|
|
hio_t* hio,
|
|
|
|
const hio_bch_t* ptr,
|
|
|
|
hio_oow_t len,
|
2020-02-16 14:23:27 +00:00
|
|
|
unsigned int* index
|
|
|
|
);
|
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
HIO_EXPORT int hio_ucstrtoifindex (
|
|
|
|
hio_t* hio,
|
|
|
|
const hio_uch_t* ptr,
|
2020-02-16 14:23:27 +00:00
|
|
|
unsigned int* index
|
|
|
|
);
|
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
HIO_EXPORT int hio_ucharstoifindex (
|
|
|
|
hio_t* hio,
|
|
|
|
const hio_uch_t* ptr,
|
|
|
|
hio_oow_t len,
|
2020-02-16 14:23:27 +00:00
|
|
|
unsigned int* index
|
|
|
|
);
|
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
HIO_EXPORT int hio_ifindextobcstr (
|
|
|
|
hio_t* hio,
|
2020-02-16 14:23:27 +00:00
|
|
|
unsigned int index,
|
2021-07-22 07:43:01 +00:00
|
|
|
hio_bch_t* buf,
|
|
|
|
hio_oow_t len
|
2020-02-16 14:23:27 +00:00
|
|
|
);
|
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
HIO_EXPORT int hio_ifindextoucstr (
|
|
|
|
hio_t* hio,
|
2020-02-16 14:23:27 +00:00
|
|
|
unsigned int index,
|
2021-07-22 07:43:01 +00:00
|
|
|
hio_uch_t* buf,
|
|
|
|
hio_oow_t len
|
2020-02-16 14:23:27 +00:00
|
|
|
);
|
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
#if defined(HIO_OOCH_IS_UCH)
|
|
|
|
# define hio_oocstrtoifindex hio_ucstrtoifindex
|
|
|
|
# define hio_oocharstoifindex hio_ucharstoifindex
|
|
|
|
# define hio_ifindextooocstr hio_ifindextoucstr
|
2020-02-16 14:23:27 +00:00
|
|
|
#else
|
2021-07-22 07:43:01 +00:00
|
|
|
# define hio_oocstrtoifindex hio_bcstrtoifindex
|
|
|
|
# define hio_oocharstoifindex hio_bcharstoifindex
|
|
|
|
# define hio_ifindextooocstr hio_ifindextobcstr
|
2020-02-16 14:23:27 +00:00
|
|
|
#endif
|
|
|
|
|
2021-07-22 07:43:01 +00:00
|
|
|
HIO_EXPORT int hio_getifcfg (
|
|
|
|
hio_t* hio,
|
|
|
|
hio_ifcfg_t* cfg
|
2020-02-16 14:23:27 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|