⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fwwebdevice.c

📁 firewall PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 5 页
字号:
    else        fwWebIntHolder = 0;    if (ret == ERROR)       return ERROR;        return OK;    }/******************************************************************************* * fwWebSrcPortEndDisplaySet - Set the source end port of a rule entry.*** RETURNS: OK if success, or ERROR if not */STATUS fwWebSrcPortEndDisplaySet(void)    {    DBG_PRINT(("Set fwWebSrcPortEndDisplaySet \n "));    if( pfwWebRule != NULL)        {        switch (pfwWebRule->proto)            {            /* The protocol may not be set yet !*/            case IPPROTO_TCP:            case IPPROTO_UDP:            case IPPROTO_ICMP:#ifdef INET6            case IPPROTO_ICMPV6: /*icmpv6*/#endif            case IPPROTO_IP:            case IPPROTO_MAX + 1:                pfwWebRule->tcp.srcPort.end = fwWebIntHolder;                pfwWebRule->udp.srcPort.end = fwWebIntHolder;                break;              default:                sprintf(fwWebTempError, " Unknown protocol type %d in srcPortEndDisplaySet!\n",pfwWebRule->proto);                fwWebErrorPrint(fwWebTempError);                return ERROR;                break;              }        }    return OK;    }/******************************************************************************* * fwWebSrcPortStartDisplayGet - Get the source start port of a rule entry  * to display on the webscreen editing/adding table*** RETURNS: OK if success, or ERROR if not */STATUS fwWebSrcPortStartDisplayGet(void)    {    int ret = fwWebRuleFieldGet(FW_FIELD_PROTO,FWWEB_DISPLAY_INDEX,                       (void *)&pfwWebRule->proto,"fwWebSrcPortEndDisplayGet");    if (ret == OK)        switch (pfwWebRule->proto)            {            case IPPROTO_TCP:                if (fwWebRuleFieldGet(FW_FIELD_TCP,FWWEB_DISPLAY_INDEX,(void *)&pfwWebRule->tcp,"fwWebSrcPortStartDisplayGet") == ERROR)                    {                    fwWebErrorPrint (" fwRuleGet failed in fwWebSrcPortStartDisplayGet! \n");                    fwWebIntHolder = 0;                    return ERROR;                    }                fwWebIntHolder =pfwWebRule->tcp.srcPort.start;                break;               case IPPROTO_UDP:                if (fwWebRuleFieldGet(FW_FIELD_UDP,FWWEB_DISPLAY_INDEX,(void *)&pfwWebRule->udp,"fwWebSrcPortStartDisplayGet") == ERROR)                    {                    fwWebErrorPrint (" fwRuleGet failed in fwWebSrcPortStartDisplayGet! \n");                    fwWebIntHolder = 0;                    return ERROR;                    }                fwWebIntHolder = pfwWebRule->udp.srcPort.start;                break;              case IPPROTO_ICMP:#ifdef INET6            case IPPROTO_ICMPV6: /*icmpv6*/#endif                fwWebIntHolder = 0;                break;              case IPPROTO_IP:                fwWebIntHolder = 0;                break;              default:                fwWebIntHolder = 0;                sprintf(fwWebTempError, " Unknown protocol type %d in srcPortStartDisplayGet!\n",pfwWebRule->proto);                fwWebErrorPrint(fwWebTempError);                return ERROR;                break;              }    else        fwWebIntHolder = 0;    if (ret == ERROR)       return ERROR;        return OK;    }/******************************************************************************* * fwWebSrcPortStartDisplaySet - Set the source start port of a rule entry.*** RETURNS: OK if success, or ERROR if not */STATUS fwWebSrcPortStartDisplaySet(void)    {    DBG_PRINT(("Set fwWebSrcPortStartDisplaySet \n "));    if( pfwWebRule != NULL)        {        switch (pfwWebRule->proto)            {            /* The protocol may not be set yet !*/            case IPPROTO_TCP:            case IPPROTO_UDP:            case IPPROTO_ICMP:#ifdef INET6            case IPPROTO_ICMPV6: /*icmpv6*/#endif            case IPPROTO_IP:            case IPPROTO_MAX + 1:                pfwWebRule->udp.srcPort.start = fwWebIntHolder;                pfwWebRule->tcp.srcPort.start = fwWebIntHolder;                break;              default:                sprintf(fwWebTempError, " Unknown protocol type %d in srcPortStartDisplaySet!\n",pfwWebRule->proto);                fwWebErrorPrint(fwWebTempError);                return ERROR;                break;              }        }    return OK;    }/******************************************************************************* * fwWebProtoGet - Get the protocol type of a rule entry to display on * the webscreen incoming or outgoing table*** RETURNS: OK if success, or ERROR if not */STATUS fwWebProtoGet(void)    {    if (fwWebTotalEntry <= 0)        return OK;    if( fwWebRuleFieldGet(FW_FIELD_PROTO, FWWEB_MOVE_INDEX, (void *)&pfwWebRule->proto, "fwWebProtoGet") == OK)        switch (pfwWebRule->proto)            {            case IPPROTO_TCP:                strcpy(fwWebStringHolder, "TCP");                break;               case IPPROTO_UDP:                strcpy(fwWebStringHolder, "UDP");                break;              case IPPROTO_ICMP:                strcpy(fwWebStringHolder, "ICMP");                break;  #ifdef INET6            case IPPROTO_ICMPV6: /*icmpv6*/                strcpy(fwWebStringHolder, "ICMPV6");                break;  #endif            case IPPROTO_IP:                strcpy(fwWebStringHolder, "Any");                break;              default:                strcpy(fwWebStringHolder, "unknown");                sprintf(fwWebTempError, " Unknown protocol type %d in protoGet!\n",pfwWebRule->proto);                fwWebErrorPrint(fwWebTempError);                return ERROR;                break;              }    else        {        strcpy(fwWebStringHolder, "unknown");        return ERROR;        }    return OK;    }/******************************************************************************* * fwWebProtoDisplayGet - Get the protocol type of a rule entry  * to display on the webscreen editing/adding table*** RETURNS: OK if success, or ERROR if not */STATUS fwWebProtoDisplayGet(void)    {    int ret = fwWebRuleFieldGet(FW_FIELD_PROTO,FWWEB_DISPLAY_INDEX,                       (void *)&pfwWebRule->proto,"fwWebProtoDisplayGet");    if (ret == OK)        switch (pfwWebRule->proto)            {            case IPPROTO_TCP:                strcpy(fwWebStringHolder, "TCP");                break;              case IPPROTO_UDP:                strcpy(fwWebStringHolder, "UDP");                break;              case IPPROTO_ICMP:                strcpy(fwWebStringHolder, "ICMP");                break;  #ifdef INET6            case IPPROTO_ICMPV6:                strcpy(fwWebStringHolder, "ICMPV6");                break;  #endif            case IPPROTO_IP:                strcpy(fwWebStringHolder, "Any");                break;              default:                strcpy(fwWebStringHolder, "unknown");                sprintf(fwWebTempError, " Unknown protocol type %d in protoDisplayGet!\n",pfwWebRule->proto);                fwWebErrorPrint(fwWebTempError);                return ERROR;                break;              }    else        strcpy(fwWebStringHolder, "unknown");    if (ret == ERROR)       return ERROR;        return OK;    }/******************************************************************************* * fwWebProtoDisplaySet - Set the protocol of a rule entry.*** RETURNS: OK if success, or ERROR if not */STATUS fwWebProtoDisplaySet(void)    {    DBG_PRINT(("Set fwWebProtoDisplaySet %s \n ", fwWebStringHolder));    if( pfwWebRule != NULL)        {        if (strcmp (fwWebStringHolder, "tcp") == 0 || strcmp (fwWebStringHolder, "TCP") == 0 )            pfwWebRule->proto = IPPROTO_TCP;        else if (strcmp (fwWebStringHolder, "udp") == 0 || strcmp (fwWebStringHolder, "UDP") == 0 )            pfwWebRule->proto = IPPROTO_UDP;        else if (strcmp (fwWebStringHolder, "icmp") == 0 || strcmp (fwWebStringHolder, "ICMP") == 0 )            {            pfwWebRule->proto = IPPROTO_ICMP;            pfwWebRule->icmp.type = FW_INVALID_ICMP_TYPE;            }#ifdef INET6        else if (strcmp (fwWebStringHolder, "icmpv6") == 0 || strcmp (fwWebStringHolder, "ICMPV6") == 0 )            {            pfwWebRule->proto = IPPROTO_ICMPV6;            pfwWebRule->icmp.type = FW_INVALID_ICMP_TYPE;            }#endif        else            pfwWebRule->proto = IPPROTO_IP;        }    /* Note, this must be set in edit/add */    fwWebSetGetCalled = 1;    DBG_PRINT(("Set fwWebProtoDisplaySet result %d \n ", pfwWebRule->proto));    return OK;    }/******************************************************************************* * fwWebTimeOfDayGet - Get the time of day of a rule entry to display on * the webscreen incoming or outgoing table*** RETURNS: OK if success, or ERROR if not */STATUS fwWebTimeOfDayGet(void)    {    int hours, minutes, seconds, start, end, days;    if (fwWebTotalEntry <= 0)        return OK;    if( fwWebRuleFieldGet(FW_FIELD_TIME, FWWEB_MOVE_INDEX, (void *)&pfwWebRule->timeOfDay, "fwWebTimeOfDayGet") == OK)        {        if( pfwWebRule->timeOfDay.days == 0x0 )            {            strcpy(fwWebStringHolder, "Any time of day");            return OK;            }                 start = pfwWebRule->timeOfDay.secStart % (24*3600);        end = pfwWebRule->timeOfDay.secEnd % (24*3600);        days = pfwWebRule->timeOfDay.days % 128;        fwWebStringHolder[0] = 0;        fwWebTmpString1[0] = 0;        fwWebTmpString2[0] = 0;        DBG_PRINT(("days =%d", days));        if( pfwWebRule->timeOfDay.days == FW_DAY_ALL )            {            strcpy(fwWebStringHolder, "Everyday");            }        else            {            if ( days & FW_DAY_SUN )                strcat(fwWebStringHolder, "Sun ");            if ( days & FW_DAY_MON)                strcat(fwWebStringHolder, "Mon ");            if ( days & FW_DAY_TUE )                strcat(fwWebStringHolder, "Tue ");            if ( days & FW_DAY_WED )                strcat(fwWebStringHolder, "Wed ");            if ( days & FW_DAY_THU )                strcat(fwWebStringHolder, "Thu ");            if ( days & FW_DAY_FRI )                strcat(fwWebStringHolder, "Fri ");            if ( days & FW_DAY_SAT )                strcat(fwWebStringHolder, "Sat ");            }        DBG_PRINT((" start =%d, end = %d \n", start, end ));        if( pfwWebRule->timeOfDay.secEnd == 0x0 && pfwWebRule->timeOfDay.secEnd == 0x0  )            {            strcpy(fwWebTmpString2, "Anytime in the day");            }        else            {            seconds = (start % 3600) % 60;            minutes =((start - seconds ) % 3600)/60;            hours = (start - seconds - ( minutes * 60) )/3600;            DBG_PRINT(("start hours =%2d, minutes = %2d  seconds = %2d \n", hours, minutes, seconds ));            sprintf (fwWebTmpString1, "%2d:%2d:%2d", hours, minutes, seconds);            seconds = (end % 3600) % 60;            minutes =((end - seconds ) % 3600)/60;            hours = (end - seconds - ( minutes * 60) )/3600;             DBG_PRINT(("end hours =%2d, minutes = %2d  seconds = %2d \n", hours, minutes, seconds ));            sprintf (fwWebTmpString2, "  %s - %2d:%2d:%2d", fwWebTmpString1, hours, minutes, seconds);            }        strcat(fwWebStringHolder, fwWebTmpString2);        }    else        {        strcpy(fwWebStringHolder, "unknown");        return ERROR;        }    return OK;    }/******************************************************************************* * fwWebNotAnytimeSet - Set the not any time choice of a rule entry.*** RETURNS: OK if success, or ERROR if not */STATUS fwWebNotAnytimeSet(void)    {    DBG_PRINT(("Set fwWebNotAnytimeSet \n "));    if( pfwWebRule != NULL)        {        if (fwWebNotAnytime == 0 )            {/*            pfwWebRule->timeOfDay.days = FW_DAY_ALL;*/            pfwWebRule->timeOfDay.days = 0x0;            pfwWebRule->timeOfDay.secStart = 0;/*            pfwWebRule->timeOfDay.secEnd = 23*3600 + 59*60 + 59;*/            /* all zero means anytime of the day */            pfwWebRule->timeOfDay.secEnd = 0;            }        }    return OK;    }/******************************************************************************* * fwWebNotAnydaySet - Set the not any day choice of a rule entry.*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -