示例#1
0
s32 SEQ_TERMINAL_PrintNetworkInfo(void *_output_function)
{
  void (*out)(char *format, ...) = _output_function;

  MUTEX_MIDIOUT_TAKE;

#if defined(MIOS32_FAMILY_EMULATION)
  out("No network informations available in emulation!");
#else

  out("MBHP_ETH module connected: %s", UIP_TASK_NetworkDeviceAvailable() ? "yes" : "no");
  if( !UIP_TASK_NetworkDeviceAvailable() ) {
    out("Please reboot your MIDIbox SEQ to restart module detection! (or just type \"reset\")");
  } else {
    out("Ethernet services running: %s", UIP_TASK_ServicesRunning() ? "yes" : "no");
    out("DHCP: %s", UIP_TASK_DHCP_EnableGet() ? "enabled" : "disabled");

    if( UIP_TASK_DHCP_EnableGet() && !UIP_TASK_ServicesRunning() ) {
      out("IP address: not available yet");
      out("Netmask: not available yet");
      out("Default Router (Gateway): not available yet");
    } else {
      uip_ipaddr_t ipaddr;
      uip_gethostaddr(&ipaddr);
      out("IP address: %d.%d.%d.%d",
	  uip_ipaddr1(ipaddr), uip_ipaddr2(ipaddr),
	  uip_ipaddr3(ipaddr), uip_ipaddr4(ipaddr));

      uip_ipaddr_t netmask;
      uip_getnetmask(&netmask);
      out("Netmask: %d.%d.%d.%d",
	  uip_ipaddr1(netmask), uip_ipaddr2(netmask),
	  uip_ipaddr3(netmask), uip_ipaddr4(netmask));

      uip_ipaddr_t draddr;
      uip_getdraddr(&draddr);
      out("Default Router (Gateway): %d.%d.%d.%d",
	  uip_ipaddr1(draddr), uip_ipaddr2(draddr),
	  uip_ipaddr3(draddr), uip_ipaddr4(draddr));
    }

    int con;
    for(con=0; con<OSC_SERVER_NUM_CONNECTIONS; ++con) {
      u32 osc_remote_ip = OSC_SERVER_RemoteIP_Get(con);
      out("OSC%d Remote address: %d.%d.%d.%d",
	  con+1,
	  (osc_remote_ip>>24)&0xff, (osc_remote_ip>>16)&0xff,
	  (osc_remote_ip>>8)&0xff, (osc_remote_ip>>0)&0xff);
      out("OSC%d Remote port: %d", con+1, OSC_SERVER_RemotePortGet(con));
      out("OSC%d Local port: %d", con+1, OSC_SERVER_LocalPortGet(con));
    }
  }
#endif
  MUTEX_MIDIOUT_GIVE;

  return 0; // no error
}
static void stringIp(u32 ix, u16 value, char *label)
{
  char buffer[16];

  // 3 items combined to a 15 char IP string
  if( UIP_TASK_DHCP_EnableGet() && !UIP_TASK_ServicesRunning() ) {
    sprintf(buffer, "???.???.???.???");
  } else {
    u32 ip = 0;
    switch( selectedIpPar ) {
    case 0: ip = UIP_TASK_IP_EffectiveAddressGet(); break;
    case 1: ip = UIP_TASK_EffectiveNetmaskGet(); break;
    case 2: ip = UIP_TASK_EffectiveGatewayGet(); break;
    }

    sprintf(buffer, "%3d.%3d.%3d.%3d",
	    (ip >> 24) & 0xff,
	    (ip >> 16) & 0xff,
	    (ip >>  8) & 0xff,
	    (ip >>  0) & 0xff);  
  }
  memcpy(label, (char *)&buffer[ix*SCS_MENU_ITEM_WIDTH], SCS_MENU_ITEM_WIDTH);
  label[SCS_MENU_ITEM_WIDTH] = 0;
}