Mac2string

From Spectrum
Revision as of 19:01, 31 August 2008 by Winston (talk | contribs) (New page: '''mac2string (IXCALL 0x3E5A)''' - convert a 6 byte MAC address to a null terminated string '''string2mac (IXCALL 0x3E3D)''' - convert a null terminated string to a 6 byte MAC address ==...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

mac2string (IXCALL 0x3E5A) - convert a 6 byte MAC address to a null terminated string

string2mac (IXCALL 0x3E3D) - convert a null terminated string to a 6 byte MAC address

Synopsis

Assembly language

   ld hl, mac_addr
   ld de, mac_string
   ld ix, MAC2STRING
   call IXCALL

   ld hl, mac_string
   ld de, mac_addr
   ld ix, STRING2MAC
   call IXCALL
   jr c, .error

C

   #include <spectranet.h>

   void mac2string(char *msc_addr, char *mac_string);
   int string2mac(char *mac_string, char *mac_addr);

Description

The mac2string() and string2mac convert 6 byte MAC addresses to null terminated strings, and vice versa. The mac_addr parameter should be a 6 byte buffer containing a MAC address for mac2string, or 6 bytes of storage to receive the converted address for string2mac. The mac_string argument must be at least 19 bytes long to receive an 18 character null terminated string.

The string2mac() function takes, as valid input, a MAC address string as pairs of hexadecimal numbers separated by colons, as in the following example:

00:55:AA:12:7C:9E

The mac2string() function returns the string representation of the 6 byte MAC address in this format. The routine is case sensitive; letters forming a hex number must be in upper case.

Return values

The string2mac() C function returns 0 on success, or -1 if it can't parse the supplied string. The assembly language interface returns with carry reset on success, or carry set on error.