Commit Graph

688 Commits

Author SHA1 Message Date
Carsten Haitzler 1c74aaa7e9 Revert "cxx: Fix manual code after efl_app change."
This reverts commit 135154303b.

Revert "efl: move signal events from efl.loop to efl.app"
This reverts commit 3dbca39f98.

Revert "efl: add test suite for efl_app"
This reverts commit 3e94be5d73.

Revert "efl: create Efl.App class, the parent of Efl.Loop"
This reverts commit 28fe00b94e.

Go back to before efl.app because I think this should be done with
superclassing here not a parent object. reasons?

1. multiple loops per single thread make no sense. so if multilpe loop
objects they wont be contained in a single app object and then deleted
like this.
2. the app object is not really sharable in this design so it cant be
accessed from other threads
3. it makes it harder to get the main loop or app object (well 2 func
calls one calling the other and more typing. it is longer to type and
more work where it is not necessary, and again it can't work from
other threads unless we go duplicating efl.app per thread and then
what is the point of splittyign out the signal events from efl.loop
then?)

etc.
2018-03-03 13:40:33 +09:00
Mike Blumenkrantz 28fe00b94e efl: create Efl.App class, the parent of Efl.Loop 2018-02-26 14:02:51 -05:00
Marcel Hollerbach 17d8781a2a ecore: use new bs static lib 2018-02-17 21:17:58 +01:00
Mike Blumenkrantz ac909ac04c efl-net: rename conflicting "name" properties 2018-02-15 13:11:00 -05:00
Cedric BAIL 7db7d84fa2 ecore_con: missed compiler warning. 2018-01-25 09:54:36 -08:00
Cedric BAIL fb3e49d66d ecore_con: restore ability for negative port on local connection.
Thanks make check.
2018-01-25 09:40:20 -08:00
Carsten Haitzler 3f8c282544 ecore-con pass port into err print 2018-01-26 01:53:58 +09:00
Carsten Haitzler eb951e99a6 ecore_con - give error output if port num is invalid 2018-01-26 01:04:12 +09:00
Myoungwoon Roy, Kim 1837253935 ecore_con: Check for the valid port number
Summary:
This patch checks whether the port number is valid or not.
The valid port number is an unsigned 16-bit integer, so 1-65535.
0 is reserved already.

Test Plan: Execute test suite

Reviewers: cedric, raster, stefan, Jaehyun_Cho

Reviewed By: raster

Subscribers: jpeg

Differential Revision: https://phab.enlightenment.org/D5761
2018-01-25 13:23:25 +09:00
Vincent Torri f5b01ac5ce all: Simplify definition of EAPI
This will help in the transition from Autotools to Meson. This has been
tested on Windows for which EFL_XXX_BUILD were first introduced.
2018-01-18 18:04:03 +09:00
Cedric BAIL 0f7c5582a4 ecore_con: we should just stop using ecore_main_loop_get. 2018-01-03 12:49:10 -08:00
Carsten Haitzler 9bedda14b3 efl loop - rename ecore_main_loop_get to efl_main_loop_get
ecore_main_loop_get() is really a new "eo api" but it's using our old
ecore_* namespace, so move to the new efl namespace.
2018-01-02 16:13:54 +09:00
Andy Williams d234458dfc Fix and simpligy windows behaviour.
Author: Vincent Torri
2017-12-31 16:08:31 +00:00
Andy Williams b9401d7e0a docs: Update ecore_con eo files for grammar and readability
Author: Nate Drake
2017-12-20 17:30:29 +00:00
Carsten Haitzler b22b2ded1d ecore_con: bug workaround SO_REUSEADDR and EADDRINUSE from bind (fix)
what i'm seeing is this with local unix sockets:

1. server process not cleanly shut down (kill -9 for example).
2. run server process again and bind fails due to EADDRINUSE
3. we ARE doing setsockopt() with SO_REUSEADDR set to 1 ...

this just makes no sense because setsockopt() SHOULD allow use to
re-use... the previous efreetd process for example is gone. no such
process, yet socket is not re-usable. this should just not happen due
to SO_REUSEADDR, but it does. this has nasty consequences like efreetd
maybe never running because of stale sockets. this should never have
happened, but it does. odd. so a hacky workaround:

1. try bind.
2. if bind fails with EADDRINUSE and its a socket path AND
pd->unlink_before_bind is NOT set... then try a connect to the socket.
3. if connect succeeds then fail as normal (close socket and error on
bind'ing)
   if connect fails then we have a stale socket, so unlink it
forcibly. create the socket again and try bind again.

hacky but... fixes the core issue.

@fix
2017-12-20 21:10:53 +09:00
Jean-Philippe Andre fce444bb18 ecore_con: Make sure the proxy helper is valid
If the http proxy helper gets deleted at shutdown rather than because
the process actually exited, the object pointer becomes invalid. This
patch tries to avoid a situation where the object is not valid.
2017-12-18 19:54:31 +09:00
Jean-Philippe Andre c0c5e72408 ecore_con: Properly shutdown and unregister log domain
I believe the comment saying we should not unregister the log domain is
invalid as we try to flush the pending ecore events.
2017-12-18 19:54:31 +09:00
Jean-Philippe Andre 81bad9f47c ecore_con: Always get the loop on init
In case of init/shutdown/init cycles, the loop EO ID has changed, so it
must be fetched again.
2017-12-18 19:54:31 +09:00
Jean-Philippe Andre a90746378d ecore_con: Avoid safety errors when closing http
When setting EOS on the dialoer, it's possible that it will also get
automatically closed (by a callback). This results in safety check error
messages, while everything is fine (at least I believe it is).
2017-12-18 19:54:31 +09:00
Cedric Bail affd07a11f ecore_con: move Efl.Net.Control.Access_Point to use Eina_Future. 2017-12-14 16:42:44 -08:00
Cedric BAIL df032058fd ecore: rename Efl.Loop_User to Efl.Loop.Consumer. 2017-12-13 14:54:57 -08:00
Ross Vandegrift 71e5c74eb6 efl: drop deprecated Encoding key from desktop files
Summary:
The Encoding key is no longer required, all desktop files are assumed to
be UTF-8 encoded.  See details at:
https://standards.freedesktop.org/desktop-entry-spec/1.1/apc.html

Fix various typos and misspellings

lintian, Debian's package checker, uses strings to check for common typos
in compiled binaries.  This change fixes the ones it identified in 1.20.6.

Reviewers: cedric

Reviewed By: cedric

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D5584

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-12-13 10:27:48 -08:00
Cedric BAIL ac63a74d1d ecore_con: implement FIXME for Efl.Net.Control.Technology by returning EINA_VALUE_EMPTY. 2017-12-11 15:08:48 -08:00
Cedric BAIL a8197a8c40 ecore_con: use Eina_Future for Efl.Net.Control.Technology. 2017-12-11 15:03:11 -08:00
Cedric BAIL d614894d04 ecore: rename efl_loop_Eina_FutureXXX_job to efl_loop_job. 2017-12-11 14:04:09 -08:00
Vincent Torri 771bb6e6a7 Evil: use static buffer to store error messages
Reviewers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D5394
2017-12-11 16:04:02 +09:00
Cedric Bail 25747d0881 ecore: rename efl_loop_Eina_FutureXXX_timeout to efl_loop_timeout. 2017-12-03 16:30:53 -08:00
Carsten Haitzler 047141fc90 ecore ipc/con: fix nasty ... they dont mutually exclude
by deleting the socket they wont mutually exclude at bind which means
eny new server just nides the pror one and you can get lots of copies
of the same server. this wasnt the case before. it shouldnt have been.
i think ther was an rm path for stale sockets when connecting failed
or something. anyway... this here was causing multilpe efreetd's and
all sorts of nastiness. this is the root cause. so... fix it.

@fix
2017-11-26 14:01:14 +09:00
Pawel Aksiutowicz 03152b8958 ecore_con: quiet 2 "clobbered" warnings in ecore_con
Reviewers: stanluk, lukasz.stanislawski

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D5514

Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
2017-11-23 15:38:52 -08:00
Cedric Bail fee2b1beb4 ecore_con: add support for EFL_MAIN with ecore_con support. 2017-11-09 15:25:51 -08:00
Andy Williams d5dbcdabd1 eo: Rename efl_ref_get to efl_ref_count 2017-11-08 09:30:42 +00:00
Carsten Haitzler ede0587887 efl net - handle proxy helper fails better and abort proxy lookups
if proxy fails are too many then give up on queued lookups as they
likely will continue. i noticed a process continually spawning efl net
proxy helper because one queued lookup failed and could be looked up
so it kept trying again and again.

@fix
2017-11-07 22:42:49 +09:00
Daniel Kolesa 4f5b72a3ed eo files: convert various to use @cref 2017-11-02 16:41:01 +01:00
Daniel Kolesa cf63573e73 eolian: only allow reference (ownable) types in containers 2017-11-02 13:51:02 +01:00
Cedric Bail 6d8ceab4be ecore_con: add an Efl_Net.h 2017-10-27 18:51:38 -07:00
Taehyub Kim 5360034675 ecore: remove doxygen warning messages
Summary:
remove doxygen warning messages
@fix

Reviewers: jpeg, cedric, woohyun

Reviewed By: jpeg

Differential Revision: https://phab.enlightenment.org/D5339
2017-10-18 19:24:28 +09:00
Prince Kumar Dubey 41197981ab efl: unsigned int/long never be less than zero. Fixed.
Reviewers: raster, cedric

Subscribers: rajeshps, jpeg

Differential Revision: https://phab.enlightenment.org/D5300

Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
2017-10-13 12:07:28 -07:00
Chris Michael ae49b6b6df ecore-con: Mark unused function paramater as unused
Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-10-02 08:12:06 -04:00
Vincent Torri 10ba064b65 Windows: remove XP support and forbid compilation and run on this platform
Test Plan: run on XP

Reviewers: jpeg, cedric, ajwillia.ms

Reviewed By: ajwillia.ms

Subscribers: ajwillia.ms

Differential Revision: https://phab.enlightenment.org/D5245
2017-10-01 18:09:46 +01:00
Cedric BAIL 871b6ac0ad ecore_con: simplify Efl.Net.Server.Ssl by inheriting from Efl.Net.Server.Tcp. 2017-09-29 16:01:02 -07:00
Cedric BAIL b7049e8c43 ecore_con: add an intermediate Efl.Net.Server.Ip 2017-09-29 14:12:03 -07:00
Daniel Kolesa f36e5bd543 eolian: add mstring
This is a new type representing a mutable string (no const).
Regular strings cannot be made mutable with @owned because
they might be hidden behind typedefs.
2017-09-22 17:10:42 +02:00
Vincent Torri 0cdd501246 EFL For WIN32: Replace HAVE_EVIL define with _WIN32 2017-09-22 05:06:10 -05:00
Carsten Haitzler aec79f9d0d efl net http - fix protocol error handling to not crash and handle it
if http server doesnt send even a valid http response and just closes
your conenction... dont segv with null pd->cm

@fix
2017-09-17 18:18:12 +09:00
Daniel Kolesa 8f6ba61011 ecore: convert existing eo files to new ownership 2017-09-15 16:51:37 +02:00
Carsten Haitzler f179d32157 efl net - adapt to openssl 1.1.0 changes with tls method support
support the tls methods if on openssl 1.1.0 so we don't get
"unsupported cipher" as it does support it just with a new api.

@fix
2017-09-15 16:12:59 +09:00
Guilherme Iscaro ec27ceac27 efl_net: Use the new Eina_Future API. 2017-09-04 10:24:00 -03:00
Daniel Kolesa 436815ca00 ecore, ecore_con: fix const on Eina.Slice
Fixes TODOs from dd5cdda64b
after fixing T5024.
2017-08-10 12:53:14 +02:00
Carsten Haitzler ff26991220 efl net - fix ipv6 getsockname to use the proper struct to do it
struct sockaddr_storage *addr;

AS the actual storage ( a ptr to store the whole data). kind of...
wrong. it should be:

      struct sockaddr_storage addr;

see examples of this kind of usage of getsockname:

http://www.masterraghu.com/subjects/np/introduction/unix_network_programming_v1.3/ch04lev1sec10.html

found by PVS studio

@fix
2017-07-29 10:56:47 +09:00
Carsten Haitzler 16abe895c6 efl net ssl constructor - remove double set of same var
all struct vars are set... one 2x. not a bug but pointless code in the
src

found by PVS studio
2017-07-29 09:08:40 +09:00
Guilherme Iscaro ef03ecd89c Ecore_Con: Fix wrong comparison.
Otherwise it will always evaluate to false.
2017-07-28 15:22:51 -03:00
Guilherme Iscaro 493f75587d Ecore_Conn: Set EOS only if the connection is not closed.#algo.
This check prevents that EOS is set on a closed connection.

Fixes T5180
2017-07-28 15:22:51 -03:00
Guilherme Iscaro 0a51ac2997 Ecore_Con: Fix CLOEXEC documentation.
The socket attributes are inherited by the child.
2017-07-28 15:22:51 -03:00
Guilherme Iscaro 45a767632d Ecore_Conn: Enable CLOEXEC by default.
This flag should be enabled by default in order to avoid socket leaks.
2017-07-27 16:54:34 +02:00
Carsten Haitzler fd9e6b305d efl net server udp - report erro on alloc failure
unwind nicely and complain
2017-07-24 17:44:22 +09:00
Carsten Haitzler 143709faba ecore con proxy helper - complain when realloc fails
so you know why things might be failing... complain about out of
memory errors.
2017-07-24 17:35:13 +09:00
Myoungwoon Roy, Kim 802b547310 docs: Fix typos and some wrong expressions in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.
Summary: I had fixed some typos and wrong expressions, such as capital letters, $simbols in .eo and singulars in Ecore, Ecore_Audio, Ecore_Cocoa, Ecore_Con, and Ector API reference doxygen.

Test Plan: Doxygen Revision

Reviewers: Jaehyun_Cho, stefan, jpeg, cedric, raster

Reviewed By: Jaehyun_Cho

Differential Revision: https://phab.enlightenment.org/D4943
2017-06-07 13:01:13 +09:00
Gustavo Sverzut Barbieri 6dd3594735 efl.net: rename Ip.Address to Ip_Address.
It's unlikely that we'll have other stuff under Ip namespace, also not
that likely to have other than Ip Addresses (to invert it to
Address.Ip), thus make a toplevel entry Ip_Address as suggested by
DaveMDS.
2017-04-25 11:18:00 -03:00
Chris Michael 0652fbe91c ecore-con: Remove unused variable
Gcc complains that 'flags' here may be used uninitialized. In looking
at the code, 'flags' does not seem to be needed in the debug prints
here. If we keep and initialize the variable to 0 during declaration,
it would only ever print out 0 anyway as 'flags' is never changed in the
code.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-19 10:57:43 -04:00
Cedric BAIL 662f7d3310 ecore_con: use new API eina_file_close_on_exec. 2017-04-18 16:56:01 -07:00
Bryce Harrington 6ea18851ba ecore_con: send server_upgrade event *after* clearing pending saves
Summary:
The _ecore_con_post_event_server_upgrade() call adds an event to free
the server_upgrade object, svr, via  _ecore_con_server_free(svr) so we
should assume srv is freed after it returns.  Thus, perform the
pending_slice processing prior to calling it.  Otherwise it triggers an
illegal access (USE_AFTER_FREE) error in Coverity.

@fix CID1373485

Reviewers: barbieri

Reviewed By: barbieri

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D4785

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-04-12 14:39:08 -07:00
Gustavo Sverzut Barbieri e8a59ab6c2 efl_net_socket_ssl (dialer): emit "resolved"
for dialers we should also monitor "resolved" from inner TCP socket
and emit that ourselves, letting people know that we have an IP
address.

this is important for ecore_con_legacy.c, since the svr->ip is only
decoded and stored once when this signal is emitted.
2017-04-08 19:21:44 -03:00
Gustavo Sverzut Barbieri c90865ca48 ecore_con_legacy: fix legacy compatibility for ecore_con_server_send()
Since efl_net_ssl_context is immutable for a dialer and we create the
dialer with the context, the SSL cases uses a trick to postpone dialer
creation using a job, then it allows one main loop iteration for the
user to call various ecore_con_server_ssl_*() methods.

However this breaks immediate ecore_con_server_send() after
ecore_con_server_connect() as used to be allowed and used by
azy/erssd.

Most people wouldn't notice that, since the most common case is to
either use ecore_con_url (which uses cURL and a complete different
code path) OR they would wait for ECORE_CON_EVENT_SERVER_ADD prior to
sending data.

Nonetheless it was a compatibility issue and must be fixed.

Fixes T5339
2017-04-08 19:21:44 -03:00
Gustavo Sverzut Barbieri 9486225744 ecore_con: remove warnings if FD_CLOEXEC is undefined.
currently it's being defined in evil_fcntl.h, but the actual
implementation of fcntl() in evil_fcntl.c is causing problems with
sockets. So one possibility is to remove the ifdef, another is to
change the implementation.
2017-03-29 12:44:19 -03:00
Gustavo Sverzut Barbieri a4be1e479c ecore_con_local_path_new(): implemented for Windows 2017-03-29 12:44:19 -03:00
Gustavo Sverzut Barbieri fa0e2865a1 implement efl_net_{socket,dialer,server}_windows
This is the local socket for windows, analogous to AF_UNIX.

`Efl_Net_Socket_Windows` is the base class doing `ReadFile()` and
`WriteFile()` using overlapped I/O, as well as the close procedure
(`FlushFileBuffers()`, `DisconnectNamedPipe()` and
`CloseHandle()`). These are done on top of an existing HANDLE that is
set by `Efl_Net_Dialer_Windows` (from `CreateFile()`) or
`Efl_Net_Server_Windows` (from `CreateNamedPipe()`).

The overlapped I/O will return immediately, either with operation
completed or `ERROR_IO_PENDING`, which means the kernel will execute
that asynchronously and will later `SetEvent(overlapped.hEvent)` which
is an event we wait on our main loop. That `overlapped` handle must
exist during the call lifetime, thus cannot be bound to `pd`, as we
may call `CancelIo()` but there is no guarantee the memory won't be
touched, in that case we keep the overlapped around, but without an
associated object.

Windows provides no notification "can read without blocking" or
non-blocking calls that returns partial data. The way to go is to use
these overlapped I/O, with an initial `ReadFile()` to an internal
buffer, once that operation finishes, we callback the user to says
there is something to read (`efl_io_reader_can_read_set()`) and wait
until `efl_io_reader_read()` is called to consume the available data,
then `ReadFile()` is called again to read more data to the same
internal buffer.

Likewise, there is no "can write without blocking" or non-blocking
calls that sends only partial data. The way to go is to get user bytes
in `efl_io_writer_write()` and copy them in an internal buffer, then
call `WriteFile()` on that and inform the user nothing else can be
written until that operation completes
(`efl_io_writer_can_write_set()`).

This is cumbersome since we say we "sent" stuff when we actually
didn't, it's still in our internal buffer (`pd->send.bytes`), but
nonetheless the kernel and the other peer may be adding even more
buffers, in this case we need to do a best effort to get it
delivery. A particular case is troublesome: `write() -> close()`, this
may result in `WriteFile()` pending, in this case we wait using
`GetOverlappedResult()`, *this is nasty and may block*, but it's the
only way I see to cope with such common use case.

Other operations, like ongoing `ReadFile()` or `ConnectNamedPipe()`
will be canceled using `CancelIo()`.

Q: Why no I/O Completion Port (IOCP) was used? Why no
   CreateThreadpoolIo()? These perform much better!

A: These will call back from secondary threads, but in EFL we must
   report back to the user in order to process incoming data or get
   more data to send. That is, we serialize everything to the main
   thread, making it impossible to use the benefits of IOCP and
   similar such as CreateThreadpoolIo(). Since we'd need to wakeup the
   main thread anyways, using `OVERLAPPED.hEvent` with
   `ecore_main_win32_handler_add()` does the job as we expect.

Thanks to Vincent Torri (vtorri) for his help getting this code done
with an example on how to do the NamedPipe handling on Windows.
2017-03-29 12:44:19 -03:00
Vincent Torri 02b6ee3ed8 Ecore_Con: Fix compilation on Solaris
FIONREAD is defined in sys/filio.h
2017-03-26 23:50:02 +09:00
Cedric BAIL deb6f0d2cd ecore_con: avoid potential crash during shutdown due to Ecore_Event queue. 2017-03-09 16:17:58 -08:00
Myoungwoon Roy, Kim 62455a8d41 docs: Fix typos and some wrong expressions in Ecore and Edje API reference doxygen.
Summary: I had fixed some typos and wrong expressions, euch as capital letters, singular Etc. in Ecore and Edje API reference doxygen.

Test Plan: Doxygen Revision

Reviewers: stefan, cedric, raster, Jaehyun_Cho, jpeg

Subscribers: conr2d

Differential Revision: https://phab.enlightenment.org/D4677
2017-02-27 19:48:38 +09:00
Myoungwoon Roy, Kim 01931c4676 doxygen: Fix typos & invalid statements in ecore
This covers ecore audio, avahi, buffer and con.

Summary: There are some typos and cacologigue statements in
doxygen of ecore_audio, ecore_avahi, ecore_buffer, and ecore_con.

Test Plan: API Doxygen Revision

Reviewers: stefan, cedric, raster, Jaehyun_Cho

Subscribers: jpeg, conr2d

Differential Revision: https://phab.enlightenment.org/D4652
2017-02-13 19:54:29 +09:00
Carsten Haitzler c6ff925132 ecore_con - only use XDG_RUNTIME_DIR if not setuid
this should address possible misuse of this env var in setuid apps.
keep using home and tmp to maintain socket "abi" (the filenames that
are used).
2017-02-08 21:19:39 +09:00
Carsten Haitzler 434d354a51 ecore_con proxy helper - fix null return handling for thread q wait
this fixes CID 1368376
2017-02-08 11:33:42 +09:00
Gustavo Sverzut Barbieri 8dc853f230 ifdef RUN_IN_TREE logic.
This logic is only needed for autotools, cmake will replicate the
installation file structure and thus eina_prefix works out of box.
2017-02-03 12:36:38 -02:00
Carsten Haitzler eab798c753 ecore_con/efl_net - dedicated threads for network i/o not from the pool
so ecore_con/efl_net were using the standard ecore_thread thread pool
for doing things like dns lookups (that can take multiple minutes
until timeouts) and actual http transactions. similarly they can block
thread workers for long periods or indefinitely thus basically
blocking the whole eocre_thread pool and stopping others from sharing
it. the best solution we have right now is to bypass the thread pool
queue and have dedicated threads for these actions. what we should
have is a dedicated thread pool with each thread taking on N
connections (via select etc.) and the ability to create and destroy
thread pools for specific tasks so you can separate the work out from
other work.  but that is basically a redesign of our thread pool infra
so let's do the quick solution here until that day comes.

this partially addresses D4640

a dedicated thread per image load though is going to be a lot nastier...
2017-02-03 14:57:49 +09:00
Gustavo Sverzut Barbieri 0293c360eb efl_net_dialer_http: check for finished handles after unpause.
After we call curl_multi_socket_action() we must call
_efl_net_dialer_http_curlm_check() in order to call
curl_multi_info_read() and be notified of handles that were
finished. Otherwise the handle is gone and we'll be waiting for an
action that will never happen.

Fixes T5079
2017-02-01 16:26:38 -02:00
Gustavo Sverzut Barbieri f6cac7ed9a cmake: add ecore_con. 2017-01-27 17:26:05 -02:00
Gustavo Sverzut Barbieri 281ca807fe ecore_con: add missing string nul byte terminator to efl_net_ip_address. 2017-01-27 17:26:05 -02:00
Daniel Kolesa cb3f8304e0 eolian: change eo file syntax @virtual_pure -> @pure_virtual 2017-01-13 15:44:09 +01:00
Daniel Kolesa 85fbc333dd eolian: enforce specification of both get and set in prop impls
Now you can't use the same syntax as you would for a method to
implement a property as whole, instead you need to specify the
getter and/or setter explicitly. This is to allow parent classes
to expand their properties without altering behavior of the child
classes.
2017-01-11 16:38:41 +01:00
Carsten Haitzler bd2f189d4c ecore_con - move libproxy to a slave binary with stdin/out msging
so here's the ugly problem. libproxy. yes. we've discussed memory
usage (e.g. it may have to execute javascript and pull in lots of deps
etc.) but we dlopene'd on the fly. ok... but this didn't solve another
issue i hit:

libproxy was causing enlightenment to abort(). some internal bit of
libproxy was raising a c++ exception. this wasn't caught. this causes
an abort(). takes down your entire desktop. FANTASTIC. this is bad. i
wouldnt' expect a library we depend on to be THIS anti-social but
libproxy seemingly is. it SHOULd catch its error sand just propagate
back to us so we can handle gracefully.

there reall is no way around this - isolate libproxy. it's even worse
that libproxy can load arbitrary modules that come from anywhere sho
who knows what issues this can cause. isolation is the best solution i
can think of.

so this makes an elf+net_proxy_helper we spawn the first time we need
a proxy lookup. we re-use that binary again and again until it exits
(it should exit after 10 seconds of being idle with no requests coming
in/pending). it'll respawn again later if needed. this involves now
the efl net threads having to marshall back to mainloop to do the
spawn and to write to the proxy process (reading is done by async exe
data events and the data is passed down a thread queue to the waitng
efl net thread). if the exe dies with pending requests unanswered then
it's respawned again and the req's are re-sent to it... just in case.
it has a limit on how often it'll respawn quickly.

this seems to work in my limited testing. this ALSO now isolates
memory usage of libproxy to another slave process AND this process
will die taking its memory with it once it's been idle for long
enough. that;s also another good solution to keeping libproxy impact
at bay.
2017-01-09 15:29:33 +09:00
Carsten Haitzler 2842165415 openssl 1.1 build break fixes
this fixes building against openssl 1.1 since it broke api in various
ways by hiding structs and deprecating api's (this causes warnings not
breaks unlike the struct hiding). this adapts to these changes and
makes efl build again.

@fix
2017-01-04 17:47:38 +09:00
Daniel Kolesa 5a5707e054 ecore con: use new property impl syntax 2016-12-27 16:58:07 +01:00
Daniel Zaoui f8d7602f46 Ecore_Con_Url/Curl: add consistency for _c init/shutdown
_c_init was not called from Ecore_Con_Url although _c_shutdown was.
2016-12-23 23:03:24 +02:00
Daniel Zaoui 3235c83c36 Ecore_Con_Url/Curl: add referencing on _c structure
The _c structure used to store the Curl function pointers needs
referencing to be sure it is not freed although still needed.
The non-referencing was leading to a crash during the destruction
of the dialers. The _c was still used although it has been freed
by ecore_con_url_shutdown.
2016-12-23 23:02:45 +02:00
Gustavo Sverzut Barbieri b00ea12e8b ecore_con_legacy: fix compatibility behavior (eos-mark on receiver done).
While a socket can be closed to receive data resulting in EOS, it
could still be used to send stuff. Then it won't result in "finished",
just "read,finished" event.

However, previously this was considered a disconnect and we must
respect this otherwise tests (Ecore_Con_Eet suite) will hang waiting
for a disconnect.
2016-12-20 10:18:33 -02:00
Gustavo Sverzut Barbieri 08c38713ce do not emit events from efl_io_closer_close() on destructor.
On destructor we're not supposed to emit events, I even thought that
would be implicit, but it's not. If we do, for example an event
handler that would 'efl_del()' on "EFL_IO_CLOSER_EVENT_CLOSED" would
trigger too-many unrefs.
2016-12-20 10:18:32 -02:00
Gustavo Sverzut Barbieri 963e3a793d efl_io_reader/writer: always set 'can_*' to FALSE on errors.
If user tries to read or write and that fails then set 'can_read' or
'can_write' to false, regardless of the error code.
2016-12-20 10:18:32 -02:00
Gustavo Sverzut Barbieri 42923bc29e efl_net_server_udp_client: make error easier to understand.
UDP client has no socket on its own, so it can't be marked as
close-on-exec, however failing to resolve the method is bad as
confuses the user.

Instead provide a method that checks if the setting is different from
parent, in such case provide a meaningful message. Otherwise just be
quiet.
2016-12-19 17:19:45 -02:00
Gustavo Sverzut Barbieri a995529a46 efl_net_socket_udp: expose init() as protected method.
remove one more TODO: since Efl.Net.Ip.Address was introduced we can
now expose Efl.Net.Socket.Udp.init as a protected method that will
configure the internal address we use for the remote peer. This allow
subclasses to override or call such methods.
2016-12-19 17:11:46 -02:00
Gustavo Sverzut Barbieri db1e2b994e efl_net_socket_ssl: remove TODO leftover.
There are no jobs to stop there, it was a left over since this code
was somehow derived from Efl.Loop_Fd where "read" and "write" would
constantly be called until the kernel flag was cleared, there the
callback must be removed to stop jobs, not here.
2016-12-19 16:52:29 -02:00
Gustavo Sverzut Barbieri dd5cdda64b more eo simplified to use Eina_Slice instead of pointer to.
Working directly with Eina_Slice is easier than a pointer to it,
requires no validation of the pointers and is cheap since it's just
putting together size_t + void*.

However we can't hint the user of 'const(Eina.Slice)' properties as
Eolian is incorrectly generating getters as:

   const Eina_Slice class_property_get(...)

which is makes compilers complain about ignored qualifiers:

   ../src/lib/ecore/efl_io_copier.eo.h:329:7: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]

Leave some TODO so @q66 can fix those.
2016-12-19 15:30:56 -02:00
Gustavo Sverzut Barbieri 25a9e1d886 Efl.Io.{Queue,Buffer,Buffered_Stream}: slice_get is now a property.
Previously we couldn't return a slice, instead required the user to
pass a slice and we'd fill it since Eolian couldn't generate fallbacks
for structures.

Since @q66 fixed eolian, we can now return the structure itself as
initially wanted, ditching some TODO from the code.
2016-12-19 15:30:56 -02:00
Gustavo Sverzut Barbieri a7657e821f ecore_con/ecore_ipc: flush should wait for connection.
Some applications will create the handle, immediately send data, flush
and delete it, expecting the data to be sent to remote peer.

This is a bad behavior as the application would become unresponsive
until the connection is established, data can be written (since
depends on server consuming it), then allow it to be closed.

A proper behavior here would be to chain based on events, with the
usage of a copier would be simply wait for "done" event.

However the legacy API allowed this and terminology depends on this
awkward "feature", thus be bug-compatible.

This fixes T5015.
2016-12-19 13:03:33 -02:00
Gustavo Sverzut Barbieri b4c80b50bc efl_net_socket_fd: initialize fds to INVALID_SOCKET
Since 0 is a valid fd, then we'd try to do socket operations on it,
which would generate misleading errors.
2016-12-19 13:03:33 -02:00
Gustavo Sverzut Barbieri ae054e6c0b ecore_con/ecore_ipc legacy: fail early for local sockets.
In the old/legacy API the socket would be opened early in non-blocking
mode (connect returned errno==EINPROGRESS), with UNIX socket being
path-validated early and returning NULL as 'server' handle.

Some applications relied on this instead of monitoring the "ERROR"
events, considering the connection to be successful if there was a
handle -- this was the case with Terminology after it moved from DBus
to Ecore_Ipc.

Although this is not correct, we must keep compatibility and thus we
stat() in compatibility layer, failing early as the old API would do.
2016-12-19 13:03:33 -02:00
Gustavo Sverzut Barbieri 482437ee14 ecore_con/ecore_ipc: keep log domain alive after shutdown.
These legacy API had the nasty behavior of keeping handles alive until
the pending events were dispatched, this could happen after the module
itself was shutdown, resulting in log to unregistered domains.

Then do not unregister the domain -- eina_shutdown will avoid leaks
anyway.
2016-12-19 13:03:33 -02:00
Gustavo Sverzut Barbieri 7de5146a3b efl_net: fix CID 1367489 due copy & paste.
we're looking at "x" since it's the return of getaddrinfo(), not "r"
which is used for something else.
2016-12-19 10:37:21 -02:00
Cedric BAIL 32da71d65d ecore_con: reduce amount of warning related to clobbered variable. 2016-12-15 10:31:56 -08:00
Gustavo Sverzut Barbieri c1b20aa1fb ecore_con_legacy: fix coverity issues (use after free)
for hard failures (highly unlikely), the handle would be deleted and
the next use would crash.

guard against those or reorder when it makes sense.
2016-12-12 13:17:40 -02:00
Gustavo Sverzut Barbieri 4f44287a59 efl_net_ip_address: make coverity happy.
host and port were already checked, but let's quiet CID 1366921
2016-12-12 13:02:55 -02:00
Gustavo Sverzut Barbieri 4812d9eb74 add missing includes for BSD.
Thanks @netstar.
2016-12-12 12:17:11 -02:00
Gustavo Sverzut Barbieri 7e648c46df efl_net_ip_address: improve docs.
thanks stefan for reminding me of these :-)
2016-12-12 09:57:36 -02:00
Stefan Schmidt fcd131e122 docs: ecore_con: fill gaps in newly added efl_net_ip_address documentation 2016-12-12 09:34:33 +01:00
Stefan Schmidt cd477e0217 docs: ecore_con: document newly added extern struct item 2016-12-12 09:34:33 +01:00
Gustavo Sverzut Barbieri 0073e87761 efl_net_dialer_http: fix HEAD requests.
We do not need to keep a "only_head" flag, but we must set
CURLOPT_NOBODY instead of going the "CUSTOMREQUEST" route, otherwise
curl won't follow redirects, etc.
2016-12-12 03:17:35 -02:00
Gustavo Sverzut Barbieri d52daf8dd7 efl_net_dialer_http: fix reference check.
With the last patch to fix delete-from-curl callback it went too much,
considering it was always dead (in the test scenario it was, so it was
"right"), but broke normal cases.
2016-12-12 03:16:07 -02:00
Gustavo Sverzut Barbieri 633ec445b8 efl_net: add Efl.Net.Ip_Address
This is a string parser, serializer and asynchronous resolver.

It's purpose is to convert to and from the strings we use in our
dialers and servers, such as "127.0.0.1:1234" or "[::1]:1234",
properties allow to check the family, port, address bytes (slice) and
even get a struct sockaddr pointer to use with bind()/connect() in
outside code.

It will also offer some utilities present in netinet/in.h in an easy
to use way, after all IN6_IS_ADDR_LOOPBACK() works one way, while
there is no IN_LOOPBACK and comparing with INADDR_LOOPBACK will lead
to errors since it's in network order.

Last but not least, it will do asynchronous resolve of host and port
names using an internal thread and getaddrinfo(). The results are
delivered using a Future with an array of objects.
2016-12-12 02:30:33 -02:00
Gustavo Sverzut Barbieri 96eccc2753 efl_net: move error COULDNT_RESOLVE_HOST to broader scope.
This error is shared by Dialer and Server, will also be used by IP
resolution.
2016-12-12 02:30:33 -02:00
Gustavo Sverzut Barbieri 21759f713a yoda-style inactivity timeout.
s/inactivity_timeout/timeout_inactivity/g so it matches the EFL names
with scope first, like timeout_connect, etc.
2016-12-12 02:30:33 -02:00
Gustavo Sverzut Barbieri e9a72ea8f4 efl_net: spell check s/revogation/revocation/g
Sorry, in pt_BR it's revoGar... so I did misspell :-)
2016-12-12 02:30:33 -02:00
Gustavo Sverzut Barbieri f4306d654d ecore_con: Ecore_Con_Server now on top of Efl_Net!
This is a major work and unfortunately couldn't be split into smaller
pieces as old code was highly coupled.

Ecore_Con_Server is now a wrapper around Efl_Net_Dialer_Simple
(ecore_con_server_connect()) and Efl_Net_Server_Simple
(ecore_con_server_add()), doing all that the original version did with
some fixes so ecore_con_ssl_server_upgrade() and
ecore_con_ssl_client_upgrade() are more usable -- see the examples and
-t/--type=tcp+ssl.

I tried to be bug-compatible, with code annotations where things
doesn't make sense. This was based on ecore_con_suite tests and some
manual experimenting with the examples, these can be helpful if you
find regressions (report/assign to me).
2016-12-10 08:44:06 -02:00
Gustavo Sverzut Barbieri c5fc33d378 ecore_con_url: only close the request if we got a final response.
if we're doing 30x redirects or anything else, keep going. If it's an
error it will be reported later, otherwise EOS. Fact is we're only
interested if 20x.
2016-12-09 22:18:27 -02:00
Gustavo Sverzut Barbieri 2945b972ef efl_net_dialer_http: fix delete-from-CURL callback.
This was annoying to identify as the sequence is kinda difficult to
get, but Terminology was doing a HEAD request and it was triggering
this case in particular.

Fixes T4975.
2016-12-09 22:18:18 -02:00
Gustavo Sverzut Barbieri fb0e716c1a efl_net: fix formatting warnings from windows. 2016-12-09 19:33:40 -02:00
Gustavo Sverzut Barbieri 345bba3ef1 efl_net_dialer_http: fix build on windows.
Windows time_t is not a long, but long-long, then stick with int64_t
so it works everywhere (converts to time_t internally).

And there is no gmtime_r(), then use the gmtime() if not detected.
2016-12-09 19:32:14 -02:00
Gustavo Sverzut Barbieri 324b4e93f5 efl_net_server_unix: do not mkpath for abstract sockets. 2016-12-09 13:47:04 -02:00
Gustavo Sverzut Barbieri 5939f0d9c2 efl_net_dialer: emit 'resolved' even if connection failed.
If we resolved the address but couldn't connect, use
efl_net_socket_address_remote_set() and emit
EFL_NET_DIALER_EVENT_RESOLVED.
2016-12-09 13:47:04 -02:00
Gustavo Sverzut Barbieri afdbe897a0 efl_net: optimize serving of IP addresses.
If we can parse the IP using inet_pton() and the port, there is no
reason to call getaddrinfo() in a thread.

This is required since ecore_con_suite (for ecore_con-over-efl_net) will
assume the server is running as soon as it's created.
2016-12-09 13:47:04 -02:00
Gustavo Sverzut Barbieri b2bbc1c188 efl_net_server_simple: fix leak reported by eo_debug
eo_debug now reports leaked objects, which is very nice :-)
2016-12-09 13:47:04 -02:00
Gustavo Sverzut Barbieri 9e682774d2 efl_net_dialer_socket: allow us to create a dialer from existing object.
If we want to upgrade a dialer, then we must have a way to know if
that socket has already adopted another socket so we don't create it.

We can't simply use efl_net_socket_ssl, otherwise we'd miss some
methods such as efl_net_dialer_address_dial_get() and events such as
connected.
2016-12-09 13:47:04 -02:00
Gustavo Sverzut Barbieri 3fc0fbba42 efl_net_socket_fd: do not close stdout if nothing was set.
if we create an object, say a TCP dialer, and don't connect/bind, then
we have no FD (=0). If we set FD to INVALID_SOCKET on start, other
parts of the code will fail since they consider that "closed", but
we're not closed yet.

Then check for family == AF_UNSPEC && fd == 0, if so don't close it.
2016-12-09 13:47:03 -02:00
Gustavo Sverzut Barbieri cfc21c16fb efl_net_ssl: do not access torn down sockets.
OpenSSL crashes if given a NULL pointer, then be safe and remember if
we did the tear down -- print error so bugs can be identified more
easily.
2016-12-09 13:47:03 -02:00
Gustavo Sverzut Barbieri c97111bf3c efl_net_ssl_conn-openssl: fix dlsym() for X509_check_ip_asc.
At least in ArchLinux the function has no "_" in the symbol name,
matching perfectly what's in the header.

If in other systems it misses such symbol, then check for both.
2016-12-09 13:47:03 -02:00
Gustavo Sverzut Barbieri 17e0204ab3 efl_net_server_ssl: monitor context del and unref on destructor.
we're leaking ssl_ctx on destruction, also monitor it so we don't
access stale data.
2016-12-08 16:00:01 -02:00
Gustavo Sverzut Barbieri 7c7ea6be06 efl_net_ssl_context: check and document constructor only properties.
The context is shared and thus these lists should be static once
object is created.
2016-12-08 16:00:01 -02:00
Gustavo Sverzut Barbieri b64df5e323 efl_net_dialer_ssl: fix copy&paste too much. 2016-12-08 16:00:01 -02:00
Carsten Haitzler 96d90fa5d6 efl_net check openssl x509 check o runtime dlsym checks
this fixes T4814
2016-12-06 16:16:23 +09:00
Gustavo Sverzut Barbieri 2cb3466ddf ecore_con_url: now on top of efl_net_dialer_http.
Rewrite Ecore_Con_Url as a non-Eo (since it's just legacy) that is
built on top of Efl_Net_Dialer_Http.

Since there are some legacy behavior we do not want to expose in the
new classes, hack around and manipulate the curl_easy_setopt()
directly in those cases.

This includes the cookies: there is no reason why we should expose
independent files for read (COOKIEFILE) and write (COOKIEJAR), real
world applications can manipulate the files directly, like copying
from a template to a RDWR before using, etc.
2016-11-29 16:03:14 -02:00
Gustavo Sverzut Barbieri da143edd8c efl_net_dialer_http: POST also allows resizing.
resizing the dialer results in changing the request content length,
which is useful when uploading files AND posting data.
2016-11-29 16:03:13 -02:00
Gustavo Sverzut Barbieri 4aca800bde efl_net_dialer_http: export SSL controls.
verify peer, hostname and set CA/CRL files.
2016-11-29 16:02:25 -02:00
Gustavo Sverzut Barbieri 3cf20ea8e8 efl_net_dialer_http: special headers and date parse/serialize.
CURL needs some special curl_easy_setopt() calls to enable automatic
gzip deflate (CURLOPT_ENCODING) and
If-Modified-Since/If-Unmodified-Since logic.

As If-Modified-Since/If-Unmodified-Since requires a timestamp string,
let's expose class methods to handle those.
2016-11-29 16:02:25 -02:00
Gustavo Sverzut Barbieri 5c7b984746 efl_net_dialer_http: only close if not closed yet.
since eos_set() emits an event the user may have closed from there.
2016-11-29 16:02:25 -02:00
Gustavo Sverzut Barbieri b4ed72518d efl_net_dialer_http: export read size.
In the legacy wrapper I'll need that.
2016-11-29 16:02:25 -02:00
Andrii Kroitor 03f20efaf0 ecore_con: fix work on Windows
Per aspera ad astra.
One little missing star was breaking all EFL UI applications.
2016-11-29 15:15:26 +02:00
Jee-Yong Um 0e2a2cbacf eolian: remove all duplicated affix
Summary:
Currently eolian abbreviates when only the last word of class name and
the first word of method name are same, but this patch abbreviates
generated c name of function to remove all duplicated affix.
For example, "efl_io_closer_fd_closer_fd_set" will be "efl_io_closer_fd_set".

Reviewers: jpeg

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D4430

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2016-11-28 11:35:27 -08:00
Gustavo Sverzut Barbieri 48049a4ce2 efl_net_server_unix: add leading_directories_create property.
This allows us to crete any parent directories that are missing.
2016-11-25 18:01:29 -02:00
Gustavo Sverzut Barbieri 167ff29ea0 efl_net_{socket,dialer,server}_simple: easy to use, buffered network sockets.
The low level I/O primitives are powerful but adds some complexity to
use, for bi-directional streaming communication one ends creating two
Efl.Io.Queue and two Efl.Io.Copier to pipe data to socket when it can
operate.

Then encapsulate the socket using the new Efl.Io.Buffered_Stream, this
will allow the socket, be a dialer or a server client, to be operated
as a single handle that internally carries about the buffering for
you.

As one can see in the examples, compared to their "manual"
alternatives they are very easy to use, ressembling
Ecore_Con_Server/Ecore_Con_Client, but also offers line-based
delimiters and the possibility to let the socket to handle queueing
for you in case you received partial messages (just do not
read/clear/discard the received data).
2016-11-25 17:27:32 -02:00
Gustavo Sverzut Barbieri 410d65900c efl_net_server: add 'client_announce', share logic and fix a bug.
I just realized that if a client is not referenced it would leak in
the 'ssl' server as we must del it.

However, if we del the SSL socket, we're going to close the underlying
TCP. But we're from the TCP "client,add" callback and this causes
issues since "closed" will be emitted, our close callback will
unparent the client, which lead to it being deleted.

The proper solution is to only monitor "closed" if the client is
accepted. Otherwise we just check if it was closed, if we're the
parent, etc...

Fixing this in all servers were painful, we could share since most
inherit from Efl.Net.Server.Fd. Then add the "client_announce"
protected method to do it, and document how it should work.
2016-11-25 17:25:18 -02:00
Gustavo Sverzut Barbieri c534d79124 efl_net_socket_fd: stop monitoring fd on EOS.
There was a bug that if the remote peer closed the connection, it
would trigger 'read' event, which would read 0 bytes, flagging as
EOS... but then marking as "can_read", which was wrong.

Just stop monitoring the events and fix that.
2016-11-25 17:25:18 -02:00
Gustavo Sverzut Barbieri c2cb5defe3 efl_net_dialer_http: use efl_loop_fd now that it's fixed.
now that efl_loop_fd manages callbacks -> Ecore_Fd_Handler properly,
we can remove the old code.
2016-11-24 02:13:32 -02:00
Gustavo Sverzut Barbieri 7edc1ef49d efl_net_socket_fd: fix copy & paste too much. 2016-11-24 02:11:56 -02:00
Gustavo Sverzut Barbieri 35cdde67d2 efl_net_socket_fd: do not spin on fd monitoring.
If we let the user know he can read or write, stop monitoring
otherwise fd handler will constanly report of data to read/write until
its actually done, which would clear the kernel flag.

Since we use "can_read" and "can_write" for that, toggle the callback
connection that manages the actual Ecore_Fd_Handler monitor.
2016-11-24 00:45:55 -02:00
Gustavo Sverzut Barbieri 92a3361deb efl_net_server_fd: do not spin if clients can be accepted.
If we have incoming clients but we do not want to drop or handle then,
stop monitoring the fd's read, otherwise we constantly spin the main
loop.
2016-11-24 00:42:54 -02:00
Gustavo Sverzut Barbieri d0b6aa6596 efl_net_server_unix: do bind() from serve() method.
Instead of adding a job to create the socket and call bind(), do it
straight from the serve() method, this allows the caller to set
umask(), permissions and so on.

Document this behavior in the class, since we can't extend the
method's documentation.
2016-11-23 18:38:24 -02:00
Gustavo Sverzut Barbieri 2f91934502 ecore_con: export function to create local path string.
The new efl_net code won't compose any path own its own, allowing the
user to connect to non-EFL systems.

However we need a way to use the same path Ecore_Con_Server does, so
we can reach it. Then export and use ecore_con_local_path_new() to do
exactly that.
2016-11-23 12:57:10 -02:00
Stefan Schmidt 9b0bc5e029 docs: ecore_con: fill last gaps ion ecore_con eo file documentation 2016-11-23 14:16:24 +01:00
Gustavo Sverzut Barbieri 6062109707 efl_net: proper format for SOCKET.
SOCKET is defined as uintptr_t (uint_ptr as called on Windows) and
thus will vary its size based on 32 or 64 bits.

Then we should format with PRIuPTR from inttypes.h, which is supported
since VisualStudio 2013
https://blogs.msdn.microsoft.com/vcblog/2013/07/19/c99-library-support-in-visual-studio-2013/
2016-11-22 11:03:57 -02:00
Jee-Yong Um 0f97d45dac fix doxygen warnings
Summary:
fix warnings while generating documents
- end of file while inside a group (eina_util.h)
- missing title after \defgroup
- ignoring title "Ecore_Con_Lib_Group" that does not match old title

Reviewers: Hermet

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D4420
2016-11-22 11:47:04 +09:00
Gustavo Sverzut Barbieri db4d4f8c87 efl_net_{control,session}: allow "none" backend.
Since connman is specific to linux, on other platforms just compile a
dummy "none" backend that will always report online and no other
details. This will be used in Windows, MacOS and other platforms that
still lack a proper backend.

The compile-time infrastructure also allows for networkmanager to be
added with ease, simply copy "efl_net*-none.c" or "efl_net*-connman.c"
to be a starting point and then add its specifics, adapting
configure.ac and Makefile_Ecore_Con.am
2016-11-18 18:20:25 -02:00
Gustavo Sverzut Barbieri 3f2881a458 efl_net: SOCKET_FMT is "long" on windows.
at least it seems so, let's see if warnings are gone.
2016-11-18 15:16:32 -02:00
Gustavo Sverzut Barbieri d6584673ea ecore_con (legacy) fix close()->closesocket() and valid fd check.
use the windows version and it will also work on UNIX due macros.
2016-11-18 14:21:21 -02:00
Gustavo Sverzut Barbieri dc3da201fd efl_net: remove warnings related to unused parameters.
if these options are not available, then cast "o" to void so it
doesn't trigger a warning, for example on Windows.
2016-11-18 14:21:21 -02:00
Gustavo Sverzut Barbieri c0f84d190f efl_net: fix missing SOCKET_FMT. 2016-11-18 14:21:21 -02:00
Stefan Schmidt f77a602a09 ecore_con: fix time to live value name and type
The time to live hop limit should not be named loopback and have a type that
can actuall hold the number of hops. It already was always uint8 in the code.
Just fix the eo file.
2016-11-18 16:20:55 +01:00
Gustavo Sverzut Barbieri 371a3332ef efl_net: remove getsockopt()/setsockopt() warning on windows.
windows is nasty and defines the value to be set or retrieved as
'char *', which triggers a warning when we use another kind of
pointer.

Partially addresses D4357.
2016-11-18 12:53:32 -02:00
Gustavo Sverzut Barbieri 8d24622f57 efl_net: remove send()/recv() warning on windows.
windows is nasty and defines the payload to be sent or received as
'char *', which triggers a warning when we use another kind of
pointer.

Partially addresses D4357.
2016-11-18 12:53:32 -02:00
Gustavo Sverzut Barbieri c3ddc8f09e efl_net: do not use sockaddr_un on Windows.
struct sockaddr_un doesn't exist on windows, so do not use it.

Partially addresses D4357.
2016-11-18 12:53:32 -02:00
Gustavo Sverzut Barbieri b322a3ae53 efl_net: define EAI_SYSTEM when it's not defined (ie: Windows).
its value is unimportant, just do not match any other EAI error value.

Partially fixes D4357.
2016-11-18 12:53:32 -02:00
Gustavo Sverzut Barbieri 090940c3ae efl_net: windows do not define AI_ADDRCONFIG.
do as for other missing bitwise flags and simply define to 0, reducing
need to ifdefs in the code.

This partially addresses D4357.
2016-11-18 12:53:32 -02:00
Gustavo Sverzut Barbieri 5818dc71da efl_net: use SOCKET_FMT to format SOCKET so it works on UNIX and Windows.
On Windows SOCKET is unsigned, thus will cause sign errors when
formatting with "%d" or comparing with signed values.

On UNIX it was quiet and easy to miss, thus a new #define can be used
to check for those. It will use 'unsigned long' as SOCKET, thus will
complain out loud and not even work correctly when using pointers on
64bits UNIX on mistakes -- which should improve the situation.

This helped to fix lots of missing conversions, all fixed.

This partially addresses D4357.
2016-11-18 12:53:32 -02:00
Stefan Schmidt a2d48a5df3 efl_net_ser_udp: fix vlaue name for time to live property
The loopback value name here was really just a copy and paste mistake.
2016-11-17 13:45:49 +01:00
Vincent Torri c0d8f1cc37 ecore_con: correctly include sys/ioctl.h
I had to make distclean for this patch to work.

Differential Revision: https://phab.enlightenment.org/D4402
2016-11-16 19:50:24 +09:00
Jean Guyomarc'h 2e8d6968fd
ecore_con: fix pointers type mismatches
printf() was not happy with a void* being used with the %s format.
Since the 'key' values are actually strings and let's declare them
as const char* to fully embrace the string semantics.
2016-11-12 10:39:18 +01:00
Stefan Schmidt b8dfc68ee2 docs: ecore_con: add all missing docs for ecore_con
This should fill all gaps we still had in ecore_con. Please make sure all new
additions comes with docs as well.
2016-11-11 15:35:48 +01:00
Stefan Schmidt f3d1211266 docs: efl_net_server: add missing docs for efl_net_server 2016-11-11 15:35:18 +01:00
Stefan Schmidt c2754dc562 docs: efl_net_socket: add missing docs for efl_net_socket 2016-11-11 15:34:08 +01:00
Stefan Schmidt 44b3fb5ebc docs: efl_net_dialer: add missing docs for efl_net_dialer 2016-11-11 15:33:18 +01:00
Stefan Schmidt be9283c17c docs: efl_net_control*: ad missing docs in efl_net_control* 2016-11-11 15:30:55 +01:00
Stefan Schmidt 6570c26921 docs: efl_network*: add missing documentation 2016-11-11 15:28:49 +01:00
Stefan Schmidt c588d49caa docs: efl_net*: add docs for newly added enums 2016-11-11 08:34:11 +01:00
Daniel Kolesa 5c54c53975 efl_net_control: remove pointer 2016-11-10 16:02:44 +01:00
Gustavo Sverzut Barbieri 1dfdb9ebd9 efl_net_session-connman: be more careful with incoming messages.
Check if calls succeed before using the values.

Fixes CID 1365677, 1365676, 1365675
2016-11-10 00:40:17 -02:00
Gustavo Sverzut Barbieri 8a2ecda4d4 efl_net_dialer_udp: remove redundant thread cancel.
it was already done lines above, likely c&p left over.
2016-11-10 00:15:36 -02:00
Gustavo Sverzut Barbieri 7917fa4ebf efl_net_dialer_http: NULL-ify thread pointer when it's gone.
on thread cancel and end, we should nullify the pointer if it was
still set.
2016-11-10 00:10:11 -02:00
Gustavo Sverzut Barbieri 21617f83c2 efl_net_server_unix: fix invalid socket comparison.
Fixes CID 1365321.
2016-11-09 17:25:27 -02:00
Gustavo Sverzut Barbieri 98fe627ca4 efl_net_session and efl_net_control for ConnMan
These are objects to allow control of networking devices
(efl_net_control) as well as an application to request for
connectivity (efl_net_session).

They are loosely based on ConnMan.org, which we already use in
Enlightenment Window Manager via DBus access with Eldbus. However they
do not map 1:1 as the goal was to expose a viable subset of controls
but in a simple and general way, thus nome strings were converted to
enums, some arrays of strings were converted to bitwise flags, some
names were made more general, such as "service" was turned into
"access point" so it doesn't generate confusion with other "network
services" (ie: http server), or "favorite" that was renamed to
"remembered". Some behavior are slightly different (yet able to be
implemented on top), such as "Service.MoveBefore" and "MoveAfter" were
converted to a numeric "priority", calculated from service's list
index, changing the priority will reoder the list and thus generate
the MoveBefore and MoveAfter DBus commands.

ConnMan was chosen not only because we already use it, but because its
DBus API is sane and simple, with the server doing almost all that we
need. This is visible in the efl_net_session, which is completely done
in the server and do not require any extra work on our side -- aside
from talking DBus and converting to Eo, which is a major work :-D

   NOTE: ConnMan doesn't use FreeDesktop.Org DBus interfaces such as
         Properties and ObjectManager, thus we cannot use
         eldbus_model_object.

There are two examples added:

 - efl_net_session_example: monitors the connection available for an
   application and try to connect. You need a connman compiled with
   session_policy_local and a configuration file explained in
   https://github.com/aldebaran/connman/blob/master/doc/session-policy-format.txt
   to get a connection if nothing is connected. Otherwise it will just
   monitor the connectivity state.

 - efl_net_control_example: monitors, plays the agent and configure
   the network details. It can enable/disable technologies, connect to
   access points (services) and configure them. It's quite extensive
   as allows testing all of ConnMan's DBus API except P2P (Peers).
2016-11-08 22:40:34 -02:00
Stefan Schmidt 9a10b83281 docs: ecore_con: add missing docs for new efl_net_* components 2016-11-07 15:58:54 +01:00
Daniel Kolesa 6975b89e14 ecore con: remove pointers 2016-11-04 17:07:50 +01:00
Stefan Schmidt 42426735e8 docs: ecore: document various type defines 2016-11-03 11:57:40 +01:00
Gustavo Sverzut Barbieri 54e00b5e9d unbreak build for OpenSSL < 1.0.2
not the ideal solution, but we need a decision if we're going to copy
the long code from OpenSSL into our library just to support legacy
users, given that Efl.Net targeted at the future.
2016-11-01 19:38:41 -02:00
Gustavo Sverzut Barbieri c2630c829f efl_net_server support systemd socket activation.
It includes extensive verifications to avoid mistakes and usage of
incorrect sockets.
2016-11-01 16:37:04 -02:00
Gustavo Sverzut Barbieri a5ebf67a83 efl_net_{server,dialer}_ssl: TCP + SSL easy to use.
in the previous commit we're manually upgrading an existing TCP socket
to SSL. It is desired since some protocols need to negotiate, like
STARTTLS and the likes

Now we offer 2 classes that does autostart SSL once the socket is
ready.
2016-11-01 01:31:56 -02:00
Gustavo Sverzut Barbieri 5e8dd491a5 efl_net_ssl: fix build on LibreSSL and BSD
As usual thanks to @netstar for quickly spotting the problem :-)

Fixes: T4811
2016-10-31 22:28:41 -02:00
Gustavo Sverzut Barbieri f4198f022a efl_net_socket_ssl: initial SSL wrapper.
This is the first step towards SSL connections on top of sockets, with
an example on how to upgrade a dialer and a server client using TCP.
2016-10-31 19:39:33 -02:00
Gustavo Sverzut Barbieri f8a5290798 efl_net_socket_fd: do not act if already closed, do not set eos.
It's pointless to reset eos, if it was set, keep it like that.
2016-10-31 19:38:22 -02:00
Gustavo Sverzut Barbieri 1ea6a42f7a remove incorrect EINA_UNUSED. 2016-10-31 19:38:22 -02:00
Jean Guyomarc'h d27b1df4e8 ecore_con: fix structure declaration
Clang raised a massive amount of warnings due to the struct sockaddr_un
not being declared before using it. So, include the header that declares
this structure first.
2016-10-30 18:40:54 +01:00
Stefan Schmidt 72f456ee82 docs: ecore_con: document missing structs 2016-10-27 18:22:42 +02:00
Gustavo Sverzut Barbieri 48fb9e72df UNIX socket doesn't exist on Windows.
thanks to vtorri & Kuri to spot that one.
2016-10-27 09:01:56 -02:00
Gustavo Sverzut Barbieri fa3a2e6489 efl_net_dialer_http: fix short downloads.
for short downloads the CURL handle will be done before the client had
time to read it, like done by efl_io_copier's job. We need to wait it
drain before we emit eos/closed.
2016-10-26 23:19:46 -02:00
Stefan Schmidt 6f25878665 docs: fix the last missing enum field docs all over the tree
With this comit we reach 100% eo doc coverage for enum fields. Keep it like
this. :)
2016-10-27 00:26:16 +02:00
Gustavo Sverzut Barbieri 651ff13616 addded efl_net_{socket,dialer,server}_unix
This introduces AF_UNIX server and dialer, these are not available on
Windows as in that platform we'll create a custom class for native
'local' communication.

In the future we can add a wrapper class Efl.Net.Local that will use
the class for each platform, but won't expose its details.

For instance, if we ever expose 'credentials' (which I didn't because
they are not portable), then it doesn't make sense to try to match
that on Windows. The 'Efl.Net.Local' would just stick to the basics:
Reader, Writer and Closer APIs.
2016-10-26 19:01:03 -02:00
Gustavo Sverzut Barbieri 84ee276b12 efl_net_dialer_tcp: remove useless code. 2016-10-26 19:01:03 -02:00
Gustavo Sverzut Barbieri 7a842e0612 efl_net_dialer_tcp: make code bit more robust.
Also avoids the double-set of remote address, since socket.tcp will
alredy do that for us when we efl_loop_fd_set().
2016-10-26 19:01:03 -02:00
Gustavo Sverzut Barbieri 9a62932d07 use more standard IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP.
The IPV6_ADD_MEMBERSHIP and IPV6_DROP_MEMBERSHIP are deprecated alias,
use the correct defines so it compiles everywhere.

Fixes T4764

Thanks netstar!
2016-10-25 19:32:07 -02:00
Stefan Schmidt a6022c1702 docs: ecore_con: document missing HTTP enums 2016-10-25 16:08:25 +02:00
Daniel Kolesa 08f11e2c46 ecore con: fix invalid doc reference
Fixes T4761 (also spank @barbieri)
2016-10-25 15:54:46 +02:00
Gustavo Sverzut Barbieri cd53f9bad2 efl_net_*_udp: make UDP usable, including multicast.
This was a huge work, but now UDP is usable as seen in the examples.

Instead of relying on 'connect()', just do 'sendto()' and 'recvfrom()'
as they are universal. Multicast address can only be connected in
IPv4, IPv6 wasn't working and I'm not sure the IPv4 is portable to
other platforms.

Dialer will auto-join multicast groups is the dialed address is
one. Multicast properties such as time to live (hops) and loopback can
be configured. When joining multicast groups, the local
address/interface can be configured by 'IP@IFACE' format, with
'@IFACE' being optional.

Dialers will now auto-bind, so it can receive data as dialers are
expected to be bi-directional. One can manually specify the binding
address if there is such need.

Since datagrams must be read in their full size, otherwise the
remaining bits are dropped, expose next_datagram_size_query() in both
Efl.Net.Socket.Udp and Efl.Net.Server.Udp.Client.

To finalize UDP for real we need to introduce an 'Efl_Net_Ip_Address'
structure to serve as both IPv4 and IPv6 and expose 'sendto()' and
'recvfrom()'. These will come later as this commit is already too big.
2016-10-25 10:11:48 -02:00
Gustavo Sverzut Barbieri 6d1a54ed8e efl_net_server_udp_client: add missing part of name. 2016-10-25 10:11:48 -02:00
Gustavo Sverzut Barbieri 91499c5179 efl_net_server_fd: fix inverted comparison for valid socket handle. 2016-10-22 22:41:01 -02:00