void
chn_read_file()
{
MY_DEBUG_LOG(
"chn_read_file():read from the file start...\n"
);
DO_LOG(
"chn_read_file():read from the file start...\n"
);
FILE
*fp;
int
i, j;
fp=
fopen
(
"/tmp/data/db_file/tcp_file"
,
"rb"
);
if
(fp == NULL)
{
DO_LOG(
"chn_read_file():open file failed, because:%s!\n"
,
strerror
(
errno
));
return
;
}
fread
(table_channels,
sizeof
(TABLE_CHANNEL), 256, fp);
MY_DEBUG_LOG(
"chn_read_file(): The informations of approuteways bellows:\n"
);
for
(i =0; i<256; i++)
{
if
(table_channels[i].used == 0)
{
continue
;
}
MY_DEBUG_LOG("[ReadFile]:ID:%d, used:%d, AppID:%d, SourceIP:%s, SourcePort:%d,\
DestIP:%s, DestPort:%d, SourceType:%c, IsDestProxyMode:%c, MaxConn:%d,\
IsWorking:%c, IsAuth:%c, InnerPort:%d, OuterPort:%d, IsAllowed:%c, name:%s!\n", \
i, table_channels[i].used, table_channels[i].AppID,table_channels[i].SourceIP,table_channels[i].SourcePort, \
table_channels[i].DestIP, table_channels[i].DestPort, table_channels[i].SourceType, table_channels[i].IsDestProxyMode,\
table_channels[i].MaxConn, table_channels[i].IsWorking,table_channels[i].IsAuth,table_channels[i].InnerPort,\
table_channels[i].OuterPort,table_channels[i].IsAllowed,table_channels[i].name);
}
MY_DEBUG_LOG(
"chn_read_file(): The informations of allowd time bellows:\n"
);
for
(i=0; i<256; i++)
{
if
(table_channels[i].used == 0)
{
continue
;
}
for
(j=0; j<8; j++)
{
if
(table_channels[i].FromTime[j][0] == 0)
{
continue
;
}
if
(table_channels[i].ToTime[j][0] == 0)
{
continue
;
}
if
(table_channels[i].WeekDay[j][0] == 0)
{
continue
;
}
MY_DEBUG_LOG(
"chn_read_file():ID:%d,FormTime:%s,ToTime:%s,WeekDay:%s\n"
,\
i,&table_channels[i].FromTime[j][0], &table_channels[i].ToTime[j][0], &table_channels[i].WeekDay[j][0]);
}
}
MY_DEBUG_LOG(
"chn_read_file(): The informations of allowd IPs bellows:\n"
);
for
(i=0; i<256; i++)
{
if
(table_channels[i].used == 0)
{
continue
;
}
for
(j=0; j<256; j++)
{
if
(table_channels[i].allowed_ip[j].ip[0] ==0)
{
continue
;
}
if
(table_channels[i].allowed_ip[j].black_white == 0)
{
MY_DEBUG_LOG(
"chn_read_file():ID:%d, ip %s, black_white:%d\n"
,
i, table_channels[i].allowed_ip[j].ip, table_channels[i].allowed_ip[j].black_white);
}
}
}
MY_DEBUG_LOG(
"chn_read_file(): The informations of allowd users bellows:\n"
);
for
(i=0; i<256; i++)
{
if
(table_channels[i].used == 0)
{
continue
;
}
for
(j=0; j<256; j++)
{
if
(table_channels[i].allowed_ip[j].ip[0] ==0)
{
continue
;
}
if
(table_channels[i].allowed_ip[j].black_white == 1)
{
MY_DEBUG_LOG(
"chn_read_file():ID:%d, users %s, black_white:%d\n"
,
i, table_channels[i].allowed_ip[j].ip, table_channels[i].allowed_ip[j].black_white);
}
}
}
MY_DEBUG_LOG(
"chn_read_file(): The informations of policies bellows:\n"
);
for
(i=0; i<256; i++)
{
if
(table_channels[i].used == 0)
{
continue
;
}
for
(j =0 ; j <64; j++)
{
if
(table_channels[i].policy[j].type == 0)
{
continue
;
}
MY_DEBUG_LOG(
"[ReadFile]:ID:%d, AppID:%d, used:%d, policy_id:%d , type:%x, IsWorking:%c, p_content:%s, IsAllowed:%c.\n"
,
i,table_channels[i].AppID,table_channels[i].used,table_channels[i].policy[j].p_id,table_channels[i].policy[j].type,
table_channels[i].policy[j].IsWorking,table_channels[i].policy[j].p_content, table_channels[i].policy[j].IsAllowed);
}
}
fclose
(fp);
MY_DEBUG_LOG(
"chn_read_file():read from the file start end...\n"
);
}
请发表评论