hosts file is one that maps IP addresses to hostnames.
Typically it is stored in a system directory and used to translate hostnames into IP addresses.
Cafe has no such support in production mode. Instead, during development, Cafe can read a
hosts file from SD card formatted with the FAT file system.
hosts file format is similar to other systems (UNIX, Windows, etc.) and provides similar functionality.
It is loaded from SD card when the system boots and all of the entries in the
hosts file are stored in the system.
When an application looks up an IP address/hostname using
first the system looks at the
hosts file database. If the IP address/hostname is found in the database, it
is returned without issuing a DNS request.
Normal DNS processing is performed if the corresponding entry is not found in the database.
hostsfile is loaded only at boot time. The settings cannot be changed while the system is running; a full system reboot is required to read a modified
hostsfile consumes system memory (not from an application's heap). Too many entries may affect the system behavior. The amount of memory consumed by
hostsentries can be verified from the log printed during system boot:
00:00:03:659: setting DRH system time to 20:51:11 00:00:03:660: sending DRC WOWL wake 00:00:03:669: NETCONF_HOSTS: Read hosts file 00:00:03:675: NETCONF_HOSTS: Loaded hosts file from SD card (allocated 7160 bytes for database). 00:00:03:725: ccr_admin_wowl_wake_drc() returned 0
The format of the Cafe
hosts file is almost same as other systems.
<ip_address> <host_name> [<alias>...]
|IP address||Hostname||Alias 1||Alias 2|
<alias>(es)) must be delimited by spaces or tabs. No spacing is allowed before
<alias>must be shorter than 128.
hostsfile, the first entry is used and any later ones are ignored.
#' character and end with the end of the same line.
# Copyright (C) 2013 Nintendo. All rights reserved. # # This is a hosts file sample for Cafe. # # [Description] # The format of each entry has to be like as below. # ip_address host_name [alias...] # Example: # 127.0.0.1 localhost LOCAL_HOST loopback # 192.168.0.1 default_gateway first_hop MYROUTER # # - Corresponding members need to be defined in the same line # - Each member (ip_address, host_name and alias) needs to be delimited by space # or tab (multiple spaces and tabs are allowed between each members) # - Characters which are followed by '#' symbol are treated as a comment # - Blank line is ignored # - Multiple aliases can be defined # - Each string length of host_name and aliases has to be less than 128 # - This feature is available only on DEBUG mode, not available on PROD mode # - Only UTF-8 is supported as a text encode (BOM is not supported) # - LF and CR+LF are supported as a line break # [Usage] # - Place this file in SD_CARD_ROOT/cafe/net/etc/ # - Insert the SD card to the SD card slot on Wii U before system boots # - Turn on Wii U and launch an application 127.0.0.1 local_host local_host_alias 192.168.0.1 default_gateway first_hop MYROUTER
hostsfile with a text editor and copy it to an SD card formatted as FAT.
/cafe/net/etc/; i.e., in the file
hostsfile is not found in the directory mentioned above, nothing is loaded.
hostsfile is invalid, nothing is loaded and an error message is printed on the console.
2014/08/08 Initial version.