Sethwaddr

From Spectrum
(Redirected from Gethwaddr)
Jump to navigation Jump to search

sethwaddr (IXCALL 0x3E51) - set the MAC address

gethwaddr (HLCALL 0x3E54) - get the MAC address

Synopsis

Assembly language

    ld hl, hw_addr      ; location in memory of 6 byte MAC address
    ld ix, SETHWADDR
    call IXCALL
    jr c, .error
    ld de, hw_addr      ; location in memory of a 6 byte buffer to store MAC address
    ld hl, GETHWADDR
    call HLCALL

C

    #include <spectranet.h>

    /* hw_addr points to a 6 byte buffer */
    int sethwaddr(char *hw_addr);
    void gethwaddr(char *hw_addr);

Description

The sethwaddr and gethwaddr routines set the hardware (MAC) address and retrieve the hardware address respectively. For sethwaddr, the parameter hw_addr points to a 6 byte array containing a valid 6 byte MAC address. For gethwaddr, the parameter hw_addr points to 6 bytes of storage where the current MAC address will be returned.

The sethwaddr() function checks that the hardware address was successfully set. The function makes an immediate change to the hardware address, but does not make a permanent change; permanent changes must be written to the configuration area in flash.

Return values

The C function sethwaddr() returns -1 if the hardware address was not successfully set, and 0 if the address was set.

The assembly language routine returns with the carry flag set on error, and the carry flag reset on success.