Async non-blocking multi-protocol networking library for C/C++

Related tags

Miscellaneous fossa
Overview

Fossa: Multi-Protocol Networking Library

Note: As of September 21st 2015, Fossa project has been merged back into Mongoose project

Fossa is a multi-protocol networking library written in C. It provides easy to use event-driven interface that allows to implement network protocols or scalable network applications with little effort. Fossa helps developers to manage the complexity of network programming and let them concentrate on the logic, saving time and money.

Fossa has built-in support for several protocols, like HTTP, Websocket, MQTT, mDNS. Example applications include Websocket-based chat server, JSON-RPC server, database server with RESTful API, MQTT broker, netcat with SSL and hexdump, Raspberry PI camera video feed + led control, and more.

Fossa is ideal for the embedded environments, it has been designed as an open source platform for connecting devices and bringing them online.

Features

  • Cross-platform: works on Linux/UNIX, QNX, eCos, Windows, Android, iPhone, etc
  • Single-threaded, asynchronous, non-blocking core with simple event-based API
  • Builtin protocols:
    • plain TCP, plain UDP, SSL/TLS (over TCP, one-way or two-way)
    • HTTP client, HTTP server
    • Websocket client, Websocket server
    • JSON-RPC client, JSON-RPC server
    • MQTT client, MQTT broker
    • CoAP client, CoAP server
    • DNS client, DNS server, async DNS resolver
  • Tiny static and run-time footprint
  • Source code is both ISO C and ISO C++ compliant
  • Very easy to integrate: just copy fossa.c and fossa.h files to your build tree
  • Extensively tested and production-ready, trusted by many blue chip businesses

Examples & Documentation

  • User Guide - Detailed User Guide and API reference
  • examples - Collection of well-commented examples. To build any example, go into respective directory and type make

Contributions

People who have agreed to the Cesanta CLA can make contributions. Note that the CLA isn't a copyright assigment but rather a copyright license. You retain the copyright on your contributions.

License

Fossa is released under GNU GPL v.2. Businesses have an option to get non-restrictive, royalty-free commercial license and professional support from Cesanta.

Comments
  • Add Arduino (W5100) support

    Add Arduino (W5100) support

    Hi, @rojer

    Please, review this PR.

    It implements support of Arduino Ethernet Shield (W5100) for fossa.

    Note: avrsupport.h & avrsupport.cpp is just an amalgamation of avrdebug, avrlibc_compat and W5100_sockets files.

    Review on Reviewable

    opened by alashkin 15
  • How to add a serial device in fossa's select loop?

    How to add a serial device in fossa's select loop?

    Hello. I have a serial device (CoolMaster 1000D). I want to write a web interface for it using fossa or mongoose on linux. Can you please tell how to add a tty to select/poll loop, which fossa uses.

    opened by makoven 14
  • Add support of CC3000 (server)

    Add support of CC3000 (server)

    Hi, @rojer

    Please, review this PR.

    It is support of CC3000 for fossa (only server - aka restful_server). This code is based on Adafruit/Texas instruments library (https://github.com/adafruit/Adafruit_CC3000_Library)

    Library stores in fossa's rep unformatted (so, sometimes code style could be strange). Later I'll make an amalgamation and use clang-format against it.

    Review on Reviewable

    opened by alashkin 14
  • CoAP: parser

    CoAP: parser

    Hello, Marko.

    In order to split implementation I've created new branch and remove everything but message parser from it. I didn't include changes in src/modules.mk, so this PR can be safely merged with master (at least I think so): it just adds two files in /src folder. Changes in unit_test.c is not included as well.

    opened by alashkin 11
  • Support `custom_mime_types` option when serving static files

    Support `custom_mime_types` option when serving static files

    Hi there!

    First of all, I want to say: thanks for all the good work of this library. It's been an enormous help so far with the WebSockets, built-in JSON-RPC support and static file serving via HTTP. :+1:

    Personally I'm a huge fan of setting a specific character set in the headers (UTF-8 in particular). This can be done by setting the charset after the MIME-type. So the Content-Type header will look like this:

    Content-Type: text/html; charset=utf-8
    Content-Type: application/javascript; charset=iso-8859-1
    Content-Type: text/css; charset=utf-8
    etc.
    

    This is what I would like to do too in my program. However, currently I cannot find any support for setting the charset for plain text-based mime-types. Is it possible to incorporate this feature?

    For example:

    1. Save the charset ("utf-8") as a variable const char *charset in proto_data_http
    2. add a variable int set_charset in static_builtin_mime_types[] for plain text-based types (please take a look here for my ideas)
    3. if set_charset is positive, add ; charset=utf=8 to MIME-type (where charset is UTF-8, e.g.)

    I would like to hear your feedback on this and of course I would be glad to help programming it.

    Thanks in advance, Hefting

    opened by tiesjan 10
  • Aborted (core dumped)

    Aborted (core dumped)

    example multi-threaded server has Aborted (core dumped) compilation with gcc 4.9.2

    cc multithreaded_restful_server.c ../../fossa.c -o multithreaded_restful_server -W -Wall -I../.. -pthread -DNS_ENABLE_THREADS 
    ../../fossa.c: In function ‘spawn_handling_thread’:
    ../../fossa.c:3134:10: warning: missing initializer for field ‘active_connections’ of ‘struct ns_mgr’ [-Wmissing-field-initializers]
       struct ns_mgr dummy = {};
              ^
    In file included from ../../fossa.c:1:0:
    ../../fossa.h:603:25: note: ‘active_connections’ declared here
       struct ns_connection *active_connections;
                             ^
    
    

    running and crash after try to connect with firefox 40.0.3 browser

    oracle@ub-vm:~/Downloads/fossa-e4bd371337db61c17b809cb123b76dc061ceaf10/examples/multithreaded_restful_server$ ./multithreaded_restful_server 
    Starting multi-threaded server on port 8000
    epoll_ctl: Invalid argument
    Aborted (core dumped)
    
    
    opened by MaxSurtaev 9
  • coap minimal

    coap minimal

    Hi, @mmikulicic !

    Please, review this PR. Since this is my first protocol added to fossa, I'm not sure that I'm right in details.

    Please, take a look. (aka PTAL)

    opened by alashkin 8
  • Completion of error handling

    Completion of error handling

    opened by elfring 8
  • Fossa fails to link without NS_DISABLE_PFS switch on Windows

    Fossa fails to link without NS_DISABLE_PFS switch on Windows

    I get unresolved externals as of below when I try to compile fossa on windows with NS_ENABLE_SSL. They are related to PFS (links if NS_DISABLE_PFS defined). Lib used is oppenssl 1.0.2d. ssleay

    Do I need to link to any more lib for this functionality and if so which?

    Cheers /Ake

    fossa.obj : error LNK2019: unresolved external symbol _BIO_new_file referenced in function _ns_use_cert 1>fossa.obj : error LNK2019: unresolved external symbol _BIO_free referenced in function _ns_use_cert 1>fossa.obj : error LNK2019: unresolved external symbol _BIO_new_mem_buf referenced in function _ns_use_cert 1>fossa.obj : error LNK2019: unresolved external symbol _DH_free referenced in function _ns_use_cert 1>fossa.obj : error LNK2019: unresolved external symbol _PEM_read_bio_DHparams referenced in function _ns_use_cert 1>.\Debug/vscphelper.dll : fatal error LNK1120: 5 unresolved externals

    opened by grodansparadis 6
  • Add simple URI rewriting mechanism

    Add simple URI rewriting mechanism

    Configured with -b flag:

    • -b /path/ - no rewriting, pass URI as is
    • -b /path/=/otherpath/ - replace "/path/" prefix with "/otherpath/"
    • -b /path= - strip "/path" prefix from URI

    Also fix -r option handling.

    Review on Reviewable

    opened by imax9000 6
  • Add directory listing to HTTP server

    Add directory listing to HTTP server

    To test,

    Unix build:

    make -C examples/restful_server
     examples/restful_server/restful_server -d /etc
    

    Windows build:

    wine make -C examples/restful_server restful_server.exe
    wine examples/restful_server/restful_server.exe -d /etc/
    

    Review on Reviewable

    opened by cpq 6
  • Undefined behaviour under Release build

    Undefined behaviour under Release build

    I can't use the socket server when building my application in Release mode. The server is up but it can't get any connection nor messages. I compiled my program with gcc-8.4.0 for x86_64 and with gcc-8.3.0 for arm_32 and both compilations resulted in the same error. Hence in Release mode, I can't debug the code and using printf in each lib function didn't result in any significant help either. I guess the compiler is optimizing/removing some part of the code that it definitely shouldn't.

    opened by andre237 0
  • latest code complain over random() on windows

    latest code complain over random() on windows

    Latest code don't compile on windows with vs 2015. Complain about random() not available in the

    if NS_DISABLE_WS_RANDOM_MASK

    return 0xefbeadde; /* generated with a random number generator, I swear */

    else

    if (sizeof(long) >= 4) { return (uint32_t) random(); } else if (sizeof(long) == 2) { return (uint32_t) random() << 16 | (uint32_t) random(); }

    endif

    }

    opened by grodansparadis 2
  • missing .gitgnore

    missing .gitgnore

    git clone and make:(Ubuntu 10.04) (https://github.com/cesanta/fossa/issues/305)

    ~/src/1/fossa$ git status On branch master Untracked files: (use "git add ..." to include in what will be committed)

       examples/captive_dns_server/captive_dns_server
       examples/coap_client/coap_client
       examples/coap_server/coap_server
       examples/http_client/http_client
       examples/json_rpc_server/json_rpc_server
       examples/mqtt_broker/mqtt_broker
       examples/mqtt_client/mqtt_client
       examples/netcat/nc
       examples/publish_subscribe/publish_subscribe
       test/unit_test
    

    nothing added to commit but untracked files present (use "git add" to track)

    opened by pavel-pimenov 0
  • error build (ubuntu 10.04)

    error build (ubuntu 10.04)

    git clone

    :~/src/1/fossa$ make make[1]: Entering directory `/home/ppa/src/1/fossa/test' unit_test.c: In function 'test_mbuf': unit_test.c:98: warning: integer constant is too large for 'long' type unit_test.c:98: warning: large integer implicitly truncated to unsigned type unit_test.c:98: warning: integer constant is too large for 'long' type unit_test.c:98: warning: large integer implicitly truncated to unsigned type unit_test.c:123: warning: integer constant is too large for 'long' type unit_test.c:123: warning: large integer implicitly truncated to unsigned type unit_test.c:123: warning: integer constant is too large for 'long' type unit_test.c:123: warning: large integer implicitly truncated to unsigned type [0.000] test_mbuf [0.000] test_parse_address [0.000] test_check_ip_acl [0.000] test_connect_opts [0.000] test_connect_opts_error_string

    ....

    cc device_side.c ../../fossa.c -I../.. -o device_side -W -Wall -DNS_ENABLE_THREADS -pthread device_side.c: In function 'generate_mjpg_data_thread_func': device_side.c:133: warning: implicit declaration of function 'WIFSIGNALED' /tmp/ccaLKefW.o: In function generate_mjpg_data_thread_func': device_side.c:(.text+0x49b): undefined reference toWIFSIGNALED' collect2: ld returned 1 exit status make[2]: *** [device_side] Error 1 make[2]: Leaving directory /home/ppa/src/1/fossa/examples/raspberry_pi_mjpeg_led' make[1]: *** [raspberry_pi_mjpeg_led/] Error 2 make[1]: Leaving directory/home/ppa/src/1/fossa/examples' make: *** [examples] Error 2

    opened by pavel-pimenov 0
  • Make fossa friendlier for embedded systems

    Make fossa friendlier for embedded systems

    FYI @danielinux & @maximevince

    The primary fossa use case is embedded. However, when modules's functionality is getting extended, we unintentionally leak functions into the core, making it fatter. We need to make sure that our development does not increase core size, unless intended.

    • [ ] Disable all modules by default. Let user explicitly enable those which are needed
    • [ ] Make minimal fossa build on a small board (e.g. Arduino UNO)
    • [ ] Setup CI with embedded fossa build, making sure we're not bloating the code
    • [ ] No big objects on stack
    opened by cpq 4
Releases(2.1)
  • 2.1(Aug 27, 2015)

    What's new

    • Many SSL related improvements and fixes, including "modern" cryptography
    • New built-in protocol support: CoAP client and server
    • HTTP functionality improvements: CGI, WebDAV, ACL checks, SSI
    • Arduino support
    • Support for embedded PICOTCP TCP/IP stack integration
    • Many new examples added
    • Bugfixes

    See readme for more information.

    Source code(tar.gz)
    Source code(zip)
  • 2.0(Jan 19, 2015)

    Major changes

    • Project renamed to Fossa
    • Simplifications
    • Modularisation
    • Lots of examples (Raspberry Pi, load balancer, RPC, ...)
    • Many HTTP improvements forward ported from Mongoose.
    • Embed dependencies (to https://github.com/cesanta/frozen[frozen])

    New features

    • Async DNS client
    • DNS server
    • MQTT client (only QoS 0)
    • MQTT broker (in progress)
    • HTTP digest auth (#184)

    More information at https://github.com/cesanta/fossa/blob/master/CHANGELOG.adoc#20-2015-01-19

    Source code(tar.gz)
    Source code(zip)
Owner
Cesanta Software
Embedded Communication
Cesanta Software
Lua HTTP async client using libcurl (supports multi requests in parallel)

lua-async-http lua-async-http rock, is a new lua rock written in C and based on libcurl. It allow us to make multiple http/https (with client certific

International Business Machines 5 Oct 25, 2022
A simple PoC to demonstrate that is possible to write Non writable memory and execute Non executable memory on Windows

WindowsPermsPoC A simple PoC to demonstrate that is possible to write Non writable memory and execute Non executable memory on Windows You can build i

Lorenzo Maffia 55 Jul 21, 2022
Ad Blocking with an ESP32

About Esper Heavily inspired by the Pi-Hole, this project aims to bring network wide ad-blocking to another popular device popular among makers and ho

null 83 Jan 3, 2023
C/C++ language server supporting multi-million line code base, powered by libclang. Emacs, Vim, VSCode, and others with language server protocol support. Cross references, completion, diagnostics, semantic highlighting and more

Archived cquery is no longer under development. clangd and ccls are both good replacements. cquery cquery is a highly-scalable, low-latency language s

Jacob Dufault 2.3k Jan 2, 2023
Multi-dimensional dynamically distorted staggered multi-bandpass LV2 plugin

B.Angr A multi-dimensional dynamicly distorted staggered multi-bandpass LV2 plugin, for extreme soundmangling. Based on Airwindows XRegion. Key featur

null 21 Nov 7, 2022
Unicorn is a lightweight, multi-platform, multi-architecture CPU emulator framework, based on QEMU.

Unicorn Engine Unicorn is a lightweight, multi-platform, multi-architecture CPU emulator framework, based on QEMU. Unicorn offers some unparalleled fe

lazymio 1 Nov 7, 2021
Reactive - Simple, non intrusive reactive programming library for C++. (Events + Observable Properties + Reactive Properties)

Header only reactive C++ library. Thread-safe, memory-safe. Concsists from: Event (C# like Event, but thread-safe, does not block while event occurs,

null 63 Nov 23, 2022
Plua is a superset of Lua for classic PalmOS devices with added support for graphics, UI, networking, events and sound.

Plua2c Plua is a superset of Lua for classic PalmOS devices with added support for graphics, UI, networking, events and sound. This is the source code

Cameron Kaiser 9 Jan 5, 2023
Lightweight Peer-to-Peer networking engine for real time applications

Club A lightweight Peer-to-Peer networking engine for real time applications written in C++14. Motivation Real time applications such as Online games,

Peter 186 Nov 25, 2022
Disable OTA Update for iOS & iPadOS for 14 - 14.3 (Non Jailbreak devices)

OTADisabler-App Disable OTA Update for iOS & iPadOS for 14 - 14.3 (Non Jailbreak devices) Support Devices iOS 14.0-14.3 (confirmed on iOS 14.1 and abo

ichitaso 27 Dec 14, 2022
Exploit allowing you to read registry hives as non-admin on Windows 10 and 11

HiveNightmare aka SeriousSam, or now CVE-2021–36934. Exploit allowing you to read any registry hives as non-admin. What is this? An zero day exploit f

Kevin Beaumont 618 Jan 1, 2023
Faster Non-Integer Sample Rate Conversion

Non-Integer Sample Rate Conversion This repository contains a comparison of sample-rate conversion (SRC) algorithms, with an emphasis on performance f

null 25 Jul 5, 2022
Demagnetization tensor of non-equidistant magnetic layers

Demagnetization tensor of non-equidistant magnetic layers A small standalone project calculating the demagnetization tensor from [1] in multi-threaded

magnum.af 1 Dec 3, 2021
Next-gen Rowhammer fuzzer that uses non-uniform, frequency-based patterns.

Blacksmith Rowhammer Fuzzer This repository provides the code accompanying the paper Blacksmith: Scalable Rowhammering in the Frequency Domain that is

Computer Security Group @ ETH Zurich 173 Nov 16, 2022
A repository for experimenting with elf loading and in-place patching of android native libraries on non-android operating systems.

droidports: A repository for experimenting with elf loading and in-place patching of android native libraries on non-android operating systems. Discla

João Henrique 26 Dec 15, 2022
a unix inspired, non posix compliant micro kernel (more of a monolithic kernel for now though) that i am working on in my spare time

toy-kernel a unix inspired, non posix compliant micro kernel (more of a monolithic kernel for now though) that i am working on in my spare time prereq

czapek 13 Nov 27, 2022
Non bloated asynchronous logger

Minimal Asynchronous Logger (MAL) A performant asynchronous data logger with acceptable feature-bloat. Credit To my former employer Diadrom AB. for al

null 216 Oct 5, 2022
A C library for RP2040-powered boards to control LCDs via the I2C protocol

picoi2clcd A C library to control I2C LCD displays using the Rapsberry Pi Pico (or really any board using the RP2040 microcontroller). License All of

Kosmas Raptis 2 Oct 16, 2021
A C++ wrapper library for the monome serialosc protocol

serialoscpp A C++ wrapper library for the monome serialosc protocol Credits oscpack: Ross Bencina http://www.rossbencina.com/code/oscpack serialosc: 2

Isabel 1 Nov 2, 2021