added the bin directory and moves files for binary commands into it
This commit is contained in:
730
mio/bin/Makefile.in
Normal file
730
mio/bin/Makefile.in
Normal file
@ -0,0 +1,730 @@
|
||||
# Makefile.in generated by automake 1.15 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
*) echo "am__make_running_with_option: internal error: invalid" \
|
||||
"target option '$${target_option-}' specified" >&2; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
has_opt=no; \
|
||||
sane_makeflags=$$MAKEFLAGS; \
|
||||
if $(am__is_gnu_make); then \
|
||||
sane_makeflags=$$MFLAGS; \
|
||||
else \
|
||||
case $$MAKEFLAGS in \
|
||||
*\\[\ \ ]*) \
|
||||
bs=\\; \
|
||||
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
|
||||
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
|
||||
esac; \
|
||||
fi; \
|
||||
skip_next=no; \
|
||||
strip_trailopt () \
|
||||
{ \
|
||||
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
|
||||
}; \
|
||||
for flg in $$sane_makeflags; do \
|
||||
test $$skip_next = yes && { skip_next=no; continue; }; \
|
||||
case $$flg in \
|
||||
*=*|--*) continue;; \
|
||||
-*I) strip_trailopt 'I'; skip_next=yes;; \
|
||||
-*I?*) strip_trailopt 'I';; \
|
||||
-*O) strip_trailopt 'O'; skip_next=yes;; \
|
||||
-*O?*) strip_trailopt 'O';; \
|
||||
-*l) strip_trailopt 'l'; skip_next=yes;; \
|
||||
-*l?*) strip_trailopt 'l';; \
|
||||
-[dEDm]) skip_next=yes;; \
|
||||
-[JT]) skip_next=yes;; \
|
||||
esac; \
|
||||
case $$flg in \
|
||||
*$$target_option*) has_opt=yes; break;; \
|
||||
esac; \
|
||||
done; \
|
||||
test $$has_opt = yes
|
||||
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
|
||||
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
bin_PROGRAMS = mio-execd$(EXEEXT) mio-t01$(EXEEXT)
|
||||
subdir = bin
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
|
||||
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
|
||||
$(top_srcdir)/m4/ax_numval.m4 $(top_srcdir)/m4/libtool.m4 \
|
||||
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
|
||||
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/lib/mio-cfg.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
am__installdirs = "$(DESTDIR)$(bindir)"
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am_mio_execd_OBJECTS = mio_execd-execd.$(OBJEXT)
|
||||
mio_execd_OBJECTS = $(am_mio_execd_OBJECTS)
|
||||
am__DEPENDENCIES_1 =
|
||||
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
|
||||
mio_execd_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
|
||||
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
|
||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||
am__v_lt_0 = --silent
|
||||
am__v_lt_1 =
|
||||
mio_execd_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(mio_execd_LDFLAGS) $(LDFLAGS) -o $@
|
||||
am_mio_t01_OBJECTS = mio_t01-t01.$(OBJEXT)
|
||||
mio_t01_OBJECTS = $(am_mio_t01_OBJECTS)
|
||||
mio_t01_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
|
||||
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
|
||||
mio_t01_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(mio_t01_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||
am__v_P_0 = false
|
||||
am__v_P_1 = :
|
||||
AM_V_GEN = $(am__v_GEN_@AM_V@)
|
||||
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
am__v_GEN_1 =
|
||||
AM_V_at = $(am__v_at_@AM_V@)
|
||||
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
|
||||
am__v_at_0 = @
|
||||
am__v_at_1 =
|
||||
DEFAULT_INCLUDES =
|
||||
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CFLAGS) $(CFLAGS)
|
||||
AM_V_CC = $(am__v_CC_@AM_V@)
|
||||
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
|
||||
am__v_CC_0 = @echo " CC " $@;
|
||||
am__v_CC_1 =
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
|
||||
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
|
||||
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||
am__v_CCLD_1 =
|
||||
SOURCES = $(mio_execd_SOURCES) $(mio_t01_SOURCES)
|
||||
DIST_SOURCES = $(mio_execd_SOURCES) $(mio_t01_SOURCES)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
# Read a list of newline-separated strings from the standard input,
|
||||
# and print each of them once, without duplicates. Input order is
|
||||
# *not* preserved.
|
||||
am__uniquify_input = $(AWK) '\
|
||||
BEGIN { nonempty = 0; } \
|
||||
{ items[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in items) print i; }; } \
|
||||
'
|
||||
# Make sure the list of sources is unique. This is necessary because,
|
||||
# e.g., the same source file might be shared among _SOURCES variables
|
||||
# for different programs/libraries.
|
||||
am__define_uniq_tagged_files = \
|
||||
list='$(am__tagged_files)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/depcomp
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
BUILD_MODE = @BUILD_MODE@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_CXX = @HAVE_CXX@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBM = @LIBM@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIBTOOL_DEPS = @LIBTOOL_DEPS@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MIO_PROJECT_AUTHOR = @MIO_PROJECT_AUTHOR@
|
||||
MIO_PROJECT_URL = @MIO_PROJECT_URL@
|
||||
MIO_SIZEOF_CHAR = @MIO_SIZEOF_CHAR@
|
||||
MIO_SIZEOF_DOUBLE = @MIO_SIZEOF_DOUBLE@
|
||||
MIO_SIZEOF_FLOAT = @MIO_SIZEOF_FLOAT@
|
||||
MIO_SIZEOF_INT = @MIO_SIZEOF_INT@
|
||||
MIO_SIZEOF_LONG = @MIO_SIZEOF_LONG@
|
||||
MIO_SIZEOF_LONG_DOUBLE = @MIO_SIZEOF_LONG_DOUBLE@
|
||||
MIO_SIZEOF_LONG_LONG = @MIO_SIZEOF_LONG_LONG@
|
||||
MIO_SIZEOF_OFF64_T = @MIO_SIZEOF_OFF64_T@
|
||||
MIO_SIZEOF_OFF_T = @MIO_SIZEOF_OFF_T@
|
||||
MIO_SIZEOF_SHORT = @MIO_SIZEOF_SHORT@
|
||||
MIO_SIZEOF_VOID_P = @MIO_SIZEOF_VOID_P@
|
||||
MIO_SIZEOF_WCHAR_T = @MIO_SIZEOF_WCHAR_T@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
|
||||
PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
|
||||
PACKAGE_VERSION_PATCH = @PACKAGE_VERSION_PATCH@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
QUADMATH_LIBS = @QUADMATH_LIBS@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SENDFILE_LIBS = @SENDFILE_LIBS@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
SOCKET_LIBS = @SOCKET_LIBS@
|
||||
SSL_LIBS = @SSL_LIBS@
|
||||
STRIP = @STRIP@
|
||||
UNICOWS_LIBS = @UNICOWS_LIBS@
|
||||
UNWIND_LIBS = @UNWIND_LIBS@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = nostdinc
|
||||
CPPFLAGS_ALL_COMMON = \
|
||||
-I$(abs_builddir) \
|
||||
-I$(abs_builddir)/../lib \
|
||||
-I$(abs_srcdir) \
|
||||
-I$(abs_srcdir)/../lib \
|
||||
-I$(includedir)
|
||||
|
||||
LDFLAGS_ALL_COMMON = -L$(abs_builddir) -L$(abs_builddir)/../lib -L$(libdir)
|
||||
|
||||
##################################################
|
||||
# MAIN LIBRARY
|
||||
##################################################
|
||||
CPPFLAGS_LIB_COMMON = $(CPPFLAGS_ALL_COMMON)
|
||||
LDFLAGS_LIB_COMMON = $(LDFLAGS_ALL_COMMON) -version-info 1:0:0 -no-undefined
|
||||
LIBADD_LIB_COMMON = $(LIBM)
|
||||
mio_execd_SOURCES = execd.c
|
||||
mio_execd_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
|
||||
mio_execd_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||
mio_execd_LDADD = $(LIBADD_LIB_COMMON) -lmio $(SSL_LIBS) $(SOCKET_LIBS) $(SENDFILE_LIBS)
|
||||
mio_t01_SOURCES = t01.c
|
||||
mio_t01_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
|
||||
mio_t01_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||
mio_t01_LDADD = $(LIBADD_LIB_COMMON) -lmio $(SSL_LIBS) $(SOCKET_LIBS) $(SENDFILE_LIBS)
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign bin/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign bin/Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
install-binPROGRAMS: $(bin_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
|
||||
if test -n "$$list"; then \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
|
||||
fi; \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed 's/$(EXEEXT)$$//' | \
|
||||
while read p p1; do if test -f $$p \
|
||||
|| test -f $$p1 \
|
||||
; then echo "$$p"; echo "$$p"; else :; fi; \
|
||||
done | \
|
||||
sed -e 'p;s,.*/,,;n;h' \
|
||||
-e 's|.*|.|' \
|
||||
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
|
||||
sed 'N;N;N;s,\n, ,g' | \
|
||||
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
|
||||
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
|
||||
if ($$2 == $$4) files[d] = files[d] " " $$1; \
|
||||
else { print "f", $$3 "/" $$4, $$1; } } \
|
||||
END { for (d in files) print "f", d, files[d] }' | \
|
||||
while read type dir files; do \
|
||||
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
|
||||
test -z "$$files" || { \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
|
||||
} \
|
||||
; done
|
||||
|
||||
uninstall-binPROGRAMS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
|
||||
files=`for p in $$list; do echo "$$p"; done | \
|
||||
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
|
||||
-e 's/$$/$(EXEEXT)/' \
|
||||
`; \
|
||||
test -n "$$list" || exit 0; \
|
||||
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
|
||||
cd "$(DESTDIR)$(bindir)" && rm -f $$files
|
||||
|
||||
clean-binPROGRAMS:
|
||||
@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
|
||||
echo " rm -f" $$list; \
|
||||
rm -f $$list || exit $$?; \
|
||||
test -n "$(EXEEXT)" || exit 0; \
|
||||
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
|
||||
echo " rm -f" $$list; \
|
||||
rm -f $$list
|
||||
|
||||
mio-execd$(EXEEXT): $(mio_execd_OBJECTS) $(mio_execd_DEPENDENCIES) $(EXTRA_mio_execd_DEPENDENCIES)
|
||||
@rm -f mio-execd$(EXEEXT)
|
||||
$(AM_V_CCLD)$(mio_execd_LINK) $(mio_execd_OBJECTS) $(mio_execd_LDADD) $(LIBS)
|
||||
|
||||
mio-t01$(EXEEXT): $(mio_t01_OBJECTS) $(mio_t01_DEPENDENCIES) $(EXTRA_mio_t01_DEPENDENCIES)
|
||||
@rm -f mio-t01$(EXEEXT)
|
||||
$(AM_V_CCLD)$(mio_t01_LINK) $(mio_t01_OBJECTS) $(mio_t01_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mio_execd-execd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mio_t01-t01.Po@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
|
||||
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
|
||||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
|
||||
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
|
||||
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
mio_execd-execd.o: execd.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mio_execd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mio_execd-execd.o -MD -MP -MF $(DEPDIR)/mio_execd-execd.Tpo -c -o mio_execd-execd.o `test -f 'execd.c' || echo '$(srcdir)/'`execd.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mio_execd-execd.Tpo $(DEPDIR)/mio_execd-execd.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='execd.c' object='mio_execd-execd.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mio_execd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mio_execd-execd.o `test -f 'execd.c' || echo '$(srcdir)/'`execd.c
|
||||
|
||||
mio_execd-execd.obj: execd.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mio_execd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mio_execd-execd.obj -MD -MP -MF $(DEPDIR)/mio_execd-execd.Tpo -c -o mio_execd-execd.obj `if test -f 'execd.c'; then $(CYGPATH_W) 'execd.c'; else $(CYGPATH_W) '$(srcdir)/execd.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mio_execd-execd.Tpo $(DEPDIR)/mio_execd-execd.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='execd.c' object='mio_execd-execd.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mio_execd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mio_execd-execd.obj `if test -f 'execd.c'; then $(CYGPATH_W) 'execd.c'; else $(CYGPATH_W) '$(srcdir)/execd.c'; fi`
|
||||
|
||||
mio_t01-t01.o: t01.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mio_t01_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mio_t01-t01.o -MD -MP -MF $(DEPDIR)/mio_t01-t01.Tpo -c -o mio_t01-t01.o `test -f 't01.c' || echo '$(srcdir)/'`t01.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mio_t01-t01.Tpo $(DEPDIR)/mio_t01-t01.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t01.c' object='mio_t01-t01.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mio_t01_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mio_t01-t01.o `test -f 't01.c' || echo '$(srcdir)/'`t01.c
|
||||
|
||||
mio_t01-t01.obj: t01.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mio_t01_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mio_t01-t01.obj -MD -MP -MF $(DEPDIR)/mio_t01-t01.Tpo -c -o mio_t01-t01.obj `if test -f 't01.c'; then $(CYGPATH_W) 't01.c'; else $(CYGPATH_W) '$(srcdir)/t01.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mio_t01-t01.Tpo $(DEPDIR)/mio_t01-t01.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t01.c' object='mio_t01-t01.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mio_t01_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mio_t01-t01.obj `if test -f 't01.c'; then $(CYGPATH_W) 't01.c'; else $(CYGPATH_W) '$(srcdir)/t01.c'; fi`
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
ID: $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); mkid -fID $$unique
|
||||
tags: tags-am
|
||||
TAGS: tags
|
||||
|
||||
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
$(am__define_uniq_tagged_files); \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: ctags-am
|
||||
|
||||
CTAGS: ctags
|
||||
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
cscopelist: cscopelist-am
|
||||
|
||||
cscopelist-am: $(am__tagged_files)
|
||||
list='$(am__tagged_files)'; \
|
||||
case "$(srcdir)" in \
|
||||
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
|
||||
*) sdir=$(subdir)/$(srcdir) ;; \
|
||||
esac; \
|
||||
for i in $$list; do \
|
||||
if test -f "$$i"; then \
|
||||
echo "$(subdir)/$$i"; \
|
||||
else \
|
||||
echo "$$sdir/$$i"; \
|
||||
fi; \
|
||||
done >> $(top_builddir)/cscope.files
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(PROGRAMS)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(bindir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
if test -z '$(STRIP)'; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
install; \
|
||||
else \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
|
||||
fi
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am: install-binPROGRAMS
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-binPROGRAMS
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
|
||||
clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \
|
||||
ctags ctags-am distclean distclean-compile distclean-generic \
|
||||
distclean-libtool distclean-tags distdir dvi dvi-am html \
|
||||
html-am info info-am install install-am install-binPROGRAMS \
|
||||
install-data install-data-am install-dvi install-dvi-am \
|
||||
install-exec install-exec-am install-html install-html-am \
|
||||
install-info install-info-am install-man install-pdf \
|
||||
install-pdf-am install-ps install-ps-am install-strip \
|
||||
installcheck installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags tags-am uninstall uninstall-am uninstall-binPROGRAMS
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
963
mio/bin/execd.c
Normal file
963
mio/bin/execd.c
Normal file
@ -0,0 +1,963 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2015-2016 Chung, Hyung-Hwan. All rights reserved.
|
||||
|
||||
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 WAfRRANTIES
|
||||
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.
|
||||
*/
|
||||
|
||||
|
||||
#include <mio.h>
|
||||
#include <mio-utl.h>
|
||||
#include <mio-sck.h>
|
||||
#include <mio-pro.h>
|
||||
#include <mio-dns.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#if defined(HAVE_OPENSSL_SSL_H) && defined(HAVE_SSL)
|
||||
# include <openssl/ssl.h>
|
||||
# if defined(HAVE_OPENSSL_ERR_H)
|
||||
# include <openssl/err.h>
|
||||
# endif
|
||||
# if defined(HAVE_OPENSSL_ENGINE_H)
|
||||
# include <openssl/engine.h>
|
||||
# endif
|
||||
# define USE_SSL
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
struct mmgr_stat_t
|
||||
{
|
||||
mio_oow_t total_count;
|
||||
};
|
||||
|
||||
typedef struct mmgr_stat_t mmgr_stat_t;
|
||||
|
||||
static mmgr_stat_t mmgr_stat;
|
||||
|
||||
static void* mmgr_alloc (mio_mmgr_t* mmgr, mio_oow_t size)
|
||||
{
|
||||
void* x;
|
||||
|
||||
if (((mmgr_stat_t*)mmgr->ctx)->total_count > 300)
|
||||
{
|
||||
printf ("CRITICAL ERROR ---> too many heap chunks...\n");
|
||||
return MIO_NULL;
|
||||
}
|
||||
|
||||
x = malloc (size);
|
||||
if (x) ((mmgr_stat_t*)mmgr->ctx)->total_count++;
|
||||
return x;
|
||||
}
|
||||
|
||||
static void* mmgr_realloc (mio_mmgr_t* mmgr, void* ptr, mio_oow_t size)
|
||||
{
|
||||
return realloc (ptr, size);
|
||||
}
|
||||
|
||||
static void mmgr_free (mio_mmgr_t* mmgr, void* ptr)
|
||||
{
|
||||
((mmgr_stat_t*)mmgr->ctx)->total_count--;
|
||||
return free (ptr);
|
||||
}
|
||||
|
||||
|
||||
static mio_mmgr_t mmgr =
|
||||
{
|
||||
mmgr_alloc,
|
||||
mmgr_realloc,
|
||||
mmgr_free,
|
||||
&mmgr_stat
|
||||
};
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if defined(USE_SSL)
|
||||
static void cleanup_openssl ()
|
||||
{
|
||||
/* ERR_remove_state() should be called for each thread if the application is thread */
|
||||
ERR_remove_state (0);
|
||||
#if defined(HAVE_ENGINE_CLEANUP)
|
||||
ENGINE_cleanup ();
|
||||
#endif
|
||||
ERR_free_strings ();
|
||||
EVP_cleanup ();
|
||||
#if defined(HAVE_CRYPTO_CLEANUP_ALL_EX_DATA)
|
||||
CRYPTO_cleanup_all_ex_data ();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
struct tcp_server_t
|
||||
{
|
||||
int tally;
|
||||
};
|
||||
typedef struct tcp_server_t tcp_server_t;
|
||||
|
||||
static void tcp_sck_on_disconnect (mio_dev_sck_t* tcp)
|
||||
{
|
||||
switch (MIO_DEV_SCK_GET_PROGRESS(tcp))
|
||||
{
|
||||
case MIO_DEV_SCK_CONNECTING:
|
||||
MIO_INFO1 (tcp->mio, "OUTGOING SESSION DISCONNECTED - FAILED TO CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->sck);
|
||||
break;
|
||||
|
||||
case MIO_DEV_SCK_CONNECTING_SSL:
|
||||
MIO_INFO1 (tcp->mio, "OUTGOING SESSION DISCONNECTED - FAILED TO SSL-CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->sck);
|
||||
break;
|
||||
|
||||
case MIO_DEV_SCK_LISTENING:
|
||||
MIO_INFO1 (tcp->mio, "SHUTTING DOWN THE SERVER SOCKET(%d)...\n", (int)tcp->sck);
|
||||
break;
|
||||
|
||||
case MIO_DEV_SCK_CONNECTED:
|
||||
MIO_INFO1 (tcp->mio, "OUTGOING CLIENT CONNECTION GOT TORN DOWN(%d).......\n", (int)tcp->sck);
|
||||
break;
|
||||
|
||||
case MIO_DEV_SCK_ACCEPTING_SSL:
|
||||
MIO_INFO1 (tcp->mio, "INCOMING SSL-ACCEPT GOT DISCONNECTED(%d) ....\n", (int)tcp->sck);
|
||||
break;
|
||||
|
||||
case MIO_DEV_SCK_ACCEPTED:
|
||||
MIO_INFO1 (tcp->mio, "INCOMING CLIENT BEING SERVED GOT DISCONNECTED(%d).......\n", (int)tcp->sck);
|
||||
break;
|
||||
|
||||
default:
|
||||
MIO_INFO2 (tcp->mio, "SOCKET DEVICE DISCONNECTED (%d - %x)\n", (int)tcp->sck, (unsigned int)tcp->state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void tcp_sck_on_connect (mio_dev_sck_t* tcp)
|
||||
{
|
||||
mio_sckfam_t fam;
|
||||
mio_scklen_t len;
|
||||
mio_bch_t buf1[128], buf2[128];
|
||||
|
||||
memset (buf1, 0, MIO_SIZEOF(buf1));
|
||||
memset (buf2, 0, MIO_SIZEOF(buf2));
|
||||
|
||||
mio_getsckaddrinfo (tcp->mio, &tcp->localaddr, &len, &fam);
|
||||
inet_ntop (fam, tcp->localaddr.data, buf1, MIO_COUNTOF(buf1));
|
||||
|
||||
mio_getsckaddrinfo (tcp->mio, &tcp->remoteaddr, &len, &fam);
|
||||
inet_ntop (fam, tcp->remoteaddr.data, buf2, MIO_COUNTOF(buf2));
|
||||
|
||||
if (tcp->state & MIO_DEV_SCK_CONNECTED)
|
||||
{
|
||||
MIO_INFO5 (tcp->mio, "DEVICE connected to a remote server... LOCAL %hs:%d REMOTE %hs:%d SCK: %d\n",
|
||||
buf1, mio_getsckaddrport(&tcp->localaddr), buf2, mio_getsckaddrport(&tcp->remoteaddr), tcp->sck);
|
||||
}
|
||||
else if (tcp->state & MIO_DEV_SCK_ACCEPTED)
|
||||
{
|
||||
MIO_INFO5 (tcp->mio, "DEVICE accepted client device... .LOCAL %hs:%d REMOTE %hs:%d\n",
|
||||
buf1, mio_getsckaddrport(&tcp->localaddr), buf2, mio_getsckaddrport(&tcp->remoteaddr), tcp->sck);
|
||||
}
|
||||
|
||||
if (mio_dev_sck_write(tcp, "hello", 5, MIO_NULL, MIO_NULL) <= -1)
|
||||
{
|
||||
mio_dev_sck_halt (tcp);
|
||||
}
|
||||
}
|
||||
|
||||
static int tcp_sck_on_write (mio_dev_sck_t* tcp, mio_iolen_t wrlen, void* wrctx, const mio_sckaddr_t* dstaddr)
|
||||
{
|
||||
tcp_server_t* ts;
|
||||
mio_ntime_t tmout;
|
||||
|
||||
if (wrlen <= -1)
|
||||
{
|
||||
MIO_INFO1 (tcp->mio, "TCP_SCK_ON_WRITE(%d) >>> SEDING TIMED OUT...........\n", (int)tcp->sck);
|
||||
mio_dev_sck_halt (tcp);
|
||||
}
|
||||
else
|
||||
{
|
||||
ts = (tcp_server_t*)(tcp + 1);
|
||||
if (wrlen == 0)
|
||||
{
|
||||
MIO_INFO1 (tcp->mio, "TCP_SCK_ON_WRITE(%d) >>> CLOSED WRITING END\n", (int)tcp->sck);
|
||||
}
|
||||
else
|
||||
{
|
||||
MIO_INFO3 (tcp->mio, "TCP_SCK_ON_WRITE(%d) >>> SENT MESSAGE %d of length %ld\n", (int)tcp->sck, ts->tally, (long int)wrlen);
|
||||
}
|
||||
|
||||
ts->tally++;
|
||||
// if (ts->tally >= 2) mio_dev_sck_halt (tcp);
|
||||
|
||||
|
||||
MIO_INIT_NTIME (&tmout, 5, 0);
|
||||
//mio_dev_sck_read (tcp, 1);
|
||||
|
||||
MIO_INFO3 (tcp->mio, "TCP_SCK_ON_WRITE(%d) >>> REQUESTING to READ with timeout of %ld.%08ld\n", (int)tcp->sck, (long int)tmout.sec, (long int)tmout.nsec);
|
||||
mio_dev_sck_timedread (tcp, 1, &tmout);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tcp_sck_on_read (mio_dev_sck_t* tcp, const void* buf, mio_iolen_t len, const mio_sckaddr_t* srcaddr)
|
||||
{
|
||||
int n;
|
||||
|
||||
if (len <= -1)
|
||||
{
|
||||
MIO_INFO1 (tcp->mio, "TCP_SCK_ON_READ(%d) STREAM DEVICE: TIMED OUT...\n", (int)tcp->sck);
|
||||
mio_dev_sck_halt (tcp);
|
||||
return 0;
|
||||
}
|
||||
else if (len <= 0)
|
||||
{
|
||||
MIO_INFO1 (tcp->mio, "TCP_SCK_ON_READ(%d) STREAM DEVICE: EOF RECEIVED...\n", (int)tcp->sck);
|
||||
/* no outstanding request. but EOF */
|
||||
mio_dev_sck_halt (tcp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MIO_INFO2 (tcp->mio, "TCP_SCK_ON_READ(%d) - received %d bytes\n", (int)tcp->sck, (int)len);
|
||||
|
||||
{
|
||||
mio_ntime_t tmout;
|
||||
|
||||
static char a ='A';
|
||||
static char xxx[1000000];
|
||||
memset (xxx, a++ , MIO_SIZEOF(xxx));
|
||||
|
||||
MIO_INFO2 (tcp->mio, "TCP_SCK_ON_READ(%d) >>> REQUESTING to write data of %d bytes\n", (int)tcp->sck, MIO_SIZEOF(xxx));
|
||||
//return mio_dev_sck_write (tcp, "HELLO", 5, MIO_NULL);
|
||||
MIO_INIT_NTIME (&tmout, 5, 0);
|
||||
n = mio_dev_sck_timedwrite(tcp, xxx, MIO_SIZEOF(xxx), &tmout, MIO_NULL, MIO_NULL);
|
||||
|
||||
if (n <= -1) return -1;
|
||||
}
|
||||
|
||||
MIO_INFO1 (tcp->mio, "TCP_SCK_ON_READ(%d) - REQUESTING TO STOP READ\n", (int)tcp->sck);
|
||||
mio_dev_sck_read (tcp, 0);
|
||||
|
||||
#if 0
|
||||
MIO_INFO1 (tcp->mio, "TCP_SCK_ON_READ(%d) - REQUESTING TO CLOSE WRITING END\n", (int)tcp->sck);
|
||||
/* post the write finisher - close the writing end */
|
||||
n = mio_dev_sck_write(tcp, MIO_NULL, 0, MIO_NULL, MIO_NULL);
|
||||
if (n <= -1) return -1;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
/* return 1; let the main loop to read more greedily without consulting the multiplexer */
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static void pro_on_close (mio_dev_pro_t* pro, mio_dev_pro_sid_t sid)
|
||||
{
|
||||
mio_t* mio = pro->mio;
|
||||
if (sid == MIO_DEV_PRO_MASTER)
|
||||
MIO_INFO1 (mio, "PROCESS(%d) CLOSE MASTER\n", (int)pro->child_pid);
|
||||
else
|
||||
MIO_INFO2 (mio, "PROCESS(%d) CLOSE SLAVE[%d]\n", (int)pro->child_pid, sid);
|
||||
}
|
||||
|
||||
static int pro_on_read (mio_dev_pro_t* pro, mio_dev_pro_sid_t sid, const void* data, mio_iolen_t dlen)
|
||||
{
|
||||
mio_t* mio = pro->mio;
|
||||
|
||||
if (dlen <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "PROCESS(%d): READ TIMED OUT...\n", (int)pro->child_pid);
|
||||
mio_dev_pro_halt (pro);
|
||||
return 0;
|
||||
}
|
||||
else if (dlen <= 0)
|
||||
{
|
||||
MIO_INFO1 (mio, "PROCESS(%d): EOF RECEIVED...\n", (int)pro->child_pid);
|
||||
/* no outstanding request. but EOF */
|
||||
mio_dev_pro_halt (pro);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MIO_INFO5 (mio, "PROCESS(%d) READ DATA ON SLAVE[%d] len=%d [%.*hs]\n", (int)pro->child_pid, (int)sid, (int)dlen, dlen, (char*)data);
|
||||
if (sid == MIO_DEV_PRO_OUT)
|
||||
{
|
||||
mio_dev_pro_read (pro, sid, 0);
|
||||
mio_dev_pro_write (pro, "HELLO\n", 6, MIO_NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pro_on_write (mio_dev_pro_t* pro, mio_iolen_t wrlen, void* wrctx)
|
||||
{
|
||||
mio_t* mio = pro->mio;
|
||||
mio_ntime_t tmout;
|
||||
if (wrlen <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "PROCESS(%d): WRITE TIMED OUT...\n", (int)pro->child_pid);
|
||||
mio_dev_pro_halt (pro);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MIO_DEBUG2 (mio, "PROCESS(%d) wrote data of %d bytes\n", (int)pro->child_pid, (int)wrlen);
|
||||
/*mio_dev_pro_read (pro, MIO_DEV_PRO_OUT, 1);*/
|
||||
MIO_INIT_NTIME (&tmout, 5, 0);
|
||||
mio_dev_pro_timedread (pro, MIO_DEV_PRO_OUT, 1, &tmout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static int arp_sck_on_read (mio_dev_sck_t* dev, const void* data, mio_iolen_t dlen, const mio_sckaddr_t* srcaddr)
|
||||
{
|
||||
mio_etharp_pkt_t* eap;
|
||||
|
||||
|
||||
if (dlen < MIO_SIZEOF(*eap)) return 0; /* drop */
|
||||
|
||||
eap = (mio_etharp_pkt_t*)data;
|
||||
|
||||
printf ("ARP ON IFINDEX %d OPCODE: %d", mio_getsckaddrifindex(srcaddr), ntohs(eap->arphdr.opcode));
|
||||
|
||||
printf (" SHA: %02X:%02X:%02X:%02X:%02X:%02X", eap->arppld.sha[0], eap->arppld.sha[1], eap->arppld.sha[2], eap->arppld.sha[3], eap->arppld.sha[4], eap->arppld.sha[5]);
|
||||
printf (" SPA: %d.%d.%d.%d", eap->arppld.spa[0], eap->arppld.spa[1], eap->arppld.spa[2], eap->arppld.spa[3]);
|
||||
printf (" THA: %02X:%02X:%02X:%02X:%02X:%02X", eap->arppld.tha[0], eap->arppld.tha[1], eap->arppld.tha[2], eap->arppld.tha[3], eap->arppld.tha[4], eap->arppld.tha[5]);
|
||||
printf (" TPA: %d.%d.%d.%d", eap->arppld.tpa[0], eap->arppld.tpa[1], eap->arppld.tpa[2], eap->arppld.tpa[3]);
|
||||
printf ("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int arp_sck_on_write (mio_dev_sck_t* dev, mio_iolen_t wrlen, void* wrctx, const mio_sckaddr_t* dstaddr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void arp_sck_on_connect (mio_dev_sck_t* dev)
|
||||
{
|
||||
printf ("STARTING UP ARP SOCKET %d...\n", dev->sck);
|
||||
}
|
||||
|
||||
static void arp_sck_on_disconnect (mio_dev_sck_t* dev)
|
||||
{
|
||||
printf ("SHUTTING DOWN ARP SOCKET %d...\n", dev->sck);
|
||||
}
|
||||
|
||||
static int setup_arp_tester (mio_t* mio)
|
||||
{
|
||||
mio_sckaddr_t ethdst;
|
||||
mio_etharp_pkt_t etharp;
|
||||
mio_dev_sck_make_t sck_make;
|
||||
mio_dev_sck_t* sck;
|
||||
|
||||
memset (&sck_make, 0, MIO_SIZEOF(sck_make));
|
||||
sck_make.type = MIO_DEV_SCK_ARP;
|
||||
//sck_make.type = MIO_DEV_SCK_ARP_DGRAM;
|
||||
sck_make.on_write = arp_sck_on_write;
|
||||
sck_make.on_read = arp_sck_on_read;
|
||||
sck_make.on_connect = arp_sck_on_connect;
|
||||
sck_make.on_disconnect = arp_sck_on_disconnect;
|
||||
sck = mio_dev_sck_make(mio, 0, &sck_make);
|
||||
if (!sck)
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot make arp socket device - %js\n", mio_geterrmsg(mio));
|
||||
return -1;
|
||||
}
|
||||
|
||||
//mio_sckaddr_initforeth (ðdst, if_nametoindex("enp0s25.3"), (mio_ethaddr_t*)"\xFF\xFF\xFF\xFF\xFF\xFF");
|
||||
//mio_sckaddr_initforeth (ðdst, if_nametoindex("enp0s25.3"), (mio_ethaddr_t*)"\xAA\xBB\xFF\xCC\xDD\xFF");
|
||||
|
||||
mio_sckaddr_initforeth (ðdst, if_nametoindex("wlan0"), (mio_ethaddr_t*)"\xAA\xBB\xFF\xCC\xDD\xFF");
|
||||
|
||||
memset (ðarp, 0, MIO_SIZEOF(etharp));
|
||||
|
||||
memcpy (etharp.ethhdr.source, "\xB8\x6B\x23\x9C\x10\x76", MIO_ETHADDR_LEN);
|
||||
//memcpy (etharp.ethhdr.dest, "\xFF\xFF\xFF\xFF\xFF\xFF", MIO_ETHADDR_LEN);
|
||||
memcpy (etharp.ethhdr.dest, "\xAA\xBB\xFF\xCC\xDD\xFF", MIO_ETHADDR_LEN);
|
||||
etharp.ethhdr.proto = MIO_CONST_HTON16(MIO_ETHHDR_PROTO_ARP);
|
||||
|
||||
etharp.arphdr.htype = MIO_CONST_HTON16(MIO_ARPHDR_HTYPE_ETH);
|
||||
etharp.arphdr.ptype = MIO_CONST_HTON16(MIO_ARPHDR_PTYPE_IP4);
|
||||
etharp.arphdr.hlen = MIO_ETHADDR_LEN;
|
||||
etharp.arphdr.plen = MIO_IP4ADDR_LEN;
|
||||
etharp.arphdr.opcode = MIO_CONST_HTON16(MIO_ARPHDR_OPCODE_REQUEST);
|
||||
|
||||
memcpy (etharp.arppld.sha, "\xB8\x6B\x23\x9C\x10\x76", MIO_ETHADDR_LEN);
|
||||
|
||||
if (mio_dev_sck_write(sck, ðarp, MIO_SIZEOF(etharp), MIO_NULL, ðdst) <= -1)
|
||||
//if (mio_dev_sck_write (sck, ðarp.arphdr, MIO_SIZEOF(etharp) - MIO_SIZEOF(etharp.ethhdr), MIO_NULL, ðaddr) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot write arp - %js\n", mio_geterrmsg(mio));
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
struct icmpxtn_t
|
||||
{
|
||||
mio_uint16_t icmp_seq;
|
||||
mio_tmridx_t tmout_jobidx;
|
||||
int reply_received;
|
||||
};
|
||||
|
||||
typedef struct icmpxtn_t icmpxtn_t;
|
||||
|
||||
static int schedule_icmp_wait (mio_dev_sck_t* dev);
|
||||
|
||||
static void send_icmp (mio_dev_sck_t* dev, mio_uint16_t seq)
|
||||
{
|
||||
mio_t* mio = dev->mio;
|
||||
mio_sckaddr_t dstaddr;
|
||||
mio_ip4addr_t ia;
|
||||
mio_icmphdr_t* icmphdr;
|
||||
mio_uint8_t buf[512];
|
||||
|
||||
inet_pton (AF_INET, "192.168.1.131", &ia);
|
||||
mio_sckaddr_initforip4 (&dstaddr, 0, &ia);
|
||||
|
||||
memset(buf, 0, MIO_SIZEOF(buf));
|
||||
icmphdr = (mio_icmphdr_t*)buf;
|
||||
icmphdr->type = MIO_ICMP_ECHO_REQUEST;
|
||||
icmphdr->u.echo.id = MIO_CONST_HTON16(100);
|
||||
icmphdr->u.echo.seq = mio_hton16(seq);
|
||||
|
||||
memset (&buf[MIO_SIZEOF(*icmphdr)], 'A', MIO_SIZEOF(buf) - MIO_SIZEOF(*icmphdr));
|
||||
icmphdr->checksum = mio_checksumip (icmphdr, MIO_SIZEOF(buf));
|
||||
|
||||
if (mio_dev_sck_write(dev, buf, MIO_SIZEOF(buf), MIO_NULL, &dstaddr) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot write icmp - %js\n", mio_geterrmsg(mio));
|
||||
mio_dev_sck_halt (dev);
|
||||
}
|
||||
|
||||
if (schedule_icmp_wait (dev) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot schedule icmp wait - %js\n", mio_geterrmsg(mio));
|
||||
mio_dev_sck_halt (dev);
|
||||
}
|
||||
}
|
||||
|
||||
static void on_icmp_due (mio_t* mio, const mio_ntime_t* now, mio_tmrjob_t* tmrjob)
|
||||
{
|
||||
mio_dev_sck_t* dev;
|
||||
icmpxtn_t* icmpxtn;
|
||||
|
||||
dev = tmrjob->ctx;
|
||||
icmpxtn = (icmpxtn_t*)(dev + 1);
|
||||
|
||||
if (icmpxtn->reply_received)
|
||||
icmpxtn->reply_received = 0;
|
||||
else
|
||||
MIO_INFO0 (mio, "NO IMCP reply received in time\n");
|
||||
|
||||
send_icmp (dev, ++icmpxtn->icmp_seq);
|
||||
}
|
||||
|
||||
static int schedule_icmp_wait (mio_dev_sck_t* dev)
|
||||
{
|
||||
mio_t* mio = dev->mio;
|
||||
icmpxtn_t* icmpxtn;
|
||||
mio_tmrjob_t tmrjob;
|
||||
mio_ntime_t fire_after;
|
||||
|
||||
icmpxtn = (icmpxtn_t*)(dev + 1);
|
||||
MIO_INIT_NTIME (&fire_after, 2, 0);
|
||||
|
||||
memset (&tmrjob, 0, MIO_SIZEOF(tmrjob));
|
||||
tmrjob.ctx = dev;
|
||||
mio_gettime (mio, &tmrjob.when);
|
||||
MIO_ADD_NTIME (&tmrjob.when, &tmrjob.when, &fire_after);
|
||||
tmrjob.handler = on_icmp_due;
|
||||
tmrjob.idxptr = &icmpxtn->tmout_jobidx;
|
||||
|
||||
assert (icmpxtn->tmout_jobidx == MIO_TMRIDX_INVALID);
|
||||
|
||||
return (mio_instmrjob(dev->mio, &tmrjob) == MIO_TMRIDX_INVALID)? -1: 0;
|
||||
}
|
||||
|
||||
static int icmp_sck_on_read (mio_dev_sck_t* dev, const void* data, mio_iolen_t dlen, const mio_sckaddr_t* srcaddr)
|
||||
{
|
||||
icmpxtn_t* icmpxtn;
|
||||
mio_iphdr_t* iphdr;
|
||||
mio_icmphdr_t* icmphdr;
|
||||
|
||||
/* when received, the data contains the IP header.. */
|
||||
icmpxtn = (icmpxtn_t*)(dev + 1);
|
||||
|
||||
if (dlen < MIO_SIZEOF(*iphdr) + MIO_SIZEOF(*icmphdr))
|
||||
{
|
||||
printf ("INVALID ICMP PACKET.. TOO SHORT...%d\n", (int)dlen);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO: consider IP options... */
|
||||
iphdr = (mio_iphdr_t*)data;
|
||||
|
||||
if (iphdr->ihl * 4 + MIO_SIZEOF(*icmphdr) > dlen)
|
||||
{
|
||||
printf ("INVALID ICMP PACKET.. WRONG IHL...%d\n", (int)iphdr->ihl * 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
icmphdr = (mio_icmphdr_t*)((mio_uint8_t*)data + (iphdr->ihl * 4));
|
||||
|
||||
/* TODO: check srcaddr against target */
|
||||
|
||||
if (icmphdr->type == MIO_ICMP_ECHO_REPLY &&
|
||||
mio_ntoh16(icmphdr->u.echo.seq) == icmpxtn->icmp_seq) /* TODO: more check.. echo.id.. */
|
||||
{
|
||||
icmpxtn->reply_received = 1;
|
||||
printf ("ICMP REPLY RECEIVED...ID %d SEQ %d\n", (int)mio_ntoh16(icmphdr->u.echo.id), (int)mio_ntoh16(icmphdr->u.echo.seq));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("GARBAGE ICMP PACKET...LEN %d SEQ %d,%d\n", (int)dlen, (int)icmpxtn->icmp_seq, (int)mio_ntoh16(icmphdr->u.echo.seq));
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int icmp_sck_on_write (mio_dev_sck_t* dev, mio_iolen_t wrlen, void* wrctx, const mio_sckaddr_t* dstaddr)
|
||||
{
|
||||
/*icmpxtn_t* icmpxtn;
|
||||
|
||||
icmpxtn = (icmpxtn_t*)(dev + 1); */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void icmp_sck_on_disconnect (mio_dev_sck_t* dev)
|
||||
{
|
||||
icmpxtn_t* icmpxtn;
|
||||
|
||||
icmpxtn = (icmpxtn_t*)(dev + 1);
|
||||
|
||||
printf ("SHUTTING DOWN ICMP SOCKET %d...\n", dev->sck);
|
||||
if (icmpxtn->tmout_jobidx != MIO_TMRIDX_INVALID)
|
||||
{
|
||||
|
||||
mio_deltmrjob (dev->mio, icmpxtn->tmout_jobidx);
|
||||
icmpxtn->tmout_jobidx = MIO_TMRIDX_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
static int setup_ping4_tester (mio_t* mio)
|
||||
{
|
||||
mio_dev_sck_make_t sck_make;
|
||||
mio_dev_sck_t* sck;
|
||||
icmpxtn_t* icmpxtn;
|
||||
|
||||
memset (&sck_make, 0, MIO_SIZEOF(sck_make));
|
||||
sck_make.type = MIO_DEV_SCK_ICMP4;
|
||||
sck_make.on_write = icmp_sck_on_write;
|
||||
sck_make.on_read = icmp_sck_on_read;
|
||||
sck_make.on_disconnect = icmp_sck_on_disconnect;
|
||||
|
||||
sck = mio_dev_sck_make (mio, MIO_SIZEOF(icmpxtn_t), &sck_make);
|
||||
if (!sck)
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot make ICMP4 socket device - %js\n", mio_geterrmsg(mio));
|
||||
return -1;
|
||||
}
|
||||
|
||||
icmpxtn = (icmpxtn_t*)(sck + 1);
|
||||
icmpxtn->tmout_jobidx = MIO_TMRIDX_INVALID;
|
||||
icmpxtn->icmp_seq = 0;
|
||||
|
||||
/*TODO: mio_dev_sck_setbroadcast (sck, 1);*/
|
||||
|
||||
send_icmp (sck, ++icmpxtn->icmp_seq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if 1
|
||||
static mio_t* g_mio;
|
||||
|
||||
static void handle_signal (int sig)
|
||||
{
|
||||
if (g_mio) mio_stop (g_mio, MIO_STOPREQ_TERMINATION);
|
||||
}
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
mio_t* mio;
|
||||
mio_dev_sck_t* tcp[3];
|
||||
|
||||
struct sigaction sigact;
|
||||
mio_dev_sck_connect_t tcp_conn;
|
||||
mio_dev_sck_listen_t tcp_lstn;
|
||||
mio_dev_sck_bind_t tcp_bind;
|
||||
mio_dev_sck_make_t tcp_make;
|
||||
|
||||
tcp_server_t* ts;
|
||||
|
||||
#if defined(USE_SSL)
|
||||
SSL_load_error_strings ();
|
||||
SSL_library_init ();
|
||||
#endif
|
||||
|
||||
mio = mio_open(&mmgr, 0, MIO_NULL, 512, MIO_NULL);
|
||||
if (!mio)
|
||||
{
|
||||
printf ("Cannot open mio\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_mio = mio;
|
||||
|
||||
memset (&sigact, 0, MIO_SIZEOF(sigact));
|
||||
sigact.sa_flags = SA_RESTART;
|
||||
sigact.sa_handler = handle_signal;
|
||||
sigaction (SIGINT, &sigact, MIO_NULL);
|
||||
|
||||
memset (&sigact, 0, MIO_SIZEOF(sigact));
|
||||
sigact.sa_handler = SIG_IGN;
|
||||
sigaction (SIGPIPE, &sigact, MIO_NULL);
|
||||
|
||||
/*
|
||||
memset (&sigact, 0, MIO_SIZEOF(sigact));
|
||||
sigact.sa_handler = SIG_IGN;
|
||||
sigaction (SIGCHLD, &sigact, MIO_NULL);
|
||||
*/
|
||||
|
||||
/*memset (&sin, 0, MIO_SIZEOF(sin));
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(1234); */
|
||||
/*
|
||||
udp = (mio_dev_udp_t*)mio_dev_make(mio, MIO_SIZEOF(*udp), &udp_mth, &udp_evcb, &sin);
|
||||
if (!udp)
|
||||
{
|
||||
printf ("Cannot make udp\n");
|
||||
goto oops;
|
||||
}
|
||||
*/
|
||||
|
||||
memset (&tcp_make, 0, MIO_SIZEOF(tcp_make));
|
||||
tcp_make.type = MIO_DEV_SCK_TCP4;
|
||||
tcp_make.on_write = tcp_sck_on_write;
|
||||
tcp_make.on_read = tcp_sck_on_read;
|
||||
tcp_make.on_connect = tcp_sck_on_connect;
|
||||
tcp_make.on_disconnect = tcp_sck_on_disconnect;
|
||||
tcp[0] = mio_dev_sck_make(mio, MIO_SIZEOF(tcp_server_t), &tcp_make);
|
||||
if (!tcp[0])
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot make tcp - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
ts = (tcp_server_t*)(tcp[0] + 1);
|
||||
ts->tally = 0;
|
||||
|
||||
memset (&tcp_conn, 0, MIO_SIZEOF(tcp_conn));
|
||||
{
|
||||
/* openssl s_server -accept 9999 -key localhost.key -cert localhost.crt */
|
||||
in_addr_t ia = inet_addr("127.0.0.1");
|
||||
mio_sckaddr_initforip4 (&tcp_conn.remoteaddr, 9999, (mio_ip4addr_t*)&ia);
|
||||
}
|
||||
|
||||
MIO_INIT_NTIME (&tcp_conn.connect_tmout, 5, 0);
|
||||
tcp_conn.options = MIO_DEV_SCK_CONNECT_SSL;
|
||||
if (mio_dev_sck_connect(tcp[0], &tcp_conn) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "tcp[0] mio_dev_sck_connect() failed - %js\n", mio_geterrmsg(mio));
|
||||
/* carry on regardless of failure */
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
memset (&tcp_make, 0, MIO_SIZEOF(tcp_make));
|
||||
tcp_make.type = MIO_DEV_SCK_TCP4;
|
||||
tcp_make.on_write = tcp_sck_on_write;
|
||||
tcp_make.on_read = tcp_sck_on_read;
|
||||
tcp_make.on_connect = tcp_sck_on_connect;
|
||||
tcp_make.on_disconnect = tcp_sck_on_disconnect;
|
||||
|
||||
tcp[1] = mio_dev_sck_make(mio, MIO_SIZEOF(tcp_server_t), &tcp_make);
|
||||
if (!tcp[1])
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot make tcp[1] - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
ts = (tcp_server_t*)(tcp[1] + 1);
|
||||
ts->tally = 0;
|
||||
|
||||
memset (&tcp_bind, 0, MIO_SIZEOF(tcp_bind));
|
||||
mio_sckaddr_initforip4 (&tcp_bind.localaddr, 1234, MIO_NULL);
|
||||
tcp_bind.options = MIO_DEV_SCK_BIND_REUSEADDR;
|
||||
|
||||
if (mio_dev_sck_bind(tcp[1],&tcp_bind) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "tcp[1] mio_dev_sck_bind() failed - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
|
||||
tcp_lstn.backlogs = 100;
|
||||
if (mio_dev_sck_listen(tcp[1], &tcp_lstn) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "tcp[1] mio_dev_sck_listen() failed - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
memset (&tcp_make, 0, MIO_SIZEOF(tcp_make));
|
||||
tcp_make.type = MIO_DEV_SCK_TCP4;
|
||||
tcp_make.on_write = tcp_sck_on_write;
|
||||
tcp_make.on_read = tcp_sck_on_read;
|
||||
tcp_make.on_connect = tcp_sck_on_connect;
|
||||
tcp_make.on_disconnect = tcp_sck_on_disconnect;
|
||||
|
||||
tcp[2] = mio_dev_sck_make(mio, MIO_SIZEOF(tcp_server_t), &tcp_make);
|
||||
if (!tcp[2])
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot make tcp[2] - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
ts = (tcp_server_t*)(tcp[2] + 1);
|
||||
ts->tally = 0;
|
||||
|
||||
memset (&tcp_bind, 0, MIO_SIZEOF(tcp_bind));
|
||||
mio_sckaddr_initforip4 (&tcp_bind.localaddr, 1235, MIO_NULL);
|
||||
tcp_bind.options = MIO_DEV_SCK_BIND_REUSEADDR /*| MIO_DEV_SCK_BIND_REUSEPORT |*/;
|
||||
#if defined(USE_SSL)
|
||||
tcp_bind.options |= MIO_DEV_SCK_BIND_SSL;
|
||||
tcp_bind.ssl_certfile = "localhost.crt";
|
||||
tcp_bind.ssl_keyfile = "localhost.key";
|
||||
#endif
|
||||
MIO_INIT_NTIME (&tcp_bind.accept_tmout, 5, 1);
|
||||
|
||||
if (mio_dev_sck_bind(tcp[2], &tcp_bind) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "tcp[2] mio_dev_sck_bind() failed - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
tcp_lstn.backlogs = 100;
|
||||
if (mio_dev_sck_listen(tcp[2], &tcp_lstn) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "tcp[2] mio_dev_sck_listen() failed - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
//mio_dev_sck_sendfile (tcp[2], fd, offset, count);
|
||||
|
||||
setup_arp_tester(mio);
|
||||
setup_ping4_tester(mio);
|
||||
|
||||
#if 1
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
mio_dev_pro_t* pro;
|
||||
mio_dev_pro_make_t pro_make;
|
||||
|
||||
memset (&pro_make, 0, MIO_SIZEOF(pro_make));
|
||||
pro_make.flags = MIO_DEV_PRO_READOUT | MIO_DEV_PRO_READERR | MIO_DEV_PRO_WRITEIN /*| MIO_DEV_PRO_FORGET_CHILD*/;
|
||||
//pro_make.cmd = "/bin/ls -laF /usr/bin";
|
||||
//pro_make.cmd = "/bin/ls -laF";
|
||||
pro_make.cmd = "./a";
|
||||
pro_make.on_read = pro_on_read;
|
||||
pro_make.on_write = pro_on_write;
|
||||
pro_make.on_close = pro_on_close;
|
||||
|
||||
pro = mio_dev_pro_make(mio, 0, &pro_make);
|
||||
if (!pro)
|
||||
{
|
||||
MIO_INFO1 (mio, "CANNOT CREATE PROCESS PIPE - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
mio_dev_pro_read (pro, MIO_DEV_PRO_OUT, 0);
|
||||
//mio_dev_pro_read (pro, MIO_DEV_PRO_ERR, 0);
|
||||
|
||||
mio_dev_pro_write (pro, "MY MIO LIBRARY\n", 16, MIO_NULL);
|
||||
//mio_dev_pro_killchild (pro);
|
||||
//mio_dev_pro_close (pro, MIO_DEV_PRO_IN);
|
||||
//mio_dev_pro_close (pro, MIO_DEV_PRO_OUT);
|
||||
//mio_dev_pro_close (pro, MIO_DEV_PRO_ERR);
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
mio_dnsc_t* dnsc;
|
||||
dnsc = mio_dnsc_start (mio/*, "8.8.8.8:53,1.1.1.1:53"*/); /* option - send to all, send one by one */
|
||||
{
|
||||
mio_dns_bqr_t qrs[] =
|
||||
{
|
||||
{ "code.miflux.com", MIO_DNS_QTYPE_A, MIO_DNS_QCLASS_IN },
|
||||
{ "code.miflux.com", MIO_DNS_QTYPE_AAAA, MIO_DNS_QCLASS_IN },
|
||||
{ "code.abiyo.net", MIO_DNS_QTYPE_A, MIO_DNS_QCLASS_IN },
|
||||
{ "code6.abiyo.net", MIO_DNS_QTYPE_AAAA, MIO_DNS_QCLASS_IN },
|
||||
{ "abiyo.net", MIO_DNS_QTYPE_MX, MIO_DNS_QCLASS_IN }
|
||||
};
|
||||
mio_dns_brr_t rrs[] =
|
||||
{
|
||||
{ MIO_DNS_RR_PART_ANSWER, "code.miflux.com", MIO_DNS_QTYPE_A, MIO_DNS_QCLASS_IN, 86400, 0, MIO_NULL },
|
||||
{ MIO_DNS_RR_PART_ANSWER, "code.miflux.com", MIO_DNS_QTYPE_AAAA, MIO_DNS_QCLASS_IN, 86400, 0, MIO_NULL },
|
||||
{ MIO_DNS_RR_PART_AUTHORITY, "dns.miflux.com", MIO_DNS_QTYPE_NS, MIO_DNS_QCLASS_IN, 86400, 0, MIO_NULL }//,
|
||||
//{ MIO_DNS_RR_PART_ANSERT, "www.miflux.com", MIO_DNS_QTYPE_CNAME, MIO_DNS_QCLASS_IN, 60, 15, "code.miflux.com" }
|
||||
};
|
||||
|
||||
mio_dns_beopt_t beopt[] =
|
||||
{
|
||||
{ MIO_DNS_EOPT_COOKIE, 8, "\x01\x02\x03\x04\0x05\x06\0x07\0x08" },
|
||||
{ MIO_DNS_EOPT_NSID, 0, MIO_NULL }
|
||||
};
|
||||
|
||||
mio_dns_bedns_t qedns =
|
||||
{
|
||||
4096, /* uplen */
|
||||
|
||||
0, /* edns version */
|
||||
0, /* dnssec ok */
|
||||
|
||||
MIO_COUNTOF(beopt), /* number of edns options */
|
||||
beopt
|
||||
};
|
||||
|
||||
mio_dns_bdns_t qhdr =
|
||||
{
|
||||
-1, /* id */
|
||||
0, /* qr */
|
||||
MIO_DNS_OPCODE_QUERY, /* opcode */
|
||||
0, /* aa */
|
||||
0, /* tc */
|
||||
1, /* rd */
|
||||
0, /* ra */
|
||||
0, /* ad */
|
||||
0, /* cd */
|
||||
MIO_DNS_RCODE_NOERROR /* rcode */
|
||||
};
|
||||
|
||||
mio_dns_bdns_t rhdr =
|
||||
{
|
||||
0x1234, /* id */
|
||||
1, /* qr */
|
||||
MIO_DNS_OPCODE_QUERY, /* opcode */
|
||||
|
||||
0, /* aa */
|
||||
0, /* tc */
|
||||
0, /* rd */
|
||||
1, /* ra */
|
||||
0, /* ad */
|
||||
0, /* cd */
|
||||
MIO_DNS_RCODE_BADCOOKIE /* rcode */
|
||||
};
|
||||
|
||||
mio_dnsc_sendreq (dnsc, &qhdr, qrs, MIO_COUNTOF(qrs), &qedns);
|
||||
mio_dnsc_sendmsg (dnsc, &rhdr, qrs, MIO_COUNTOF(qrs), rrs, MIO_COUNTOF(rrs), &qedns);
|
||||
}
|
||||
|
||||
mio_loop (mio);
|
||||
|
||||
/* TODO: let mio close it ... dnsc is svc. sck is dev. */
|
||||
mio_dnsc_stop (dnsc);
|
||||
}
|
||||
|
||||
g_mio = MIO_NULL;
|
||||
mio_close (mio);
|
||||
#if defined(USE_SSL)
|
||||
cleanup_openssl ();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
g_mio = MIO_NULL;
|
||||
mio_close (mio);
|
||||
#if defined(USE_SSL)
|
||||
cleanup_openssl ();
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
mio_t* mio = MIO_NULL;
|
||||
mio_dev_sck_t* tcpsvr;
|
||||
mio_dev_sck_make_t tcp_make;
|
||||
mio_dev_sck_connect_t tcp_conn;
|
||||
tcp_server_t* ts;
|
||||
mio_dnsc_t dnsc = MIO_NULL;
|
||||
|
||||
mio = mio_open(&mmgr, 0, MIO_NULL, 512, MIO_NULL);
|
||||
if (!mio)
|
||||
{
|
||||
printf ("Cannot open mio\n");
|
||||
goto oops;
|
||||
}
|
||||
|
||||
memset (&tcp_make, 0, MIO_SIZEOF(tcp_make));
|
||||
tcp_make.type = MIO_DEV_SCK_TCP4;
|
||||
tcp_make.on_write = tcp_sck_on_write;
|
||||
tcp_make.on_read = tcp_sck_on_read;
|
||||
tcp_make.on_connect = tcp_sck_on_connect;
|
||||
tcp_make.on_disconnect = tcp_sck_on_disconnect;
|
||||
tcpsvr = mio_dev_sck_make(mio, MIO_SIZEOF(tcp_server_t), &tcp_make);
|
||||
if (!tcpsvr)
|
||||
{
|
||||
printf ("Cannot make a tcp server\n");
|
||||
goto oops;
|
||||
}
|
||||
|
||||
ts = (tcp_server_t*)(tcpsvr + 1);
|
||||
ts->tally = 0;
|
||||
|
||||
memset (&tcp_conn, 0, MIO_SIZEOF(tcp_conn));
|
||||
{
|
||||
in_addr_t ia = inet_addr("127.0.0.1");
|
||||
mio_sckaddr_initforip4 (&tcp_conn.remoteaddr, 9999, (mio_ip4addr_t*)&ia);
|
||||
}
|
||||
MIO_INIT_NTIME (&tcp_conn.connect_tmout, 5, 0);
|
||||
tcp_conn.options = 0;
|
||||
if (mio_dev_sck_connect(tcpsvr, &tcp_conn) <= -1)
|
||||
{
|
||||
}
|
||||
|
||||
#if 0
|
||||
while (1)
|
||||
{
|
||||
mio_exec (mio);
|
||||
}
|
||||
#endif
|
||||
mio_loop (mio);
|
||||
|
||||
oops:
|
||||
if (mio) mio_close (mio);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
963
mio/bin/t01.c
Normal file
963
mio/bin/t01.c
Normal file
@ -0,0 +1,963 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2015-2016 Chung, Hyung-Hwan. All rights reserved.
|
||||
|
||||
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 WAfRRANTIES
|
||||
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.
|
||||
*/
|
||||
|
||||
|
||||
#include <mio.h>
|
||||
#include <mio-utl.h>
|
||||
#include <mio-sck.h>
|
||||
#include <mio-pro.h>
|
||||
#include <mio-dns.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#if defined(HAVE_OPENSSL_SSL_H) && defined(HAVE_SSL)
|
||||
# include <openssl/ssl.h>
|
||||
# if defined(HAVE_OPENSSL_ERR_H)
|
||||
# include <openssl/err.h>
|
||||
# endif
|
||||
# if defined(HAVE_OPENSSL_ENGINE_H)
|
||||
# include <openssl/engine.h>
|
||||
# endif
|
||||
# define USE_SSL
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
struct mmgr_stat_t
|
||||
{
|
||||
mio_oow_t total_count;
|
||||
};
|
||||
|
||||
typedef struct mmgr_stat_t mmgr_stat_t;
|
||||
|
||||
static mmgr_stat_t mmgr_stat;
|
||||
|
||||
static void* mmgr_alloc (mio_mmgr_t* mmgr, mio_oow_t size)
|
||||
{
|
||||
void* x;
|
||||
|
||||
if (((mmgr_stat_t*)mmgr->ctx)->total_count > 300)
|
||||
{
|
||||
printf ("CRITICAL ERROR ---> too many heap chunks...\n");
|
||||
return MIO_NULL;
|
||||
}
|
||||
|
||||
x = malloc (size);
|
||||
if (x) ((mmgr_stat_t*)mmgr->ctx)->total_count++;
|
||||
return x;
|
||||
}
|
||||
|
||||
static void* mmgr_realloc (mio_mmgr_t* mmgr, void* ptr, mio_oow_t size)
|
||||
{
|
||||
return realloc (ptr, size);
|
||||
}
|
||||
|
||||
static void mmgr_free (mio_mmgr_t* mmgr, void* ptr)
|
||||
{
|
||||
((mmgr_stat_t*)mmgr->ctx)->total_count--;
|
||||
return free (ptr);
|
||||
}
|
||||
|
||||
|
||||
static mio_mmgr_t mmgr =
|
||||
{
|
||||
mmgr_alloc,
|
||||
mmgr_realloc,
|
||||
mmgr_free,
|
||||
&mmgr_stat
|
||||
};
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if defined(USE_SSL)
|
||||
static void cleanup_openssl ()
|
||||
{
|
||||
/* ERR_remove_state() should be called for each thread if the application is thread */
|
||||
ERR_remove_state (0);
|
||||
#if defined(HAVE_ENGINE_CLEANUP)
|
||||
ENGINE_cleanup ();
|
||||
#endif
|
||||
ERR_free_strings ();
|
||||
EVP_cleanup ();
|
||||
#if defined(HAVE_CRYPTO_CLEANUP_ALL_EX_DATA)
|
||||
CRYPTO_cleanup_all_ex_data ();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
struct tcp_server_t
|
||||
{
|
||||
int tally;
|
||||
};
|
||||
typedef struct tcp_server_t tcp_server_t;
|
||||
|
||||
static void tcp_sck_on_disconnect (mio_dev_sck_t* tcp)
|
||||
{
|
||||
switch (MIO_DEV_SCK_GET_PROGRESS(tcp))
|
||||
{
|
||||
case MIO_DEV_SCK_CONNECTING:
|
||||
MIO_INFO1 (tcp->mio, "OUTGOING SESSION DISCONNECTED - FAILED TO CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->sck);
|
||||
break;
|
||||
|
||||
case MIO_DEV_SCK_CONNECTING_SSL:
|
||||
MIO_INFO1 (tcp->mio, "OUTGOING SESSION DISCONNECTED - FAILED TO SSL-CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->sck);
|
||||
break;
|
||||
|
||||
case MIO_DEV_SCK_LISTENING:
|
||||
MIO_INFO1 (tcp->mio, "SHUTTING DOWN THE SERVER SOCKET(%d)...\n", (int)tcp->sck);
|
||||
break;
|
||||
|
||||
case MIO_DEV_SCK_CONNECTED:
|
||||
MIO_INFO1 (tcp->mio, "OUTGOING CLIENT CONNECTION GOT TORN DOWN(%d).......\n", (int)tcp->sck);
|
||||
break;
|
||||
|
||||
case MIO_DEV_SCK_ACCEPTING_SSL:
|
||||
MIO_INFO1 (tcp->mio, "INCOMING SSL-ACCEPT GOT DISCONNECTED(%d) ....\n", (int)tcp->sck);
|
||||
break;
|
||||
|
||||
case MIO_DEV_SCK_ACCEPTED:
|
||||
MIO_INFO1 (tcp->mio, "INCOMING CLIENT BEING SERVED GOT DISCONNECTED(%d).......\n", (int)tcp->sck);
|
||||
break;
|
||||
|
||||
default:
|
||||
MIO_INFO2 (tcp->mio, "SOCKET DEVICE DISCONNECTED (%d - %x)\n", (int)tcp->sck, (unsigned int)tcp->state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void tcp_sck_on_connect (mio_dev_sck_t* tcp)
|
||||
{
|
||||
mio_sckfam_t fam;
|
||||
mio_scklen_t len;
|
||||
mio_bch_t buf1[128], buf2[128];
|
||||
|
||||
memset (buf1, 0, MIO_SIZEOF(buf1));
|
||||
memset (buf2, 0, MIO_SIZEOF(buf2));
|
||||
|
||||
mio_getsckaddrinfo (tcp->mio, &tcp->localaddr, &len, &fam);
|
||||
inet_ntop (fam, tcp->localaddr.data, buf1, MIO_COUNTOF(buf1));
|
||||
|
||||
mio_getsckaddrinfo (tcp->mio, &tcp->remoteaddr, &len, &fam);
|
||||
inet_ntop (fam, tcp->remoteaddr.data, buf2, MIO_COUNTOF(buf2));
|
||||
|
||||
if (tcp->state & MIO_DEV_SCK_CONNECTED)
|
||||
{
|
||||
MIO_INFO5 (tcp->mio, "DEVICE connected to a remote server... LOCAL %hs:%d REMOTE %hs:%d SCK: %d\n",
|
||||
buf1, mio_getsckaddrport(&tcp->localaddr), buf2, mio_getsckaddrport(&tcp->remoteaddr), tcp->sck);
|
||||
}
|
||||
else if (tcp->state & MIO_DEV_SCK_ACCEPTED)
|
||||
{
|
||||
MIO_INFO5 (tcp->mio, "DEVICE accepted client device... .LOCAL %hs:%d REMOTE %hs:%d\n",
|
||||
buf1, mio_getsckaddrport(&tcp->localaddr), buf2, mio_getsckaddrport(&tcp->remoteaddr), tcp->sck);
|
||||
}
|
||||
|
||||
if (mio_dev_sck_write(tcp, "hello", 5, MIO_NULL, MIO_NULL) <= -1)
|
||||
{
|
||||
mio_dev_sck_halt (tcp);
|
||||
}
|
||||
}
|
||||
|
||||
static int tcp_sck_on_write (mio_dev_sck_t* tcp, mio_iolen_t wrlen, void* wrctx, const mio_sckaddr_t* dstaddr)
|
||||
{
|
||||
tcp_server_t* ts;
|
||||
mio_ntime_t tmout;
|
||||
|
||||
if (wrlen <= -1)
|
||||
{
|
||||
MIO_INFO1 (tcp->mio, "TCP_SCK_ON_WRITE(%d) >>> SEDING TIMED OUT...........\n", (int)tcp->sck);
|
||||
mio_dev_sck_halt (tcp);
|
||||
}
|
||||
else
|
||||
{
|
||||
ts = (tcp_server_t*)(tcp + 1);
|
||||
if (wrlen == 0)
|
||||
{
|
||||
MIO_INFO1 (tcp->mio, "TCP_SCK_ON_WRITE(%d) >>> CLOSED WRITING END\n", (int)tcp->sck);
|
||||
}
|
||||
else
|
||||
{
|
||||
MIO_INFO3 (tcp->mio, "TCP_SCK_ON_WRITE(%d) >>> SENT MESSAGE %d of length %ld\n", (int)tcp->sck, ts->tally, (long int)wrlen);
|
||||
}
|
||||
|
||||
ts->tally++;
|
||||
// if (ts->tally >= 2) mio_dev_sck_halt (tcp);
|
||||
|
||||
|
||||
MIO_INIT_NTIME (&tmout, 5, 0);
|
||||
//mio_dev_sck_read (tcp, 1);
|
||||
|
||||
MIO_INFO3 (tcp->mio, "TCP_SCK_ON_WRITE(%d) >>> REQUESTING to READ with timeout of %ld.%08ld\n", (int)tcp->sck, (long int)tmout.sec, (long int)tmout.nsec);
|
||||
mio_dev_sck_timedread (tcp, 1, &tmout);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tcp_sck_on_read (mio_dev_sck_t* tcp, const void* buf, mio_iolen_t len, const mio_sckaddr_t* srcaddr)
|
||||
{
|
||||
int n;
|
||||
|
||||
if (len <= -1)
|
||||
{
|
||||
MIO_INFO1 (tcp->mio, "TCP_SCK_ON_READ(%d) STREAM DEVICE: TIMED OUT...\n", (int)tcp->sck);
|
||||
mio_dev_sck_halt (tcp);
|
||||
return 0;
|
||||
}
|
||||
else if (len <= 0)
|
||||
{
|
||||
MIO_INFO1 (tcp->mio, "TCP_SCK_ON_READ(%d) STREAM DEVICE: EOF RECEIVED...\n", (int)tcp->sck);
|
||||
/* no outstanding request. but EOF */
|
||||
mio_dev_sck_halt (tcp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MIO_INFO2 (tcp->mio, "TCP_SCK_ON_READ(%d) - received %d bytes\n", (int)tcp->sck, (int)len);
|
||||
|
||||
{
|
||||
mio_ntime_t tmout;
|
||||
|
||||
static char a ='A';
|
||||
static char xxx[1000000];
|
||||
memset (xxx, a++ , MIO_SIZEOF(xxx));
|
||||
|
||||
MIO_INFO2 (tcp->mio, "TCP_SCK_ON_READ(%d) >>> REQUESTING to write data of %d bytes\n", (int)tcp->sck, MIO_SIZEOF(xxx));
|
||||
//return mio_dev_sck_write (tcp, "HELLO", 5, MIO_NULL);
|
||||
MIO_INIT_NTIME (&tmout, 5, 0);
|
||||
n = mio_dev_sck_timedwrite(tcp, xxx, MIO_SIZEOF(xxx), &tmout, MIO_NULL, MIO_NULL);
|
||||
|
||||
if (n <= -1) return -1;
|
||||
}
|
||||
|
||||
MIO_INFO1 (tcp->mio, "TCP_SCK_ON_READ(%d) - REQUESTING TO STOP READ\n", (int)tcp->sck);
|
||||
mio_dev_sck_read (tcp, 0);
|
||||
|
||||
#if 0
|
||||
MIO_INFO1 (tcp->mio, "TCP_SCK_ON_READ(%d) - REQUESTING TO CLOSE WRITING END\n", (int)tcp->sck);
|
||||
/* post the write finisher - close the writing end */
|
||||
n = mio_dev_sck_write(tcp, MIO_NULL, 0, MIO_NULL, MIO_NULL);
|
||||
if (n <= -1) return -1;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
/* return 1; let the main loop to read more greedily without consulting the multiplexer */
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static void pro_on_close (mio_dev_pro_t* pro, mio_dev_pro_sid_t sid)
|
||||
{
|
||||
mio_t* mio = pro->mio;
|
||||
if (sid == MIO_DEV_PRO_MASTER)
|
||||
MIO_INFO1 (mio, "PROCESS(%d) CLOSE MASTER\n", (int)pro->child_pid);
|
||||
else
|
||||
MIO_INFO2 (mio, "PROCESS(%d) CLOSE SLAVE[%d]\n", (int)pro->child_pid, sid);
|
||||
}
|
||||
|
||||
static int pro_on_read (mio_dev_pro_t* pro, mio_dev_pro_sid_t sid, const void* data, mio_iolen_t dlen)
|
||||
{
|
||||
mio_t* mio = pro->mio;
|
||||
|
||||
if (dlen <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "PROCESS(%d): READ TIMED OUT...\n", (int)pro->child_pid);
|
||||
mio_dev_pro_halt (pro);
|
||||
return 0;
|
||||
}
|
||||
else if (dlen <= 0)
|
||||
{
|
||||
MIO_INFO1 (mio, "PROCESS(%d): EOF RECEIVED...\n", (int)pro->child_pid);
|
||||
/* no outstanding request. but EOF */
|
||||
mio_dev_pro_halt (pro);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MIO_INFO5 (mio, "PROCESS(%d) READ DATA ON SLAVE[%d] len=%d [%.*hs]\n", (int)pro->child_pid, (int)sid, (int)dlen, dlen, (char*)data);
|
||||
if (sid == MIO_DEV_PRO_OUT)
|
||||
{
|
||||
mio_dev_pro_read (pro, sid, 0);
|
||||
mio_dev_pro_write (pro, "HELLO\n", 6, MIO_NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pro_on_write (mio_dev_pro_t* pro, mio_iolen_t wrlen, void* wrctx)
|
||||
{
|
||||
mio_t* mio = pro->mio;
|
||||
mio_ntime_t tmout;
|
||||
if (wrlen <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "PROCESS(%d): WRITE TIMED OUT...\n", (int)pro->child_pid);
|
||||
mio_dev_pro_halt (pro);
|
||||
return 0;
|
||||
}
|
||||
|
||||
MIO_DEBUG2 (mio, "PROCESS(%d) wrote data of %d bytes\n", (int)pro->child_pid, (int)wrlen);
|
||||
/*mio_dev_pro_read (pro, MIO_DEV_PRO_OUT, 1);*/
|
||||
MIO_INIT_NTIME (&tmout, 5, 0);
|
||||
mio_dev_pro_timedread (pro, MIO_DEV_PRO_OUT, 1, &tmout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
static int arp_sck_on_read (mio_dev_sck_t* dev, const void* data, mio_iolen_t dlen, const mio_sckaddr_t* srcaddr)
|
||||
{
|
||||
mio_etharp_pkt_t* eap;
|
||||
|
||||
|
||||
if (dlen < MIO_SIZEOF(*eap)) return 0; /* drop */
|
||||
|
||||
eap = (mio_etharp_pkt_t*)data;
|
||||
|
||||
printf ("ARP ON IFINDEX %d OPCODE: %d", mio_getsckaddrifindex(srcaddr), ntohs(eap->arphdr.opcode));
|
||||
|
||||
printf (" SHA: %02X:%02X:%02X:%02X:%02X:%02X", eap->arppld.sha[0], eap->arppld.sha[1], eap->arppld.sha[2], eap->arppld.sha[3], eap->arppld.sha[4], eap->arppld.sha[5]);
|
||||
printf (" SPA: %d.%d.%d.%d", eap->arppld.spa[0], eap->arppld.spa[1], eap->arppld.spa[2], eap->arppld.spa[3]);
|
||||
printf (" THA: %02X:%02X:%02X:%02X:%02X:%02X", eap->arppld.tha[0], eap->arppld.tha[1], eap->arppld.tha[2], eap->arppld.tha[3], eap->arppld.tha[4], eap->arppld.tha[5]);
|
||||
printf (" TPA: %d.%d.%d.%d", eap->arppld.tpa[0], eap->arppld.tpa[1], eap->arppld.tpa[2], eap->arppld.tpa[3]);
|
||||
printf ("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int arp_sck_on_write (mio_dev_sck_t* dev, mio_iolen_t wrlen, void* wrctx, const mio_sckaddr_t* dstaddr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void arp_sck_on_connect (mio_dev_sck_t* dev)
|
||||
{
|
||||
printf ("STARTING UP ARP SOCKET %d...\n", dev->sck);
|
||||
}
|
||||
|
||||
static void arp_sck_on_disconnect (mio_dev_sck_t* dev)
|
||||
{
|
||||
printf ("SHUTTING DOWN ARP SOCKET %d...\n", dev->sck);
|
||||
}
|
||||
|
||||
static int setup_arp_tester (mio_t* mio)
|
||||
{
|
||||
mio_sckaddr_t ethdst;
|
||||
mio_etharp_pkt_t etharp;
|
||||
mio_dev_sck_make_t sck_make;
|
||||
mio_dev_sck_t* sck;
|
||||
|
||||
memset (&sck_make, 0, MIO_SIZEOF(sck_make));
|
||||
sck_make.type = MIO_DEV_SCK_ARP;
|
||||
//sck_make.type = MIO_DEV_SCK_ARP_DGRAM;
|
||||
sck_make.on_write = arp_sck_on_write;
|
||||
sck_make.on_read = arp_sck_on_read;
|
||||
sck_make.on_connect = arp_sck_on_connect;
|
||||
sck_make.on_disconnect = arp_sck_on_disconnect;
|
||||
sck = mio_dev_sck_make(mio, 0, &sck_make);
|
||||
if (!sck)
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot make arp socket device - %js\n", mio_geterrmsg(mio));
|
||||
return -1;
|
||||
}
|
||||
|
||||
//mio_sckaddr_initforeth (ðdst, if_nametoindex("enp0s25.3"), (mio_ethaddr_t*)"\xFF\xFF\xFF\xFF\xFF\xFF");
|
||||
//mio_sckaddr_initforeth (ðdst, if_nametoindex("enp0s25.3"), (mio_ethaddr_t*)"\xAA\xBB\xFF\xCC\xDD\xFF");
|
||||
|
||||
mio_sckaddr_initforeth (ðdst, if_nametoindex("wlan0"), (mio_ethaddr_t*)"\xAA\xBB\xFF\xCC\xDD\xFF");
|
||||
|
||||
memset (ðarp, 0, MIO_SIZEOF(etharp));
|
||||
|
||||
memcpy (etharp.ethhdr.source, "\xB8\x6B\x23\x9C\x10\x76", MIO_ETHADDR_LEN);
|
||||
//memcpy (etharp.ethhdr.dest, "\xFF\xFF\xFF\xFF\xFF\xFF", MIO_ETHADDR_LEN);
|
||||
memcpy (etharp.ethhdr.dest, "\xAA\xBB\xFF\xCC\xDD\xFF", MIO_ETHADDR_LEN);
|
||||
etharp.ethhdr.proto = MIO_CONST_HTON16(MIO_ETHHDR_PROTO_ARP);
|
||||
|
||||
etharp.arphdr.htype = MIO_CONST_HTON16(MIO_ARPHDR_HTYPE_ETH);
|
||||
etharp.arphdr.ptype = MIO_CONST_HTON16(MIO_ARPHDR_PTYPE_IP4);
|
||||
etharp.arphdr.hlen = MIO_ETHADDR_LEN;
|
||||
etharp.arphdr.plen = MIO_IP4ADDR_LEN;
|
||||
etharp.arphdr.opcode = MIO_CONST_HTON16(MIO_ARPHDR_OPCODE_REQUEST);
|
||||
|
||||
memcpy (etharp.arppld.sha, "\xB8\x6B\x23\x9C\x10\x76", MIO_ETHADDR_LEN);
|
||||
|
||||
if (mio_dev_sck_write(sck, ðarp, MIO_SIZEOF(etharp), MIO_NULL, ðdst) <= -1)
|
||||
//if (mio_dev_sck_write (sck, ðarp.arphdr, MIO_SIZEOF(etharp) - MIO_SIZEOF(etharp.ethhdr), MIO_NULL, ðaddr) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot write arp - %js\n", mio_geterrmsg(mio));
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
struct icmpxtn_t
|
||||
{
|
||||
mio_uint16_t icmp_seq;
|
||||
mio_tmridx_t tmout_jobidx;
|
||||
int reply_received;
|
||||
};
|
||||
|
||||
typedef struct icmpxtn_t icmpxtn_t;
|
||||
|
||||
static int schedule_icmp_wait (mio_dev_sck_t* dev);
|
||||
|
||||
static void send_icmp (mio_dev_sck_t* dev, mio_uint16_t seq)
|
||||
{
|
||||
mio_t* mio = dev->mio;
|
||||
mio_sckaddr_t dstaddr;
|
||||
mio_ip4addr_t ia;
|
||||
mio_icmphdr_t* icmphdr;
|
||||
mio_uint8_t buf[512];
|
||||
|
||||
inet_pton (AF_INET, "192.168.1.131", &ia);
|
||||
mio_sckaddr_initforip4 (&dstaddr, 0, &ia);
|
||||
|
||||
memset(buf, 0, MIO_SIZEOF(buf));
|
||||
icmphdr = (mio_icmphdr_t*)buf;
|
||||
icmphdr->type = MIO_ICMP_ECHO_REQUEST;
|
||||
icmphdr->u.echo.id = MIO_CONST_HTON16(100);
|
||||
icmphdr->u.echo.seq = mio_hton16(seq);
|
||||
|
||||
memset (&buf[MIO_SIZEOF(*icmphdr)], 'A', MIO_SIZEOF(buf) - MIO_SIZEOF(*icmphdr));
|
||||
icmphdr->checksum = mio_checksumip (icmphdr, MIO_SIZEOF(buf));
|
||||
|
||||
if (mio_dev_sck_write(dev, buf, MIO_SIZEOF(buf), MIO_NULL, &dstaddr) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot write icmp - %js\n", mio_geterrmsg(mio));
|
||||
mio_dev_sck_halt (dev);
|
||||
}
|
||||
|
||||
if (schedule_icmp_wait (dev) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot schedule icmp wait - %js\n", mio_geterrmsg(mio));
|
||||
mio_dev_sck_halt (dev);
|
||||
}
|
||||
}
|
||||
|
||||
static void on_icmp_due (mio_t* mio, const mio_ntime_t* now, mio_tmrjob_t* tmrjob)
|
||||
{
|
||||
mio_dev_sck_t* dev;
|
||||
icmpxtn_t* icmpxtn;
|
||||
|
||||
dev = tmrjob->ctx;
|
||||
icmpxtn = (icmpxtn_t*)(dev + 1);
|
||||
|
||||
if (icmpxtn->reply_received)
|
||||
icmpxtn->reply_received = 0;
|
||||
else
|
||||
MIO_INFO0 (mio, "NO IMCP reply received in time\n");
|
||||
|
||||
send_icmp (dev, ++icmpxtn->icmp_seq);
|
||||
}
|
||||
|
||||
static int schedule_icmp_wait (mio_dev_sck_t* dev)
|
||||
{
|
||||
mio_t* mio = dev->mio;
|
||||
icmpxtn_t* icmpxtn;
|
||||
mio_tmrjob_t tmrjob;
|
||||
mio_ntime_t fire_after;
|
||||
|
||||
icmpxtn = (icmpxtn_t*)(dev + 1);
|
||||
MIO_INIT_NTIME (&fire_after, 2, 0);
|
||||
|
||||
memset (&tmrjob, 0, MIO_SIZEOF(tmrjob));
|
||||
tmrjob.ctx = dev;
|
||||
mio_gettime (mio, &tmrjob.when);
|
||||
MIO_ADD_NTIME (&tmrjob.when, &tmrjob.when, &fire_after);
|
||||
tmrjob.handler = on_icmp_due;
|
||||
tmrjob.idxptr = &icmpxtn->tmout_jobidx;
|
||||
|
||||
assert (icmpxtn->tmout_jobidx == MIO_TMRIDX_INVALID);
|
||||
|
||||
return (mio_instmrjob(dev->mio, &tmrjob) == MIO_TMRIDX_INVALID)? -1: 0;
|
||||
}
|
||||
|
||||
static int icmp_sck_on_read (mio_dev_sck_t* dev, const void* data, mio_iolen_t dlen, const mio_sckaddr_t* srcaddr)
|
||||
{
|
||||
icmpxtn_t* icmpxtn;
|
||||
mio_iphdr_t* iphdr;
|
||||
mio_icmphdr_t* icmphdr;
|
||||
|
||||
/* when received, the data contains the IP header.. */
|
||||
icmpxtn = (icmpxtn_t*)(dev + 1);
|
||||
|
||||
if (dlen < MIO_SIZEOF(*iphdr) + MIO_SIZEOF(*icmphdr))
|
||||
{
|
||||
printf ("INVALID ICMP PACKET.. TOO SHORT...%d\n", (int)dlen);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO: consider IP options... */
|
||||
iphdr = (mio_iphdr_t*)data;
|
||||
|
||||
if (iphdr->ihl * 4 + MIO_SIZEOF(*icmphdr) > dlen)
|
||||
{
|
||||
printf ("INVALID ICMP PACKET.. WRONG IHL...%d\n", (int)iphdr->ihl * 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
icmphdr = (mio_icmphdr_t*)((mio_uint8_t*)data + (iphdr->ihl * 4));
|
||||
|
||||
/* TODO: check srcaddr against target */
|
||||
|
||||
if (icmphdr->type == MIO_ICMP_ECHO_REPLY &&
|
||||
mio_ntoh16(icmphdr->u.echo.seq) == icmpxtn->icmp_seq) /* TODO: more check.. echo.id.. */
|
||||
{
|
||||
icmpxtn->reply_received = 1;
|
||||
printf ("ICMP REPLY RECEIVED...ID %d SEQ %d\n", (int)mio_ntoh16(icmphdr->u.echo.id), (int)mio_ntoh16(icmphdr->u.echo.seq));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("GARBAGE ICMP PACKET...LEN %d SEQ %d,%d\n", (int)dlen, (int)icmpxtn->icmp_seq, (int)mio_ntoh16(icmphdr->u.echo.seq));
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int icmp_sck_on_write (mio_dev_sck_t* dev, mio_iolen_t wrlen, void* wrctx, const mio_sckaddr_t* dstaddr)
|
||||
{
|
||||
/*icmpxtn_t* icmpxtn;
|
||||
|
||||
icmpxtn = (icmpxtn_t*)(dev + 1); */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void icmp_sck_on_disconnect (mio_dev_sck_t* dev)
|
||||
{
|
||||
icmpxtn_t* icmpxtn;
|
||||
|
||||
icmpxtn = (icmpxtn_t*)(dev + 1);
|
||||
|
||||
printf ("SHUTTING DOWN ICMP SOCKET %d...\n", dev->sck);
|
||||
if (icmpxtn->tmout_jobidx != MIO_TMRIDX_INVALID)
|
||||
{
|
||||
|
||||
mio_deltmrjob (dev->mio, icmpxtn->tmout_jobidx);
|
||||
icmpxtn->tmout_jobidx = MIO_TMRIDX_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
static int setup_ping4_tester (mio_t* mio)
|
||||
{
|
||||
mio_dev_sck_make_t sck_make;
|
||||
mio_dev_sck_t* sck;
|
||||
icmpxtn_t* icmpxtn;
|
||||
|
||||
memset (&sck_make, 0, MIO_SIZEOF(sck_make));
|
||||
sck_make.type = MIO_DEV_SCK_ICMP4;
|
||||
sck_make.on_write = icmp_sck_on_write;
|
||||
sck_make.on_read = icmp_sck_on_read;
|
||||
sck_make.on_disconnect = icmp_sck_on_disconnect;
|
||||
|
||||
sck = mio_dev_sck_make (mio, MIO_SIZEOF(icmpxtn_t), &sck_make);
|
||||
if (!sck)
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot make ICMP4 socket device - %js\n", mio_geterrmsg(mio));
|
||||
return -1;
|
||||
}
|
||||
|
||||
icmpxtn = (icmpxtn_t*)(sck + 1);
|
||||
icmpxtn->tmout_jobidx = MIO_TMRIDX_INVALID;
|
||||
icmpxtn->icmp_seq = 0;
|
||||
|
||||
/*TODO: mio_dev_sck_setbroadcast (sck, 1);*/
|
||||
|
||||
send_icmp (sck, ++icmpxtn->icmp_seq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if 1
|
||||
static mio_t* g_mio;
|
||||
|
||||
static void handle_signal (int sig)
|
||||
{
|
||||
if (g_mio) mio_stop (g_mio, MIO_STOPREQ_TERMINATION);
|
||||
}
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
mio_t* mio;
|
||||
mio_dev_sck_t* tcp[3];
|
||||
|
||||
struct sigaction sigact;
|
||||
mio_dev_sck_connect_t tcp_conn;
|
||||
mio_dev_sck_listen_t tcp_lstn;
|
||||
mio_dev_sck_bind_t tcp_bind;
|
||||
mio_dev_sck_make_t tcp_make;
|
||||
|
||||
tcp_server_t* ts;
|
||||
|
||||
#if defined(USE_SSL)
|
||||
SSL_load_error_strings ();
|
||||
SSL_library_init ();
|
||||
#endif
|
||||
|
||||
mio = mio_open(&mmgr, 0, MIO_NULL, 512, MIO_NULL);
|
||||
if (!mio)
|
||||
{
|
||||
printf ("Cannot open mio\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_mio = mio;
|
||||
|
||||
memset (&sigact, 0, MIO_SIZEOF(sigact));
|
||||
sigact.sa_flags = SA_RESTART;
|
||||
sigact.sa_handler = handle_signal;
|
||||
sigaction (SIGINT, &sigact, MIO_NULL);
|
||||
|
||||
memset (&sigact, 0, MIO_SIZEOF(sigact));
|
||||
sigact.sa_handler = SIG_IGN;
|
||||
sigaction (SIGPIPE, &sigact, MIO_NULL);
|
||||
|
||||
/*
|
||||
memset (&sigact, 0, MIO_SIZEOF(sigact));
|
||||
sigact.sa_handler = SIG_IGN;
|
||||
sigaction (SIGCHLD, &sigact, MIO_NULL);
|
||||
*/
|
||||
|
||||
/*memset (&sin, 0, MIO_SIZEOF(sin));
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(1234); */
|
||||
/*
|
||||
udp = (mio_dev_udp_t*)mio_dev_make(mio, MIO_SIZEOF(*udp), &udp_mth, &udp_evcb, &sin);
|
||||
if (!udp)
|
||||
{
|
||||
printf ("Cannot make udp\n");
|
||||
goto oops;
|
||||
}
|
||||
*/
|
||||
|
||||
memset (&tcp_make, 0, MIO_SIZEOF(tcp_make));
|
||||
tcp_make.type = MIO_DEV_SCK_TCP4;
|
||||
tcp_make.on_write = tcp_sck_on_write;
|
||||
tcp_make.on_read = tcp_sck_on_read;
|
||||
tcp_make.on_connect = tcp_sck_on_connect;
|
||||
tcp_make.on_disconnect = tcp_sck_on_disconnect;
|
||||
tcp[0] = mio_dev_sck_make(mio, MIO_SIZEOF(tcp_server_t), &tcp_make);
|
||||
if (!tcp[0])
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot make tcp - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
ts = (tcp_server_t*)(tcp[0] + 1);
|
||||
ts->tally = 0;
|
||||
|
||||
memset (&tcp_conn, 0, MIO_SIZEOF(tcp_conn));
|
||||
{
|
||||
/* openssl s_server -accept 9999 -key localhost.key -cert localhost.crt */
|
||||
in_addr_t ia = inet_addr("127.0.0.1");
|
||||
mio_sckaddr_initforip4 (&tcp_conn.remoteaddr, 9999, (mio_ip4addr_t*)&ia);
|
||||
}
|
||||
|
||||
MIO_INIT_NTIME (&tcp_conn.connect_tmout, 5, 0);
|
||||
tcp_conn.options = MIO_DEV_SCK_CONNECT_SSL;
|
||||
if (mio_dev_sck_connect(tcp[0], &tcp_conn) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "tcp[0] mio_dev_sck_connect() failed - %js\n", mio_geterrmsg(mio));
|
||||
/* carry on regardless of failure */
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
memset (&tcp_make, 0, MIO_SIZEOF(tcp_make));
|
||||
tcp_make.type = MIO_DEV_SCK_TCP4;
|
||||
tcp_make.on_write = tcp_sck_on_write;
|
||||
tcp_make.on_read = tcp_sck_on_read;
|
||||
tcp_make.on_connect = tcp_sck_on_connect;
|
||||
tcp_make.on_disconnect = tcp_sck_on_disconnect;
|
||||
|
||||
tcp[1] = mio_dev_sck_make(mio, MIO_SIZEOF(tcp_server_t), &tcp_make);
|
||||
if (!tcp[1])
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot make tcp[1] - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
ts = (tcp_server_t*)(tcp[1] + 1);
|
||||
ts->tally = 0;
|
||||
|
||||
memset (&tcp_bind, 0, MIO_SIZEOF(tcp_bind));
|
||||
mio_sckaddr_initforip4 (&tcp_bind.localaddr, 1234, MIO_NULL);
|
||||
tcp_bind.options = MIO_DEV_SCK_BIND_REUSEADDR;
|
||||
|
||||
if (mio_dev_sck_bind(tcp[1],&tcp_bind) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "tcp[1] mio_dev_sck_bind() failed - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
|
||||
tcp_lstn.backlogs = 100;
|
||||
if (mio_dev_sck_listen(tcp[1], &tcp_lstn) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "tcp[1] mio_dev_sck_listen() failed - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- */
|
||||
memset (&tcp_make, 0, MIO_SIZEOF(tcp_make));
|
||||
tcp_make.type = MIO_DEV_SCK_TCP4;
|
||||
tcp_make.on_write = tcp_sck_on_write;
|
||||
tcp_make.on_read = tcp_sck_on_read;
|
||||
tcp_make.on_connect = tcp_sck_on_connect;
|
||||
tcp_make.on_disconnect = tcp_sck_on_disconnect;
|
||||
|
||||
tcp[2] = mio_dev_sck_make(mio, MIO_SIZEOF(tcp_server_t), &tcp_make);
|
||||
if (!tcp[2])
|
||||
{
|
||||
MIO_INFO1 (mio, "Cannot make tcp[2] - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
ts = (tcp_server_t*)(tcp[2] + 1);
|
||||
ts->tally = 0;
|
||||
|
||||
memset (&tcp_bind, 0, MIO_SIZEOF(tcp_bind));
|
||||
mio_sckaddr_initforip4 (&tcp_bind.localaddr, 1235, MIO_NULL);
|
||||
tcp_bind.options = MIO_DEV_SCK_BIND_REUSEADDR /*| MIO_DEV_SCK_BIND_REUSEPORT |*/;
|
||||
#if defined(USE_SSL)
|
||||
tcp_bind.options |= MIO_DEV_SCK_BIND_SSL;
|
||||
tcp_bind.ssl_certfile = "localhost.crt";
|
||||
tcp_bind.ssl_keyfile = "localhost.key";
|
||||
#endif
|
||||
MIO_INIT_NTIME (&tcp_bind.accept_tmout, 5, 1);
|
||||
|
||||
if (mio_dev_sck_bind(tcp[2], &tcp_bind) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "tcp[2] mio_dev_sck_bind() failed - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
tcp_lstn.backlogs = 100;
|
||||
if (mio_dev_sck_listen(tcp[2], &tcp_lstn) <= -1)
|
||||
{
|
||||
MIO_INFO1 (mio, "tcp[2] mio_dev_sck_listen() failed - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
//mio_dev_sck_sendfile (tcp[2], fd, offset, count);
|
||||
|
||||
setup_arp_tester(mio);
|
||||
setup_ping4_tester(mio);
|
||||
|
||||
#if 1
|
||||
for (i = 0; i < 5; i++)
|
||||
{
|
||||
mio_dev_pro_t* pro;
|
||||
mio_dev_pro_make_t pro_make;
|
||||
|
||||
memset (&pro_make, 0, MIO_SIZEOF(pro_make));
|
||||
pro_make.flags = MIO_DEV_PRO_READOUT | MIO_DEV_PRO_READERR | MIO_DEV_PRO_WRITEIN /*| MIO_DEV_PRO_FORGET_CHILD*/;
|
||||
//pro_make.cmd = "/bin/ls -laF /usr/bin";
|
||||
//pro_make.cmd = "/bin/ls -laF";
|
||||
pro_make.cmd = "./a";
|
||||
pro_make.on_read = pro_on_read;
|
||||
pro_make.on_write = pro_on_write;
|
||||
pro_make.on_close = pro_on_close;
|
||||
|
||||
pro = mio_dev_pro_make(mio, 0, &pro_make);
|
||||
if (!pro)
|
||||
{
|
||||
MIO_INFO1 (mio, "CANNOT CREATE PROCESS PIPE - %js\n", mio_geterrmsg(mio));
|
||||
goto oops;
|
||||
}
|
||||
mio_dev_pro_read (pro, MIO_DEV_PRO_OUT, 0);
|
||||
//mio_dev_pro_read (pro, MIO_DEV_PRO_ERR, 0);
|
||||
|
||||
mio_dev_pro_write (pro, "MY MIO LIBRARY\n", 16, MIO_NULL);
|
||||
//mio_dev_pro_killchild (pro);
|
||||
//mio_dev_pro_close (pro, MIO_DEV_PRO_IN);
|
||||
//mio_dev_pro_close (pro, MIO_DEV_PRO_OUT);
|
||||
//mio_dev_pro_close (pro, MIO_DEV_PRO_ERR);
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
mio_dnsc_t* dnsc;
|
||||
dnsc = mio_dnsc_start (mio/*, "8.8.8.8:53,1.1.1.1:53"*/); /* option - send to all, send one by one */
|
||||
{
|
||||
mio_dns_bqr_t qrs[] =
|
||||
{
|
||||
{ "code.miflux.com", MIO_DNS_QTYPE_A, MIO_DNS_QCLASS_IN },
|
||||
{ "code.miflux.com", MIO_DNS_QTYPE_AAAA, MIO_DNS_QCLASS_IN },
|
||||
{ "code.abiyo.net", MIO_DNS_QTYPE_A, MIO_DNS_QCLASS_IN },
|
||||
{ "code6.abiyo.net", MIO_DNS_QTYPE_AAAA, MIO_DNS_QCLASS_IN },
|
||||
{ "abiyo.net", MIO_DNS_QTYPE_MX, MIO_DNS_QCLASS_IN }
|
||||
};
|
||||
mio_dns_brr_t rrs[] =
|
||||
{
|
||||
{ MIO_DNS_RR_PART_ANSWER, "code.miflux.com", MIO_DNS_QTYPE_A, MIO_DNS_QCLASS_IN, 86400, 0, MIO_NULL },
|
||||
{ MIO_DNS_RR_PART_ANSWER, "code.miflux.com", MIO_DNS_QTYPE_AAAA, MIO_DNS_QCLASS_IN, 86400, 0, MIO_NULL },
|
||||
{ MIO_DNS_RR_PART_AUTHORITY, "dns.miflux.com", MIO_DNS_QTYPE_NS, MIO_DNS_QCLASS_IN, 86400, 0, MIO_NULL }//,
|
||||
//{ MIO_DNS_RR_PART_ANSERT, "www.miflux.com", MIO_DNS_QTYPE_CNAME, MIO_DNS_QCLASS_IN, 60, 15, "code.miflux.com" }
|
||||
};
|
||||
|
||||
mio_dns_beopt_t beopt[] =
|
||||
{
|
||||
{ MIO_DNS_EOPT_COOKIE, 8, "\x01\x02\x03\x04\0x05\x06\0x07\0x08" },
|
||||
{ MIO_DNS_EOPT_NSID, 0, MIO_NULL }
|
||||
};
|
||||
|
||||
mio_dns_bedns_t qedns =
|
||||
{
|
||||
4096, /* uplen */
|
||||
|
||||
0, /* edns version */
|
||||
0, /* dnssec ok */
|
||||
|
||||
MIO_COUNTOF(beopt), /* number of edns options */
|
||||
beopt
|
||||
};
|
||||
|
||||
mio_dns_bdns_t qhdr =
|
||||
{
|
||||
-1, /* id */
|
||||
0, /* qr */
|
||||
MIO_DNS_OPCODE_QUERY, /* opcode */
|
||||
0, /* aa */
|
||||
0, /* tc */
|
||||
1, /* rd */
|
||||
0, /* ra */
|
||||
0, /* ad */
|
||||
0, /* cd */
|
||||
MIO_DNS_RCODE_NOERROR /* rcode */
|
||||
};
|
||||
|
||||
mio_dns_bdns_t rhdr =
|
||||
{
|
||||
0x1234, /* id */
|
||||
1, /* qr */
|
||||
MIO_DNS_OPCODE_QUERY, /* opcode */
|
||||
|
||||
0, /* aa */
|
||||
0, /* tc */
|
||||
0, /* rd */
|
||||
1, /* ra */
|
||||
0, /* ad */
|
||||
0, /* cd */
|
||||
MIO_DNS_RCODE_BADCOOKIE /* rcode */
|
||||
};
|
||||
|
||||
mio_dnsc_sendreq (dnsc, &qhdr, qrs, MIO_COUNTOF(qrs), &qedns);
|
||||
mio_dnsc_sendmsg (dnsc, &rhdr, qrs, MIO_COUNTOF(qrs), rrs, MIO_COUNTOF(rrs), &qedns);
|
||||
}
|
||||
|
||||
mio_loop (mio);
|
||||
|
||||
/* TODO: let mio close it ... dnsc is svc. sck is dev. */
|
||||
mio_dnsc_stop (dnsc);
|
||||
}
|
||||
|
||||
g_mio = MIO_NULL;
|
||||
mio_close (mio);
|
||||
#if defined(USE_SSL)
|
||||
cleanup_openssl ();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
g_mio = MIO_NULL;
|
||||
mio_close (mio);
|
||||
#if defined(USE_SSL)
|
||||
cleanup_openssl ();
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
mio_t* mio = MIO_NULL;
|
||||
mio_dev_sck_t* tcpsvr;
|
||||
mio_dev_sck_make_t tcp_make;
|
||||
mio_dev_sck_connect_t tcp_conn;
|
||||
tcp_server_t* ts;
|
||||
mio_dnsc_t dnsc = MIO_NULL;
|
||||
|
||||
mio = mio_open(&mmgr, 0, MIO_NULL, 512, MIO_NULL);
|
||||
if (!mio)
|
||||
{
|
||||
printf ("Cannot open mio\n");
|
||||
goto oops;
|
||||
}
|
||||
|
||||
memset (&tcp_make, 0, MIO_SIZEOF(tcp_make));
|
||||
tcp_make.type = MIO_DEV_SCK_TCP4;
|
||||
tcp_make.on_write = tcp_sck_on_write;
|
||||
tcp_make.on_read = tcp_sck_on_read;
|
||||
tcp_make.on_connect = tcp_sck_on_connect;
|
||||
tcp_make.on_disconnect = tcp_sck_on_disconnect;
|
||||
tcpsvr = mio_dev_sck_make(mio, MIO_SIZEOF(tcp_server_t), &tcp_make);
|
||||
if (!tcpsvr)
|
||||
{
|
||||
printf ("Cannot make a tcp server\n");
|
||||
goto oops;
|
||||
}
|
||||
|
||||
ts = (tcp_server_t*)(tcpsvr + 1);
|
||||
ts->tally = 0;
|
||||
|
||||
memset (&tcp_conn, 0, MIO_SIZEOF(tcp_conn));
|
||||
{
|
||||
in_addr_t ia = inet_addr("127.0.0.1");
|
||||
mio_sckaddr_initforip4 (&tcp_conn.remoteaddr, 9999, (mio_ip4addr_t*)&ia);
|
||||
}
|
||||
MIO_INIT_NTIME (&tcp_conn.connect_tmout, 5, 0);
|
||||
tcp_conn.options = 0;
|
||||
if (mio_dev_sck_connect(tcpsvr, &tcp_conn) <= -1)
|
||||
{
|
||||
}
|
||||
|
||||
#if 0
|
||||
while (1)
|
||||
{
|
||||
mio_exec (mio);
|
||||
}
|
||||
#endif
|
||||
mio_loop (mio);
|
||||
|
||||
oops:
|
||||
if (mio) mio_close (mio);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user