r1 - 26 Jan 2010 - 14:07:31 - SatoshiKonnoYou are here: TWiki >  Main Web > MiscHome > KuroBox

KuroBox

KuroBox is a network attached storage device based on Linux and PowerPC by Melco in Japan. I used the Linux box as internal servers such as subversion repository in my home from 2004 to 2009.

kuro-box.jpg
CPU PowerPC 200MHz
RAM 64MB
Flash ROM 4MB
HDD IF Parallel ATA
LAN 100BASE-TX
USB TypeA x 1
Size 60x173.5x185mm
Kernel Linux 2.4.17
Distribution  

Porting CyberLinkForCC to KuroBox

STL

To compile CyberLinkForCC, I changed the Vector::get() not to use stl::vector::at() as the following because the old gcc compiler, v2.95.3, doesn't support the method. I had to add some headers such as <stdio.h> and to compile normally.

void *Vector::get(int index)
{
    if (index < 0)
        return NULL;
    if ((int)size() < (index+1))
        return NULL;
    //return (void *)at(index);
    return (void *)((*this)[index]);
}

net-tools

The Linux box has no <ifaddrs.h> to get the local host interfaces. Then, I have to create the same function using ioctl based on the ifconfig source codes as the following. The latest package, v1.60, uses some GNU original functions such as getdelim(), and I checked the v1.46. static const char *PATH_PROC_NET_DEV = "/proc/net/dev";

int CyberNet::GetHostAddresses(NetworkInterfaceList &netfiList)
{
   netfiList.clear();
   int s = socket(AF_INET, SOCK_DGRAM, 0);
   if (s < 0)
      return 0;
   FILE *fd = fopen(PATH_PROC_NET_DEV, "r");
   char buffer[256+1];
   fgets(buffer, sizeof(buffer)-1, fd);
   fgets(buffer, sizeof(buffer)-1, fd);
   while (!feof(fd)) {
      char *ifname = buffer;
      char *sep;
      if (fgets(buffer, sizeof(buffer)-1, fd) == NULL)
         break;
      sep = strrchr(buffer, ':');
      if (sep)
         *sep = 0;
      while (*ifname == ' ')
         ifname++;
      struct ifreq req;
      strcpy(req.ifr_name, ifname);
      if (ioctl(s, SIOCGIFFLAGS, &req) < 0)
         continue;
      if (!(req.ifr_flags & IFF_UP))
         continue;
      if (req.ifr_flags & IFF_LOOPBACK)
         continue;
      if (ioctl(s, SIOCGIFADDR, &req) < 0)
         continue;
      char ifaddr[20+1];
      strncpy(ifaddr, inet_ntoa(((struct sockaddr_in*)&req.ifr_addr)->sin_addr), sizeof(ifaddr)-1);
      NetworkInterface *netIf = new NetworkInterface(ifaddr, ifname, 0);
      netfiList.add(netIf);
   }
   fclose(fd);
   close(s);
   return netfiList.size();
}
Topic attachments
I Attachment Action Size Date Who Comment
jpgjpg kuro-box.jpg manage 23.2 K 26 Jan 2010 - 13:41 SatoshiKonno  
Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r1 | More topic actions
 
Powered by TWiki

Copyright © 2010 by Satoshi Konno Powerd by twikiTWiki.