Age | Commit message (Collapse) | Author |
|
Implement socket.recvmsg(), socket.sendmsg() and support for encoding
and decoding well known control message types.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Handle varying integer sizes for socket option values
- Support interfaces name and index option values
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Treat address string values containing slashes as AF_UNIX addresses
- Default to SOCK_DGRAM for non AF_INET, AF_INET6 sockets
- Gracefully handle EOPNOTSUPP condition after listen() call
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Treat address strings containing slashes as AF_UNIX paths and do not
attempt to resolve them.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Do not attempt to calculate a dynamic length for AF_UNIX socket addresses
but return the total size of `struct sockaddr_un`, like we do it for the
structures of other address families as well.
Fixes incorrect domain socket path truncation.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Remove an accidentially copy-pasted jsdoc comment block.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
socket: optimize poll() argument handling
|
|
Optimize the poll() function implementation to re-use passed in socket/flag
tuple arrays as-is in the return value array, which simplifies attaching
state to sockets for user code through subsequent fields in the tuple array.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
socket: fix potential memory leak in connect()
|
|
If a non-string value which cannot be interpreted as socket address
structure is passed to connect(), the function will leak the internal
address vector when returning the error.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Actually pass NULL to getaddrinfo() when the service argument is omitted,
instead of incorrectly translating it to a string containing "null".
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Fixes: 0662de6 ("socket: add AF_PACKET socket type support")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
socket: add AF_PACKET socket type support
|
|
Add the required infrastructure to support Linux AF_PACKET sockets:
- Add related constants
- Add struct definitions for SOL_PACKET socket options
- Add AF_PACKET family support to sockaddr routines
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
ubus: fix uc_ubus_have_uloop for eloop+uloop combination
|
|
When uloop has been integrated with eloop (in hostapd/wpa_supplicant),
uloop_cancelling will return false, since uloop_run is not being called.
This leads to ubus.defer() calling uloop_run in a context where it can
prevent the other event loop from running.
Fix this by detecting event loop integration via uloop_fd_set_cb being set
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
uloop: add documentation
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- fix `error()` function documentation
- change error message format order to `msg: strerror`
- change `xxx() failed` messages to just `xxx()`
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Our module documentation provides its own titles, so suppress generation
of default titles.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Do not unset CMAKE_REQUIRED_* variables in order to allow various
feature tests to work properly with nonstandard locations.
Fixes: #186
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
lib: introduce socket library
|
|
Introduce a new socket module which provides bindings for the BSD sockets
API to ucode scripts.
Example usage:
import * as socket from 'socket';
let sk = socket.create(socket.AF_INET, socket.SOCK_STREAM);
sk.connect("192.168.1.1", 80);
sk.send("GET / HTTP/1.0\r\n\r\n");
print(sk.recv(4096));
sk.close();
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The reorder() function takes no `name` parameter, this was a copy-paste
error in the documentation.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
|
|
This is needed when asynchronously processing requests via uloop, e.g.
using uclient.
Example script:
let libubus = require("ubus");
let uloop = require("uloop");
uloop.init();
let ubus = libubus.connect();
ubus.publish("test", {
test: {
call: function(req) {
req.defer();
uloop.timer(1000, () => {
req.reply({ msg: "Hello, world!" }, 0);
});
},
args: {}
},
});
uloop.run();
uloop.done();
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
ubus: automatically clear error information
|
|
vm: rework `in` operator semantics
|
|
- Ensure that testing for array membership does strict equality tests
- Ensure that `(NaN in [ NaN ]) == true`
- Do not perform implicit value conversion when testing for object keys,
to avoid nonsensical results such as `([] in { "[ ]": true }) == true`
- Add test cases for the `in` operator
Fixes: #193
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The function pops the last, not the first element from the array.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Make all functions clear the last error information on success in order to
ensure that `error()` never reports stale information.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Make all functions clear the last error information on success in order to
ensure that `error()` never reports stale information.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Make all functions clear the last error information on success in order to
ensure that `error()` never reports stale information.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
uci: refactor uci.changes() to match documentation
|
|
vm: rework object iteration
|
|
When invoked with an explicit package name argument, retain the autoloaded
configuration within the context state.
Fixes: #188
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Ensure that deleting object keys during iteration is safe by keeping a
global chain of per-object iterators which are advanced to the next key
when the entry that is about to be iterated is deleted.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
When removing locals from all scopes, upvalues need to be considered like
in uc_compiler_leave_scope(). Closing them is required to avoid leaving
lingering references to stack values that went out of scope, which would
lead to invalid memory accesses in subsequent code when such upvalues are
used by closures.
Fixes: #187
Signed-off-by: Felix Fietkau <nbd@nbd.name>
[add testcase, reword commit message]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
rtnl: improve event reception in order to avoid ENOBUFS
|
|
Use the same RX buffer size which iproute2 uses as default, in order to
avoid (or rather, delay as much as possible) ENOBUFS conditions when
receiving a large burst of netlink notifications.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Once we're notified about pending data on the netlink event socket,
try to receive as much messages as possible in order to empty the socket
buffer. In contrast to the previous implementation which received one
message per epoll read notification, this avoids some premature ENOBUFS
situations when a huge burst of messages arrives, e.g. due to kernel
side GC runs on the neighbor table.
Since libnl's nl_recvmsgs*() functions do not expose the underlying
-1 error returned by the recvmsg() calls, we need to indirectly check
for errors through errno variable, so clear it out both before the
recvmsgs() call and after successfully completing a message reception
callback invocation.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Only store the callback reference in the registry once the listener
context was successfully initialized, to avoid keeping a lingering
entry when invalid parameters are passed.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- The expected length was incorrect
- An incorrect MCS MAP index was accessed
- The maximum MCS index number were wrong
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The length constraint of 16 byte was incorrect, the attribute is 8 bytes
long; two bytes for the RX MCS set, two bytes for the highest RX rate,
two bytes for the TX MCS set and two bytes for the highest TX rate.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The attributes are arrays of 6 and 11 u8 values respectively.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
|
|
Allows other C code to gain access to the ubus context without having to know
the layout of the other fields.
Also reduce the amount of unnecessary pointer indirection
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|