libkysdk-system/man/net/kdk_net_free_route.3

144 lines
3.7 KiB
Groff

.TH "KDK_NET_FREE_ROUTE" 3 "Thu Sep 14 2023" "Linux Programmer's Manual" \"
.SH NAME
kdk_net_free_route - 释放由kdk_net_get_route返回的网关信息结构体
.SH SYNOPSIS
.nf
.B #include <libkynetinfo.h>
.sp
.BI "extern void kdk_net_free_route(prouteMapList "list ");"
.sp
Link with \fI\-lkynetinfo\fP.
.SH "Detailed Description"
The main function of the interface is to release the gateway information structure returned by the
.I kdk_net_get_route.
.PP
The argument
.I list
is the return value of the
.I kdk_net_get_route.
.SH "RETURN VALUE"
No return value
.SH EXAMPLES
.EX
#include "libkynetinfo.h"
#include "stdio.h"
#include "stdlib.h"
int main(int argc, char *argv[])
{
prouteMapList list = kdk_net_get_route(), tmp = list;
while (tmp)
{
printf("%s default route %s\n", tmp->name, tmp->addr);
tmp = tmp->next;
}
kdk_net_free_route(list);
if (argc < 2)
printf("please input test port num\n");
else
printf("port:%s's state %d\n", argv[1], kdk_net_get_port_stat(atoi(argv[1])));
pChain chain = kdk_net_get_iptable_rules();
pChain tmpchain = chain;
while(tmpchain)
{
printf("Chain: %s\tpolice: %s\n",tmpchain->total,tmpchain->policy);
pChainData tmpData = tmpchain->data;
if(tmpData)
printf("target: %s\tprot: %s\topt: %s\tsource: %s\tdestination: %s\toption: %s\n",tmpData->target,tmpData->prot,tmpData->opt,
tmpData->source,tmpData->destination,tmpData->option);
printf("\n");
tmpchain = tmpchain->next;
}
kdk_net_free_chain(chain);
int result[65536];
int net = kdk_net_get_multiple_port_stat(0, 1000, result);
if(net == 0)
{
size_t count = 0;
for(;count < 1000 ;count++)
{
printf("%d\t", result[count]);
}
}
else
printf("Failed With %d", net);
printf("\n");
char mask[32] = "\0";
kdk_net_get_netmask("enaftgm1i0", mask);
printf("mask = %s\n", mask);
char **port = kdk_net_get_proc_port();
size_t index = 0;
while(port[index])
{
printf("No.%ld, port = %s\n", index+1, port[index]);
index++;
}
kdk_net_freeall(port);
port = kdk_net_get_up_port();
index = 0;
while(port[index])
{
printf("No.%ld, port = %s\n", index+1, port[index]);
index++;
}
kdk_net_freeall(port);
char *hosts = kdk_net_get_hosts();
if (hosts != NULL)
{
printf("hosts = %s\n", hosts);
free(hosts);
}
char *domain = kdk_net_get_hosts_domain();
if (domain != NULL)
{
printf("domain = %s\n", domain);
free(domain);
}
char **resolv = kdk_net_get_resolv_conf();
index = 0;
while(resolv[index])
{
printf("No.%ld, resolv = %s\n", index+1, resolv[index]);
index++;
}
kdk_net_freeall(resolv);
return 0;
}
.SH "CONFORMING TO"
These functions are as per the withdrawn POSIX.1e draft specification.
The following functions are Linux extensions:
.BR kdk_net_get_netmask (),
.BR kdk_net_get_port_stat (),
.BR kdk_net_get_multiple_port_stat (),
.BR kdk_net_get_iptable_rules (),
.BR kdk_net_get_route (),
.BR kdk_net_free_chain (),
.BR kdk_net_get_proc_port (),
.BR kdk_net_get_up_port (),
.BR kdk_net_get_hosts (),
.BR kdk_net_get_hosts_domain (),
.BR kdk_net_get_resolv_conf ()
and
.BR kdk_net_freeall ().
.SH "SEE ALSO"
.BR kdk_net_get_netmask (3),
.BR kdk_net_get_port_stat (3),
.BR kdk_net_get_multiple_port_stat (3),
.BR kdk_net_get_iptable_rules (3),
.BR kdk_net_get_route (3),
.BR kdk_net_free_chain (3),
.BR kdk_net_get_up_port (3),
.BR kdk_net_get_hosts (3),
.BR kdk_net_get_hosts_domain (3),
.BR kdk_net_get_resolv_conf (3)
and
.BR kdk_net_freeall (3).