Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding compiler options for enabling/disabling network layer #838

Open
jqiaobln opened this issue Mar 15, 2022 · 2 comments
Open

Adding compiler options for enabling/disabling network layer #838

jqiaobln opened this issue Mar 15, 2022 · 2 comments

Comments

@jqiaobln
Copy link

Is your feature request related to a problem? Please describe.

Coap is a transport layer protocol. It should be fully functional without assumptions of underlying security and network layer.

Libcoap has options to compile without TLS libraries; however it always includes networking layer code, i.e. coap_io.c and address.c, etc.

Describe the solution you'd like

Libcoap will improve its reusability and modulization if there are compiler options which can enable/disable the network layer code.

E.g. a project whose TLS and networking layer are handled by some other libraries, can integrate libcoap without including coap_io.c, address.c and the system networking libraries: socket, tcp, etc.

@obgm
Copy link
Owner

obgm commented Mar 16, 2022

@jqiaobln There is a defined interface for the underlying read/write operations on the network. Ports for non-POSIX platforms show how to replace them. Data structures such as coap_address_t can be replaced to serve special needs as well. DTLS and TLS can be switched off (there is no point in abstracting these away because the supported DTLS and TLS libraries address very specific transport layer characteristics).
Therefore, it is fairly easy to port the networking code to different transport layer abstractions by replacing certain. c files as done for the existing ports.

@mrdeep1
Copy link
Collaborator

mrdeep1 commented Apr 11, 2023

@jqiaobln libcoap is now broken down into protocol layers, making it much easier to intercept at the level appropriate for your application.

So, in your cited case, the coap_netif_*() functions (in src/coap_netif.c) can call whatever is appropriate. You may also want to adjust the indexing table coap_layers_coap[] in src/coap_io.c (or its equivalent in one of your files) to point into your equivalent functions.

Each layer function calls the next function in the protocol stack (when it has finished processing) with its level as an index - e.g. session->sock.lfunc[COAP_LAYER_WS].write(session, (uint8_t*)buf, strlen(buf)); for invoking the next layer down when doing a write having completed the COAP_LAYER_WS write logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants