mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-16 07:27:35 +00:00
genode_c_api/socket: add label to socket init
Add label argument to genode_socket_init that can be/is used to label possible connecions. issue #5471
This commit is contained in:
parent
a7bd01bd4a
commit
92086cce68
@ -89,11 +89,14 @@ struct Main
|
||||
|
||||
|
||||
void genode_socket_init(struct genode_env *_env,
|
||||
struct genode_socket_io_progress *io_progress)
|
||||
struct genode_socket_io_progress *io_progress,
|
||||
char const *label)
|
||||
{
|
||||
Env &env = *static_cast<Env *>(_env);
|
||||
static Main main { env, io_progress };
|
||||
|
||||
socket_label(label);
|
||||
|
||||
Lx_kit::initialize(env, main.schedule_handler);
|
||||
|
||||
main.init();
|
||||
|
@ -202,7 +202,8 @@ static int __init virtio_net_driver_init(void)
|
||||
|
||||
dev->netdev_ops = &net_ops;
|
||||
|
||||
dev->ifalias = (struct dev_ifalias *)genode_nic_client_create("");
|
||||
dev->ifalias = (struct dev_ifalias *)
|
||||
genode_nic_client_create(socket_nic_client_label());
|
||||
|
||||
if (!dev->ifalias) {
|
||||
printk("Failed to create nic client\n");
|
||||
|
@ -29,6 +29,10 @@ extern "C" {
|
||||
void socket_config_address(void);
|
||||
void socket_unconfigure_address(void);
|
||||
void socket_update_link_state(void);
|
||||
|
||||
void socket_label(char const *);
|
||||
char const *socket_nic_client_label(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -37,10 +37,11 @@ using Socket_queue = Fifo<Lx_call>;
|
||||
|
||||
struct Statics
|
||||
{
|
||||
genode_socket_wakeup *wakeup_remote { nullptr };
|
||||
genode_socket_config config{ };
|
||||
bool address_configured { false };
|
||||
bool address_valid { false };
|
||||
genode_socket_wakeup *wakeup_remote { nullptr };
|
||||
genode_socket_config config{ };
|
||||
bool address_configured { false };
|
||||
bool address_valid { false };
|
||||
Constructible<Session_label> label { };
|
||||
};
|
||||
|
||||
|
||||
@ -801,3 +802,20 @@ void socket_update_link_state(void)
|
||||
else
|
||||
statics().address_configured = false;
|
||||
}
|
||||
|
||||
|
||||
void socket_label(char const *label)
|
||||
{
|
||||
if (statics().label.constructed()) return;
|
||||
|
||||
statics().label.construct(label);
|
||||
}
|
||||
|
||||
|
||||
char const *socket_nic_client_label()
|
||||
{
|
||||
if (statics().label.constructed())
|
||||
return statics().label->string();
|
||||
|
||||
return "";
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ struct Test::Client
|
||||
|
||||
Client(Env &env) : env(env)
|
||||
{
|
||||
genode_socket_init(genode_env_ptr(env), nullptr);
|
||||
genode_socket_init(genode_env_ptr(env), nullptr, "");
|
||||
|
||||
_wakeup.data = this;
|
||||
_wakeup.callback = _wakeup_remote;
|
||||
|
@ -81,7 +81,7 @@ struct Test::Server
|
||||
|
||||
Server(Env &env) : env(env)
|
||||
{
|
||||
genode_socket_init(genode_env_ptr(env), nullptr);
|
||||
genode_socket_init(genode_env_ptr(env), nullptr, "");
|
||||
|
||||
_wakeup.data = this;
|
||||
_wakeup.callback = _wakeup_remote;
|
||||
|
@ -24,7 +24,7 @@ struct genode_netif_handle;
|
||||
struct genode_socket_config;
|
||||
struct genode_socket_info;
|
||||
|
||||
struct genode_netif_handle *lwip_genode_netif_init(void);
|
||||
struct genode_netif_handle *lwip_genode_netif_init(char const *label);
|
||||
|
||||
void lwip_genode_netif_address(struct genode_netif_handle *handle,
|
||||
struct genode_socket_config *config);
|
||||
|
@ -193,7 +193,7 @@ static void nic_netif_status_callback(struct netif *netif)
|
||||
* public functions of this module
|
||||
*/
|
||||
|
||||
struct genode_netif_handle *lwip_genode_netif_init(void)
|
||||
struct genode_netif_handle *lwip_genode_netif_init(char const *label)
|
||||
{
|
||||
ip4_addr_t v4dummy;
|
||||
IP4_ADDR(&v4dummy, 0, 0, 0, 0);
|
||||
@ -215,7 +215,7 @@ struct genode_netif_handle *lwip_genode_netif_init(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handle->nic_handle = genode_nic_client_create("");
|
||||
handle->nic_handle = genode_nic_client_create(label);
|
||||
handle->netif = net;
|
||||
handle->address_valid = false;
|
||||
handle->address_configured = false;
|
||||
|
@ -89,7 +89,7 @@ struct Socket::Main
|
||||
statics().io_progress->callback(statics().io_progress->data);
|
||||
}
|
||||
|
||||
Main(Env &env) : _env(env)
|
||||
Main(Env &env, char const *label) : _env(env)
|
||||
{
|
||||
statics().heap = &_heap;
|
||||
|
||||
@ -101,7 +101,7 @@ struct Socket::Main
|
||||
Lwip::genode_init(_heap, _timer);
|
||||
|
||||
/* create lwIP-network interface */
|
||||
statics().netif_ptr = lwip_genode_netif_init();
|
||||
statics().netif_ptr = lwip_genode_netif_init(label);
|
||||
}
|
||||
|
||||
void handle_nic_client()
|
||||
@ -344,14 +344,15 @@ void genode_socket_wait_for_progress()
|
||||
|
||||
|
||||
void genode_socket_init(struct genode_env *_env,
|
||||
struct genode_socket_io_progress *io_progress)
|
||||
struct genode_socket_io_progress *io_progress,
|
||||
char const *label)
|
||||
{
|
||||
Genode::Env &env = *static_cast<Genode::Env *>(_env);
|
||||
|
||||
statics().env = &env;
|
||||
statics().io_progress = io_progress;
|
||||
|
||||
static Socket::Main main { env };
|
||||
static Socket::Main main { env, label };
|
||||
}
|
||||
|
||||
|
||||
|
@ -156,7 +156,8 @@ struct genode_socket_io_progress
|
||||
|
||||
|
||||
void genode_socket_init(struct genode_env *env,
|
||||
struct genode_socket_io_progress *);
|
||||
struct genode_socket_io_progress *,
|
||||
char const *label);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -1996,7 +1996,10 @@ struct Ip_factory : Vfs::File_system_factory
|
||||
io_progress.data = &env;
|
||||
io_progress.callback = socket_progress;
|
||||
|
||||
genode_socket_init(genode_env_ptr(env.env()), &io_progress);
|
||||
using Label = Genode::String<Genode::Session_label::capacity()>;
|
||||
|
||||
genode_socket_init(genode_env_ptr(env.env()), &io_progress,
|
||||
config.attribute_value("label", Label("")).string());
|
||||
|
||||
return new (env.alloc()) Vfs::Ip_file_system(env, config);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user