Exemple #1
0
static int _InitRouteTable(key_t uShmKey, int iCreateFlags)
{
    int ret = 0;
    size_t dwTableSize = 0;
    char *pTable = NULL;


    dwTableSize = sizeof(RouteTable) +  MAX_ENTRY_NUM * sizeof(RouteEntry);

    if((pTable = GetShm(uShmKey, dwTableSize, 0666)) == NULL)
    { 
        if(iCreateFlags == 0)
        {   
            printf("shm not existd.should create! shmkey = 0x%x\n", uShmKey);
            return -3; 
        }   
        else if(iCreateFlags == 1)
        {   
            if((ret = GetShm2((volatile void **)&pTable, uShmKey, dwTableSize, 0666 | IPC_CREAT)) < 0)
            {   
                printf("GetShm2 error. %s\n", strerror(errno));
                return -4; 
            }   
            printf("first GetShm2 error ret = %d but Second Ok.\n", ret);
            bzero((void *)pTable,dwTableSize);
        }   
        else 
        {   
            return -5; 
        }   
    }

    if((ret = RouteTableInit(&gstRouteTable, pTable))  < 0)
    {
        return -6;
    }

    return 0;
}
Exemple #2
0
void IPInit()
{
	RouteTableInit(route_tbl);
	MTUTableInit(MTU_tbl);
}