Initializing network interface eth1

To initialize eth1, we can refer to the initialization of eth0 in the emulator. The network interface eth0 is initialized in the system/etc/init.goldfish.sh shell script as follows:

#!/system/bin/sh 

# Setup networking when boot starts
ifconfig eth0 10.0.2.15 netmask 255.255.255.0 up
route add default gw 10.0.2.2 dev eth0
...

As we can see, a fixed IP address 10.0.2.15 is assigned to the eth0 interface. We can add the following commands to initialize the interface eth1:

ifconfig eth1 up 
dhcpcd -d eth1

In the preceding commands, we enable the interface eth1 first using the ifconfig command. Then, instead of using a fixed IP address, we use the DHCP client to get the IP address for eth1.

As we discussed when covering the init process of Android in Chapter 6, Debugging the Boot Up Process Using a Customized ramdisk, the init process will process the init.rc script during the system startup. The init.rc script will include a hardware-specific init script, init.${ro.hardware}.rc. In our case, the ro.hardware is ranchu, so the hardware-specific init script is init.ranchu.rc.

In the init.ranchu.rc init script, a service, as shown in the following snippet, is defined to run the init.goldfish.sh shell script:

... 
service goldfish-setup /system/etc/init.goldfish.sh
user root
group root
oneshot
...

That's how the goldfish- or ranchu- related setup process is done in an emulator.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.243.18