migrating from 9.62 to 10.72 cannot find sethostid()

The function sethostid(), was removed from DC10.72 if you are trying to change the address at runtime you can do this with ifconfig(), see sample below:

This is an easy way to set the Network settings of a device using the
ifconfig() function and shows how to bounce the connection.

*******************************************************************************/

/*

  • The following macros define the network setup of the physical Ethernet
  • interface.
    */

#define LOCAL_IP1 β€œ192.168.1.197”
#define LOCAL_NETMASK β€œ255.255.255.0”
#define LOCAL_GATEWAY β€œ192.168.1.1”

#define LOCAL_IP2 β€œ192.168.1.198”

/*

  • USE_ETHERNET must be defined. This definition simply means that we are
  • using the first (and probably only) physical Ethernet interface.
    */
    #define USE_ETHERNET 0x01

/*

  • NOTE: Since we are setting up the network manually, we are
  • intentionally NOT using the TCP_CONFIG.LIB setup.
    */
    #define TCPCONFIG 0

#memmap xmem
#use β€œdcrtcp.lib”

void display_config(void)
{
auto longword ipaddr;
auto longword netmask;
auto longword gateway;
auto char addr_buffer[16];

ifconfig(IF_DEFAULT,
         IFG_IPADDR, &ipaddr,
         IFG_NETMASK, &netmask,
         IFG_ROUTER_DEFAULT, &gateway,
         IFS_END);
printf("Your current configuration is:

");
printf("IP Address: %s
", inet_ntoa(addr_buffer, ipaddr));
printf("Netmask : %s
", inet_ntoa(addr_buffer, netmask));
printf("Gateway : %s
", inet_ntoa(addr_buffer, gateway));
}

void main(void)
{
char Network_Up_Flag; //Flag used to reset the network
char IP_buffer[16];

strcpy(IP_buffer, LOCAL_IP1);

//Initialize the TCP/IP stack
sock_init();

//This primary loop handles setting and bouncing the network settings
while(1)
{
//Perform network configuration with second configuration
printf("Bringing up Main Interface
");
ifconfig(IF_ETH0,
IFS_IPADDR, aton(IP_buffer),
IFS_NETMASK, aton(LOCAL_NETMASK),
IFS_ROUTER_SET,aton(LOCAL_GATEWAY),
IFS_UP,
IFS_END);

  // Wait for the interface to come up
while (ifpending(IF_ETH0) == IF_COMING_UP) {
		tcp_tick(NULL);
	}
printf("Interface is up!!

");
Network_Up_Flag = 1;

  display_config();

  //This secondary loop is used to drive the stack and monitor the
  //network status. It provides an easy mechanism for bouncing the
  //connection.
while (Network_Up_Flag)
  {
	costate  //Drive the TCP stack
  	{
  		tcp_tick(NULL);
  	}

  	costate 	//This could be a test that determines the status of the network
  	{
        waitfor(DelayMs((1000)*10));		//bounce network after 10 sec delay
        Network_Up_Flag = 0;
        if (strcmp(LOCAL_IP1, IP_buffer) == 0)
        	strcpy(IP_buffer, LOCAL_IP2);
        else
        	strcpy(IP_buffer, LOCAL_IP1);
  	}
  }

        // Bring down the main Ethernet interface
printf("Bringing down Main Interface!!

");
ifconfig(IF_ETH0,
IFS_DOWN,
IFS_END);

  // Wait for the interface to come down
while (ifpending(IF_ETH0) != IF_DOWN) {
		tcp_tick(NULL);
	}
  printf("Interface is down!!

");
}
}

1 Like