lxip: network reconfiguration support
This commit is contained in:
parent
aa602032dd
commit
a1453d83ff
|
@ -34,12 +34,18 @@ namespace Lxip {
|
||||||
/**
|
/**
|
||||||
* Init backend
|
* Init backend
|
||||||
*
|
*
|
||||||
* \param address_config for dynamic configuration use "dhcp", for static
|
* \param ip_addr_str IP address
|
||||||
* configuration use "<ip>::<gw-ip>:<netmask>:::off"
|
* \param netmask_str Netmask
|
||||||
|
* \param gateway_str Gateway
|
||||||
|
* \param nameserver_str Nameserver
|
||||||
*
|
*
|
||||||
* \return Reference to Socketcall object
|
* \return Reference to Socketcall object
|
||||||
*/
|
*/
|
||||||
Socketcall & init(Genode::Env &env, char const *address_config);
|
Socketcall & init(Genode::Env &env,
|
||||||
|
char const *ip_addr_str,
|
||||||
|
char const *netmask_str,
|
||||||
|
char const *gateway_str,
|
||||||
|
char const *nameserver_str);
|
||||||
|
|
||||||
typedef Genode::uint8_t uint8_t;
|
typedef Genode::uint8_t uint8_t;
|
||||||
typedef Genode::uint16_t uint16_t;
|
typedef Genode::uint16_t uint16_t;
|
||||||
|
|
|
@ -83,8 +83,13 @@ struct Plugin : Libc::Plugin
|
||||||
Genode::Heap heap;
|
Genode::Heap heap;
|
||||||
Lxip::Socketcall &socketcall;
|
Lxip::Socketcall &socketcall;
|
||||||
|
|
||||||
Socketcall(Genode::Env &env, char const *address_config)
|
Socketcall(Genode::Env &env,
|
||||||
: heap(env.ram(), env.rm()), socketcall(Lxip::init(env, address_config))
|
char const *ip_addr_str,
|
||||||
|
char const *netmask_str,
|
||||||
|
char const *gateway_str)
|
||||||
|
: heap(env.ram(), env.rm()),
|
||||||
|
socketcall(Lxip::init(env, ip_addr_str, netmask_str,
|
||||||
|
gateway_str, gateway_str))
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -174,7 +179,6 @@ void Plugin::init(Genode::Env &env)
|
||||||
char netmask_str[16] = {0};
|
char netmask_str[16] = {0};
|
||||||
char gateway_str[16] = {0};
|
char gateway_str[16] = {0};
|
||||||
char address_buf[128];
|
char address_buf[128];
|
||||||
char const *address_config;
|
|
||||||
|
|
||||||
Genode::Attached_rom_dataspace config { env, "config"} ;
|
Genode::Attached_rom_dataspace config { env, "config"} ;
|
||||||
|
|
||||||
|
@ -214,18 +218,12 @@ void Plugin::init(Genode::Env &env)
|
||||||
"ip_addr=", Genode::Cstring(ip_addr_str), " "
|
"ip_addr=", Genode::Cstring(ip_addr_str), " "
|
||||||
"netmask=", Genode::Cstring(netmask_str), " "
|
"netmask=", Genode::Cstring(netmask_str), " "
|
||||||
"gateway=", Genode::Cstring(gateway_str));
|
"gateway=", Genode::Cstring(gateway_str));
|
||||||
|
|
||||||
Genode::snprintf(address_buf, sizeof(address_buf), "%s::%s:%s:::off",
|
|
||||||
ip_addr_str, gateway_str, netmask_str);
|
|
||||||
address_config = address_buf;
|
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
Genode::log("Using DHCP for interface configuration.");
|
Genode::log("Using DHCP for interface configuration.");
|
||||||
address_config = "dhcp";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Genode::log("Plugin::init() address config=", address_config);
|
socketconstruct.construct(env, ip_addr_str, netmask_str, gateway_str);
|
||||||
socketconstruct.construct(env, address_config);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* TODO shameful copied from lwip... generalize this */
|
/* TODO shameful copied from lwip... generalize this */
|
||||||
|
|
|
@ -40,7 +40,12 @@ namespace Lx {
|
||||||
void lxcc_emul_init(Lx_kit::Env &env);
|
void lxcc_emul_init(Lx_kit::Env &env);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int lxip_init(char const *address_config);
|
extern "C" void lxip_init();
|
||||||
|
|
||||||
|
extern "C" void lxip_configure_static(char const *addr,
|
||||||
|
char const *netmask,
|
||||||
|
char const *gateway,
|
||||||
|
char const *nameserver);
|
||||||
|
extern "C" void lxip_configure_dhcp();
|
||||||
|
|
||||||
#endif /* _LX_H_ */
|
#endif /* _LX_H_ */
|
||||||
|
|
|
@ -480,14 +480,11 @@ void late_tcp_congestion_default(void);
|
||||||
/**
|
/**
|
||||||
* Initialize sub-systems
|
* Initialize sub-systems
|
||||||
*/
|
*/
|
||||||
int lxip_init(char const *address_config)
|
void lxip_init()
|
||||||
{
|
{
|
||||||
/* init data */
|
/* init data */
|
||||||
INIT_LIST_HEAD(&init_net.dev_base_head);
|
INIT_LIST_HEAD(&init_net.dev_base_head);
|
||||||
|
|
||||||
/* call __setup stuff */
|
|
||||||
__ip_auto_config_setup((char *)address_config);
|
|
||||||
|
|
||||||
core_sock_init();
|
core_sock_init();
|
||||||
core_netlink_proto_init();
|
core_netlink_proto_init();
|
||||||
|
|
||||||
|
@ -506,14 +503,13 @@ int lxip_init(char const *address_config)
|
||||||
|
|
||||||
/* late */
|
/* late */
|
||||||
late_tcp_congestion_default();
|
late_tcp_congestion_default();
|
||||||
|
|
||||||
/* dhcp or static configuration */
|
|
||||||
late_ip_auto_config();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Network configuration
|
||||||
|
*/
|
||||||
|
|
||||||
static void lxip_configure(char const *address_config)
|
static void lxip_configure(char const *address_config)
|
||||||
{
|
{
|
||||||
__ip_auto_config_setup((char *)address_config);
|
__ip_auto_config_setup((char *)address_config);
|
||||||
|
|
|
@ -617,7 +617,11 @@ class Net::Socketcall : public Lxip::Socketcall,
|
||||||
|
|
||||||
static void ticker() { }
|
static void ticker() { }
|
||||||
|
|
||||||
Lxip::Socketcall & Lxip::init(Genode::Env &env, char const *address_config)
|
Lxip::Socketcall & Lxip::init(Genode::Env &env,
|
||||||
|
char const *ip_addr_str,
|
||||||
|
char const *netmask_str,
|
||||||
|
char const *gateway_str,
|
||||||
|
char const *nameserver_str)
|
||||||
{
|
{
|
||||||
Lx_kit::Env &lx_env = Lx_kit::construct_env(env);
|
Lx_kit::Env &lx_env = Lx_kit::construct_env(env);
|
||||||
|
|
||||||
|
@ -628,7 +632,15 @@ Lxip::Socketcall & Lxip::init(Genode::Env &env, char const *address_config)
|
||||||
Lx::nic_client_init(env, socketcall, lx_env.heap(), ticker);
|
Lx::nic_client_init(env, socketcall, lx_env.heap(), ticker);
|
||||||
Lx::lxcc_emul_init(lx_env);
|
Lx::lxcc_emul_init(lx_env);
|
||||||
|
|
||||||
lxip_init(address_config);
|
lxip_init();
|
||||||
|
|
||||||
|
if ((!ip_addr_str || (ip_addr_str[0] == 0)) ||
|
||||||
|
(!netmask_str || (netmask_str[0] == 0)) ||
|
||||||
|
(!gateway_str || (gateway_str[0] == 0)) ||
|
||||||
|
(!nameserver_str || (nameserver_str[0] == 0)))
|
||||||
|
lxip_configure_dhcp();
|
||||||
|
else
|
||||||
|
lxip_configure_static(ip_addr_str, netmask_str, gateway_str, nameserver_str);
|
||||||
|
|
||||||
return socketcall;
|
return socketcall;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user