mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-16 14:18:27 +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:
committed by
Norman Feske
parent
a7bd01bd4a
commit
92086cce68
@ -89,11 +89,14 @@ struct Main
|
|||||||
|
|
||||||
|
|
||||||
void genode_socket_init(struct genode_env *_env,
|
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);
|
Env &env = *static_cast<Env *>(_env);
|
||||||
static Main main { env, io_progress };
|
static Main main { env, io_progress };
|
||||||
|
|
||||||
|
socket_label(label);
|
||||||
|
|
||||||
Lx_kit::initialize(env, main.schedule_handler);
|
Lx_kit::initialize(env, main.schedule_handler);
|
||||||
|
|
||||||
main.init();
|
main.init();
|
||||||
|
@ -202,7 +202,8 @@ static int __init virtio_net_driver_init(void)
|
|||||||
|
|
||||||
dev->netdev_ops = &net_ops;
|
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) {
|
if (!dev->ifalias) {
|
||||||
printk("Failed to create nic client\n");
|
printk("Failed to create nic client\n");
|
||||||
|
@ -29,6 +29,10 @@ extern "C" {
|
|||||||
void socket_config_address(void);
|
void socket_config_address(void);
|
||||||
void socket_unconfigure_address(void);
|
void socket_unconfigure_address(void);
|
||||||
void socket_update_link_state(void);
|
void socket_update_link_state(void);
|
||||||
|
|
||||||
|
void socket_label(char const *);
|
||||||
|
char const *socket_nic_client_label(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,6 +41,7 @@ struct Statics
|
|||||||
genode_socket_config config{ };
|
genode_socket_config config{ };
|
||||||
bool address_configured { false };
|
bool address_configured { false };
|
||||||
bool address_valid { false };
|
bool address_valid { false };
|
||||||
|
Constructible<Session_label> label { };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -801,3 +802,20 @@ void socket_update_link_state(void)
|
|||||||
else
|
else
|
||||||
statics().address_configured = false;
|
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)
|
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.data = this;
|
||||||
_wakeup.callback = _wakeup_remote;
|
_wakeup.callback = _wakeup_remote;
|
||||||
|
@ -81,7 +81,7 @@ struct Test::Server
|
|||||||
|
|
||||||
Server(Env &env) : env(env)
|
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.data = this;
|
||||||
_wakeup.callback = _wakeup_remote;
|
_wakeup.callback = _wakeup_remote;
|
||||||
|
@ -24,7 +24,7 @@ struct genode_netif_handle;
|
|||||||
struct genode_socket_config;
|
struct genode_socket_config;
|
||||||
struct genode_socket_info;
|
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,
|
void lwip_genode_netif_address(struct genode_netif_handle *handle,
|
||||||
struct genode_socket_config *config);
|
struct genode_socket_config *config);
|
||||||
|
@ -193,7 +193,7 @@ static void nic_netif_status_callback(struct netif *netif)
|
|||||||
* public functions of this module
|
* 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_t v4dummy;
|
||||||
IP4_ADDR(&v4dummy, 0, 0, 0, 0);
|
IP4_ADDR(&v4dummy, 0, 0, 0, 0);
|
||||||
@ -215,7 +215,7 @@ struct genode_netif_handle *lwip_genode_netif_init(void)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->nic_handle = genode_nic_client_create("");
|
handle->nic_handle = genode_nic_client_create(label);
|
||||||
handle->netif = net;
|
handle->netif = net;
|
||||||
handle->address_valid = false;
|
handle->address_valid = false;
|
||||||
handle->address_configured = false;
|
handle->address_configured = false;
|
||||||
|
@ -89,7 +89,7 @@ struct Socket::Main
|
|||||||
statics().io_progress->callback(statics().io_progress->data);
|
statics().io_progress->callback(statics().io_progress->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
Main(Env &env) : _env(env)
|
Main(Env &env, char const *label) : _env(env)
|
||||||
{
|
{
|
||||||
statics().heap = &_heap;
|
statics().heap = &_heap;
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ struct Socket::Main
|
|||||||
Lwip::genode_init(_heap, _timer);
|
Lwip::genode_init(_heap, _timer);
|
||||||
|
|
||||||
/* create lwIP-network interface */
|
/* create lwIP-network interface */
|
||||||
statics().netif_ptr = lwip_genode_netif_init();
|
statics().netif_ptr = lwip_genode_netif_init(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_nic_client()
|
void handle_nic_client()
|
||||||
@ -344,14 +344,15 @@ void genode_socket_wait_for_progress()
|
|||||||
|
|
||||||
|
|
||||||
void genode_socket_init(struct genode_env *_env,
|
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);
|
Genode::Env &env = *static_cast<Genode::Env *>(_env);
|
||||||
|
|
||||||
statics().env = &env;
|
statics().env = &env;
|
||||||
statics().io_progress = io_progress;
|
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,
|
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.data = &env;
|
||||||
io_progress.callback = socket_progress;
|
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);
|
return new (env.alloc()) Vfs::Ip_file_system(env, config);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user