📄 fwwebdevice.c
字号:
* RETURNS: OK if success, or ERROR if not */STATUS fwWebDstAddrGet(void) { if (fwWebTotalEntry <= 0) return OK;#ifdef INET6 if( fwWebDirection == FW_PREIN_LOC_V6 || fwWebDirection == FW_OUT_LOC_V6) { if (fwWebRuleFieldGet(FW_FIELD_IPADDR, FWWEB_MOVE_INDEX, (void *)&pfwWebRule->srcAddrV6, "fwWebDstAddrGet") == OK) { inet_ntop (AF_INET6, (void *) &(pfwWebRule->dstAddrV6.start), fwWebTmpString1, INET6_ADDRSTRLEN); inet_ntop (AF_INET6, (void *) &(pfwWebRule->dstAddrV6.end), fwWebTmpString2, INET6_ADDRSTRLEN); sprintf(fwWebStringHolder, "%s - %s", fwWebTmpString1, fwWebTmpString2); DBG_PRINT(("fwWebDstAddrGet: V6 %s\n",fwWebStringHolder)); } else { strcpy(fwWebStringHolder, emptyAddrRangeV6); return ERROR; } } else#endif { /* when v6 enabled, under prein and out, there are still v4 rules*/ if (fwWebRuleFieldGet(FW_FIELD_IPADDR, FWWEB_MOVE_INDEX, (void *)&pfwWebRule->srcAddr, "fwWebDstAddrGet") == OK) { HTONL(pfwWebRule->dstAddr.start.s_addr); HTONL(pfwWebRule->dstAddr.end.s_addr); inet_ntop (AF_INET, (void *) &(pfwWebRule->dstAddr.start), fwWebTmpString1, INET_ADDRSTRLEN); inet_ntop (AF_INET, (void *) &(pfwWebRule->dstAddr.end), fwWebTmpString2, INET_ADDRSTRLEN); sprintf(fwWebStringHolder, "%s - %s", fwWebTmpString1, fwWebTmpString2); DBG_PRINT(("fwWebDstAddrGet: %s\n",fwWebStringHolder)); } else { strcpy(fwWebStringHolder, emptyAddrRange); return ERROR; } } return OK; }/******************************************************************************* * fwWebSrcAddrGet - Get the source address range of a rule entry to display on * the webscreen incoming or outgoing table*** RETURNS: OK if success, or ERROR if not */STATUS fwWebSrcAddrGet(void) { if (fwWebTotalEntry <= 0) return OK;#ifdef INET6 if( fwWebDirection == FW_PREIN_LOC_V6 || fwWebDirection == FW_OUT_LOC_V6) { if (fwWebRuleFieldGet(FW_FIELD_IPADDR, FWWEB_MOVE_INDEX, (void *)&pfwWebRule->srcAddrV6, "fwWebSrcAddrGet") == OK) { inet_ntop (AF_INET6, (void *) &(pfwWebRule->srcAddrV6.start), fwWebTmpString1, INET6_ADDRSTRLEN); inet_ntop (AF_INET6, (void *) &(pfwWebRule->srcAddrV6.end), fwWebTmpString2, INET6_ADDRSTRLEN); sprintf(fwWebStringHolder, "%s - %s", fwWebTmpString1, fwWebTmpString2); DBG_PRINT(("fwWebSrcAddrGet: V6 %s\n",fwWebStringHolder)); } else { strcpy(fwWebStringHolder, emptyAddrRangeV6); return ERROR; } } else#endif { /* when v6 enabled, under prein and out, there are still v4 rules*/ if( fwWebRuleFieldGet(FW_FIELD_IPADDR, FWWEB_MOVE_INDEX, (void *)&pfwWebRule->srcAddr, "fwWebSrcAddrGet") == OK) { HTONL(pfwWebRule->srcAddr.start.s_addr); HTONL(pfwWebRule->srcAddr.end.s_addr); inet_ntop (AF_INET, (void *) &(pfwWebRule->srcAddr.start), fwWebTmpString1, INET_ADDRSTRLEN); inet_ntop (AF_INET, (void *) &(pfwWebRule->srcAddr.end), fwWebTmpString2, INET_ADDRSTRLEN); sprintf(fwWebStringHolder, "%s - %s", fwWebTmpString1, fwWebTmpString2); DBG_PRINT(("fwWebSrcAddrGet: %s\n",fwWebStringHolder)); } else { strcpy(fwWebStringHolder, emptyAddrRange); return ERROR; } } return OK; }/******************************************************************************* * fwWebDstAddrEndDisplayGet - Get the destination end address of a rule entry * to display on the webscreen editing/adding table*** RETURNS: OK if success, or ERROR if not */STATUS fwWebDstAddrEndDisplayGet(void) { int ret;#ifdef INET6 if( fwWebDirection == FW_PREIN_LOC_V6 || fwWebDirection == FW_OUT_LOC_V6) { ret = fwWebRuleFieldGet(FW_FIELD_IPADDR,FWWEB_DISPLAY_INDEX, (void *)&pfwWebRule->srcAddrV6,"fwWebDstAddrEndDisplayGet"); if (ret == OK) { inet_ntop (AF_INET6, (void *) &pfwWebRule->dstAddrV6.end, fwWebStringHolder, INET6_ADDRSTRLEN); } else strcpy(fwWebStringHolder, "0::0:0:0:0"); } else#endif { ret = fwWebRuleFieldGet(FW_FIELD_IPADDR,FWWEB_DISPLAY_INDEX, (void *)&pfwWebRule->srcAddr,"fwWebDstAddrEndDisplayGet"); if (ret == OK) { HTONL(pfwWebRule->dstAddr.end.s_addr); inet_ntop (AF_INET, (void *) &pfwWebRule->dstAddr.end, fwWebStringHolder, INET_ADDRSTRLEN); } else fwWebStringHolder[0]=0; } if (ret == ERROR) return ERROR; return OK; }/******************************************************************************* * fwWebDstAddrEndDisplaySet - Set the destination end address of a rule entry.*** RETURNS: OK if success, or ERROR if not */STATUS fwWebDstAddrEndDisplaySet(void) { int retv6 = 1; int ret = 1; DBG_PRINT(("Set fwWebDstAddrEndDisplaySet \n ")); if( pfwWebRule != NULL) {#ifdef INET6 retv6 = inet_pton (AF_INET6, fwWebStringHolder, (void *) &pfwWebRule->dstAddrV6.end); if (retv6 != 1 ) fwWebV6AddrError = TRUE;#endif ret = inet_pton (AF_INET, fwWebStringHolder, (void *) &pfwWebRule->dstAddr.end); NTOHL(pfwWebRule->dstAddr.end.s_addr); if (ret != 1 && strcmp(fwWebStringHolder, "255.255.255.255") ) fwWebV4AddrError = TRUE; /* not a valid v4 or v6 address */ if (strcmp(fwWebStringHolder, "255.255.255.255") && ret !=1 && retv6 != 1) { sprintf(fwWebTempError, "fwWebDstAddrEndDisplaySet failed direction %d with invalid address %s!\n", fwWebDirection, fwWebStringHolder); fwWebErrorPrint(fwWebTempError); /*return ERROR;*/ } } return OK; } /******************************************************************************* * fwWebDstAddrStartDisplayGet - Get the destination start address of a rule entry * to display on the webscreen editing/adding table*** RETURNS: OK if success, or ERROR if not */STATUS fwWebDstAddrStartDisplayGet(void) { int ret;#ifdef INET6 if( fwWebDirection == FW_PREIN_LOC_V6 || fwWebDirection == FW_OUT_LOC_V6) { ret = fwWebRuleFieldGet(FW_FIELD_IPADDR,FWWEB_DISPLAY_INDEX, (void *)&pfwWebRule->srcAddrV6,"fwWebDstAddrStartDisplayGet"); if (ret == OK) { inet_ntop (AF_INET6, (void *) &pfwWebRule->dstAddrV6.start, fwWebStringHolder, INET6_ADDRSTRLEN); } else strcpy(fwWebStringHolder, "0::0:0:0:0"); } else#endif { ret = fwWebRuleFieldGet(FW_FIELD_IPADDR,FWWEB_DISPLAY_INDEX, (void *)&pfwWebRule->srcAddr,"fwWebDstAddrStartDisplayGet"); if (ret == OK) { HTONL(pfwWebRule->dstAddr.start.s_addr); inet_ntop (AF_INET, (void *) &pfwWebRule->dstAddr.start, fwWebStringHolder, INET_ADDRSTRLEN); } else strcpy(fwWebStringHolder, ""); } if (ret == ERROR) return ERROR; return OK; }/******************************************************************************* * fwWebDstAddrStartDisplaySet - Set the destination start address of a rule entry.*** RETURNS: OK if success, or ERROR if not */STATUS fwWebDstAddrStartDisplaySet(void) { int ret = 1; int retv6 = 1; DBG_PRINT(("Set fwWebDstAddrStartDisplaySet \n ")); if( pfwWebRule != NULL) {#ifdef INET6 retv6 = inet_pton (AF_INET6, fwWebStringHolder, (void *) &pfwWebRule->dstAddrV6.start); if (retv6 != 1) fwWebV6AddrError = TRUE;#endif ret = inet_pton (AF_INET, fwWebStringHolder, (void *) &pfwWebRule->dstAddr.start); NTOHL(pfwWebRule->dstAddr.start.s_addr); if (ret != 1 && strcmp(fwWebStringHolder, "255.255.255.255") ) fwWebV4AddrError = TRUE; /* not a valid v4 or v6 address */ if (strcmp(fwWebStringHolder, "255.255.255.255") && ret !=1 && retv6 != 1) { sprintf(fwWebTempError, "fwWebDstAddrStartDisplaySet failed direction %d with invalid address %s!\n", fwWebDirection, fwWebStringHolder); fwWebErrorPrint(fwWebTempError); /*return ERROR;*/ } } return OK; }/******************************************************************************* * fwWebDstPortGet - Get the destination port range of a rule entry to display on * the webscreen incoming or outgoing table*** RETURNS: OK if success, or ERROR if not */STATUS fwWebDstPortGet(void) { if (fwWebTotalEntry <= 0) return OK; if( fwWebRuleFieldGet(FW_FIELD_PROTO,FWWEB_MOVE_INDEX, (void *)&pfwWebRule->proto, "fwWebDstPortGet" ) == OK) { switch (pfwWebRule->proto) { case IPPROTO_TCP: /*tcp*/ if (fwWebRuleFieldGet(FW_FIELD_TCP,FWWEB_MOVE_INDEX,(void *)&pfwWebRule->tcp,"fwWebDstPortGet") == ERROR) { strcpy(fwWebStringHolder, "N/A"); return ERROR; } sprintf(fwWebStringHolder, "%d - %d", pfwWebRule->tcp.dstPort.start, pfwWebRule->tcp.dstPort.end); break; case IPPROTO_UDP: /*udp*/ if (fwWebRuleFieldGet(FW_FIELD_UDP,FWWEB_MOVE_INDEX,(void *)&pfwWebRule->udp,"fwWebDstPortGet") == ERROR) { fwWebErrorPrint (" fwRuleGet failed in fwWebDstPortGet! \n"); strcpy(fwWebStringHolder, "N/A"); return ERROR; } sprintf(fwWebStringHolder, "%d - %d", pfwWebRule->udp.dstPort.start, pfwWebRule->udp.dstPort.end); break; case IPPROTO_ICMP: /*icmp*/#ifdef INET6 case IPPROTO_ICMPV6: /*icmpv6*/#endif case IPPROTO_IP: strcpy(fwWebStringHolder, "N/A"); break; default: strcpy(fwWebStringHolder, "0 - 0"); sprintf(fwWebTempError, " Unknown protocol type %d in dstPortGet!\n",pfwWebRule->proto); fwWebErrorPrint(fwWebTempError); return ERROR; break; } } else { strcpy(fwWebStringHolder, "0 - 0"); return ERROR; } return OK; }/******************************************************************************* * fwWebDstPortEndDisplayGet - Get the destination end port of a rule entry * to display on the webscreen editing/adding table*** RETURNS: OK if success, or ERROR if not */STATUS fwWebDstPortEndDisplayGet(void) { int ret = fwWebRuleFieldGet(FW_FIELD_PROTO,FWWEB_DISPLAY_INDEX, (void *)&pfwWebRule->proto,"fwWebDstPortEndDisplayGet"); if (ret == OK) switch (pfwWebRule->proto) { case IPPROTO_TCP: if (fwWebRuleFieldGet(FW_FIELD_TCP,FWWEB_DISPLAY_INDEX,(void *)&pfwWebRule->tcp,"fwWebDstPortEndDisplayGet") == ERROR) { fwWebErrorPrint (" fwRuleGet failed in fwWebDstPortEndDisplayGet! \n"); fwWebIntHolder = 0; return ERROR; } fwWebIntHolder = pfwWebRule->tcp.dstPort.end; break; case IPPROTO_UDP: if (fwWebRuleFieldGet(FW_FIELD_UDP,FWWEB_DISPLAY_INDEX,(void *)&pfwWebRule->udp,"fwWebDstPortEndDisplayGet") == ERROR) { fwWebErrorPrint (" fwRuleGet failed in fwWebDstPortEndDisplayGet! \n"); fwWebIntHolder = 0; return ERROR; } fwWebIntHolder = pfwWebRule->udp.dstPort.end; break; case IPPROTO_ICMP:#ifdef INET6 case IPPROTO_ICMPV6: /*icmpv6*/#endif case IPPROTO_IP: fwWebIntHolder = 0; break; default: fwWebIntHolder = 0; sprintf(fwWebTempError, " Unknown protocol type %d in dstPortEndDisplayGet!\n",pfwWebRule->proto); fwWebErrorPrint(fwWebTempError); return ERROR; break; } else fwWebIntHolder = 0; if (ret == ERROR) return ERROR; return OK; }/******************************************************************************* * fwWebDstPortEndDisplaySet - Set the destination end port of a rule entry.*** RETURNS: OK if success, or ERROR if not */STATUS fwWebDstPortEndDisplaySet(void) { DBG_PRINT(("Set fwWebDstPortEndDisplaySet \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.dstPort.end = fwWebIntHolder; pfwWebRule->udp.dstPort.end = fwWebIntHolder; break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -