Add more constants for various static configuration items
This commit is contained in:
parent
54499f0135
commit
2fb4067da9
2 changed files with 18 additions and 8 deletions
|
|
@ -33,6 +33,9 @@ constexpr const char *assignment_static{"STATIC"};
|
||||||
constexpr const char *assignment_dhcp{"DHCP"};
|
constexpr const char *assignment_dhcp{"DHCP"};
|
||||||
constexpr const char *assignment_unknown{"UNKNOWN"};
|
constexpr const char *assignment_unknown{"UNKNOWN"};
|
||||||
|
|
||||||
|
constexpr const std::uint32_t is_default_gateway{0};
|
||||||
|
constexpr const std::uint32_t gateway_is_present{1};
|
||||||
|
|
||||||
namespace aa = anbox::android;
|
namespace aa = anbox::android;
|
||||||
std::string assignment_to_string(const aa::IpConfigBuilder::Assignment &value) {
|
std::string assignment_to_string(const aa::IpConfigBuilder::Assignment &value) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
|
|
@ -54,6 +57,9 @@ namespace android {
|
||||||
std::size_t IpConfigBuilder::write(common::BinaryWriter &writer) {
|
std::size_t IpConfigBuilder::write(common::BinaryWriter &writer) {
|
||||||
writer.set_byte_order(common::BinaryWriter::Order::Big);
|
writer.set_byte_order(common::BinaryWriter::Order::Big);
|
||||||
|
|
||||||
|
// See http://androidxref.com/7.1.1_r6/xref/frameworks/base/services/core/java/com/android/server/net/IpConfigStore.java
|
||||||
|
// for more details on the binary file format used here.
|
||||||
|
|
||||||
writer.write_unsigned_long(static_cast<std::uint32_t>(version_));
|
writer.write_unsigned_long(static_cast<std::uint32_t>(version_));
|
||||||
|
|
||||||
writer.write_string_with_size(assignment_key);
|
writer.write_string_with_size(assignment_key);
|
||||||
|
|
@ -64,8 +70,8 @@ std::size_t IpConfigBuilder::write(common::BinaryWriter &writer) {
|
||||||
writer.write_unsigned_long(link_.prefix_length);
|
writer.write_unsigned_long(link_.prefix_length);
|
||||||
|
|
||||||
writer.write_string_with_size(gateway_key);
|
writer.write_string_with_size(gateway_key);
|
||||||
writer.write_unsigned_long(0);
|
writer.write_unsigned_long(is_default_gateway);
|
||||||
writer.write_unsigned_long(1);
|
writer.write_unsigned_long(gateway_is_present);
|
||||||
writer.write_string_with_size(gateway_);
|
writer.write_string_with_size(gateway_);
|
||||||
|
|
||||||
writer.write_string_with_size(dns_key);
|
writer.write_string_with_size(dns_key);
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,13 @@
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr const char *default_container_ip_address{"192.168.250.2"};
|
||||||
|
constexpr const std::uint32_t default_container_ip_prefix_length{24};
|
||||||
|
constexpr const char *default_host_ip_address{"192.168.250.1"};
|
||||||
|
constexpr const char *default_dns_server{"8.8.8.8"};
|
||||||
|
}
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace container {
|
namespace container {
|
||||||
LxcContainer::LxcContainer(bool privileged, const network::Credentials &creds)
|
LxcContainer::LxcContainer(bool privileged, const network::Credentials &creds)
|
||||||
|
|
@ -92,16 +99,13 @@ void LxcContainer::setup_network() {
|
||||||
// for the virtual ethernet interface LXC creates for us. This will be bridged
|
// for the virtual ethernet interface LXC creates for us. This will be bridged
|
||||||
// to the host and will allows us to have reliable network connectivity and
|
// to the host and will allows us to have reliable network connectivity and
|
||||||
// not depend on any other system service.
|
// not depend on any other system service.
|
||||||
//
|
|
||||||
// See http://androidxref.com/7.1.1_r6/xref/frameworks/base/core/java/android/net/IpConfiguration.java
|
|
||||||
// for more details of the IP configuration format used here.
|
|
||||||
|
|
||||||
android::IpConfigBuilder ip_conf;
|
android::IpConfigBuilder ip_conf;
|
||||||
ip_conf.set_version(android::IpConfigBuilder::Version::Version2);
|
ip_conf.set_version(android::IpConfigBuilder::Version::Version2);
|
||||||
ip_conf.set_assignment(android::IpConfigBuilder::Assignment::Static);
|
ip_conf.set_assignment(android::IpConfigBuilder::Assignment::Static);
|
||||||
ip_conf.set_link_address("192.168.250.2", 24);
|
ip_conf.set_link_address(default_container_ip_address, default_container_ip_prefix_length);
|
||||||
ip_conf.set_gateway("192.168.250.1");
|
ip_conf.set_gateway(default_host_ip_address);
|
||||||
ip_conf.set_dns_servers({"8.8.8.8"});
|
ip_conf.set_dns_servers({default_dns_server});
|
||||||
ip_conf.set_id(0);
|
ip_conf.set_id(0);
|
||||||
|
|
||||||
std::vector<std::uint8_t> buffer(512);
|
std::vector<std::uint8_t> buffer(512);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue