ii / iigadget

linux gadget supporting iiflashing, hid, net, and disk
GNU General Public License v2.0
0 stars 0 forks source link

dhcp server AND client at the same time #3

Open hh opened 9 years ago

hh commented 9 years ago

I wonder if it's possible to use dhcpclient and dhcpserver on same interface.

Since it's USB (only one other host), doing both should be feasible. (in case it's our internet connection, or in case they don't know they can share and we need them to reach our 1.1.1.1 address)

(internet sharing from host to iigagdet) (iigadget supporting plug and play)

hh commented 9 years ago

http://www.linux-usb.org/gadget/

# manufacturing assigns Ethernet addresses; company id is xx:xx:xx
setenv eth_a_host    xx:xx:xx:01:23:45
setenv eth_a_gadget  xx:xx:xx:67:89:ac
setenv eth_i_vendor  "Great Stuff, LLC"
setenv eth_i_product "Our Cool Thing"
setenv eth_args             g_ether.host_addr=\$(eth_a_host)
setenv eth_args $(eth_args) g_ether.dev_addr=\$(eth_a_gadget)
setenv eth_args $(eth_args) g_ether.iManufacturer=\$(eth_i_vendor)
setenv eth_args $(eth_args) g_ether.iProduct=\$(eth_i_product)
# you can assign USB vendor/product/version codes too...
setenv add_eth_args setenv bootargs $(eth_args) \$(bootargs)
...
setenv bootcmd run add_eth_args\;bootm

For production devices, maybe look into http://standards.ieee.org/faqs/regauth.html

hh commented 9 years ago

http://www.electronic-products-design.com/resources/customer-guides/manufacturing/obtaining-mac-addresses-for-product-with-an-ethernet-interface

Look like the smallest block of mac addresses is $550 for 4096, and then $1650/16777214

hh commented 9 years ago

Unique hostname on boot:

https://github.com/jimmyken793/boot-scripts/commit/ebe2880a580eb3f099dc197e01617146d421e106

    if [ `cat /etc/hostname` = arm ] ; then
        hostname=ky-controller-$(hexdump -v -e '1/1 "%02X" ' /proc/device-tree/ocp/ethernet@4a100000/slave@4a100200/mac-address)
        echo $hostname > /etc/hostname 
        hostname $hostname
        echo -e "127.0.0.1\t$hostname" |sudo tee -a /etc/hosts
    fi