A Standard for C64 TCP/IP Configuration

Rationale

As Ethernet and TCP/IP based applications for the C64 have appeared, a standardized method of configuring them would be beneficial to both users and developers.

Benefits for users

Configure once
The user only has to configure the connection once, not once for every application that he/she wishes to use.
Familiar interface
The configuration can be created using a standardized program using a standardized interface, making it easier to write documentation and guide new users.
Easier debugging
With known good configuration tools, it's easier to separate configuration errors from application bugs.

Benefits for developers

Existing tools
Developers don't have to write their own configuration tools, they can use existing ones.
Easier debugging
Known good code can be used as a reference when tracking down bugs.

Goals

Simplicity
The application programmer should be able to use the configuration file with as little code as possible.
Extensibility
As every need can't be predicted, the format must be extensible.

Format Specification

The configuration file is a binary PRG file. It starts with a magic 2-byte header, and then a section of data chunks. A data chunk has a type, a length, and optional data. The first six chunks are mandatory and must come in the specified order. The last chunk in the file should have the type set to zero, to signal end of file. Other chunks are optional, and may come in any order, as long as they come after the first six chunks, and before the end of file chunk. The maximum size of the configuration file is 254 bytes, or 1 disk block.

File name

The default configuration file should be named "ipconfig-default". Additional configuration files should start with "ipconfig-".

Magic file header

The configuration file starts with the byte pair $ec, $64.

Data chunks

Data chunks start with a type byte, followed by a length byte, and optional chunk data. The length includes the type byte and the length byte itself.

Chunk types

Mandatory Chunks
Type Length Data Description
0 N/A End of file
1 4 2-byte driver code The driver to use (driver class, product ID)
2 8 6-byte MAC address The MAC adress used for the ethernet card
3 6 4-byte address The IP address
4 6 4-byte address IP netmask
5 6 4-byte address Default gateway IP
6 6 4-byte address Primary DNS server
Optional Chunks
Type Length Data Description
7 6 4-byte address Secondary DNS server
8 4 2-byte speed code Line speed, values are driver specific
9 2 + N N bytes PETSCII Configuration name, in PETSCII
10 2 Use dynamic configuration (e.g. DHCP or PPP), overriding provided data
11 2 + N N bytes PETSCII phone number Phone number for dialup connections
Application chunks
Type Length Data Description
128 6 4-byte PETSCII ID Application ID
129-255 Application specific data

Network drivers

RS-232 interfaces
Class ID Product
$01 $01 User port
$01 $02 Swiftlink
$01 $03 Turbo232
$01 $04 Silver Surfer
$01 $05 DUART
Ethernet cards
Class ID Product
$02 $01 TFE
$02 $02 RR-Net
$02 $03 ETH64

Application chunks

Chunk types 128-255 are reserved for application specific use. If they are used, chunk 128 should be present and appear before any other application chunks.

Sample config files

Minimal config file, providing only the mandatory fields:

	.byte $ec, $64				; Magic ID
	.byte 1, 4, $02, $02			; RR-Net
	.byte 2, 8, $0c, $64, "P", "O", 74, 04	; MAC address
	.byte 3, 6, 192, 168, 0, 64		; IP address
	.byte 4, 6, 255, 255, 255, 0		; Netmask
	.byte 5, 6, 192, 168, 0, 1		; Gateway
	.byte 6, 6, 192, 168, 0, 1		; Primary DNS
	.byte 0					; EOF

DHCP configuration, using the RR-Net driver:

	.byte $ec, $64				; Magic ID
	.byte 1, 4, $02, $02			; RR-Net
	.byte 2, 8, $0c, $64, "P", "O", 74, 04	; MAC address
	.byte 3, 6, 0, 0, 0, 0			; IP address
	.byte 4, 6, 0, 0, 0, 0			; Netmask
	.byte 5, 6, 0, 0, 0, 0			; Gateway
	.byte 6, 6, 0, 0, 0, 0			; Primary DNS
	.byte 10, 2				; DHCP
	.byte 9, 6, "DHCP"			; Profile called "DHCP"
	.byte 0					; EOF

PPP dialup using Turbo232:

	.byte $ec, $64				; Magic ID
	.byte 1, 4, $01, $03			; Turbo232
	.byte 2, 8, 0, 0, 0, 0, 0, 0		; MAC address
	.byte 3, 6, 0, 0, 0, 0			; IP address
	.byte 4, 6, 0, 0, 0, 0			; Netmask
	.byte 5, 6, 0, 0, 0, 0			; Gateway
	.byte 6, 6, 0, 0, 0, 0			; Primary DNS
	.byte 10, 2				; Dynamic address
	.byte 11, 11, "020795611"		; Phone number
	.byte 9, 7, "Felia"			; Profile called "Felia"
	.byte 0					; EOF

Implementation Notes

As the first six chunks are mandatory, a quick and dirty implementation could just load the config file into memory. If you load the config file at $cf00, the MAC address would be at $cf06, the IP address at $cf0e, and so on. For some applications (like RR-Net transfer tools) this is preferable over having to write a full config parser for a bunch of options that the application doesn't support.

Changes

2004-03-03
First version.
2004-03-05
Made driver code the first mandatory chunk.

Feedback

Please let me know if you have any comments, changes, or additions.