|
version 1.1.1.3, 2016/11/01 09:56:12
|
version 1.1.1.4, 2021/03/17 00:39:23
|
|
Line 82
|
Line 82
|
| */ |
*/ |
| |
|
| #ifdef USE_NG_NETFLOW |
#ifdef USE_NG_NETFLOW |
| static int NetflowSetCommand(Context ctx, int ac, char *av[], void *arg); | static int NetflowSetCommand(Context ctx, int ac, const char *const av[], const void *arg); |
| #endif |
#endif |
| |
|
| /* |
/* |
|
Line 109
|
Line 109
|
| NetflowSetCommand, NULL, 2, (void *) SET_NODE }, |
NetflowSetCommand, NULL, 2, (void *) SET_NODE }, |
| { "hook {number}", "Set initial hook number" , |
{ "hook {number}", "Set initial hook number" , |
| NetflowSetCommand, NULL, 2, (void *) SET_HOOK }, |
NetflowSetCommand, NULL, 2, (void *) SET_HOOK }, |
| { NULL }, | { NULL, NULL, NULL, NULL, 0, NULL }, |
| }; |
}; |
| #endif |
#endif |
| |
|
|
Line 131
|
Line 131
|
| uint32_t gNetflowInactive = 0; |
uint32_t gNetflowInactive = 0; |
| uint32_t gNetflowActive = 0; |
uint32_t gNetflowActive = 0; |
| #if NGM_NETFLOW_COOKIE >= 1309868867 |
#if NGM_NETFLOW_COOKIE >= 1309868867 |
| uint16_t gNetflowTime = 0; | static uint16_t gNetflowTime = 0; |
| uint16_t gNetflowPackets = 0; | static uint16_t gNetflowPackets = 0; |
| uint16_t gNetflowMTU = 0; | static uint16_t gNetflowMTU = 0; |
| u_int gNetflowVer = 5; | static u_int gNetflowVer = 5; |
| #endif |
#endif |
| #endif |
#endif |
| |
|
|
Line 160 NgFuncInitGlobalNetflow(void)
|
Line 160 NgFuncInitGlobalNetflow(void)
|
| /* If node exist just get it's ID. */ |
/* If node exist just get it's ID. */ |
| if (gNetflowNode) { |
if (gNetflowNode) { |
| snprintf(path, sizeof(path), "%s:", gNetflowNodeName); |
snprintf(path, sizeof(path), "%s:", gNetflowNodeName); |
| gNetflowNodeID = NgGetNodeID(csock, path); | if ((gNetflowNodeID = NgGetNodeID(csock, path)) == 0) { |
| | Perror("NETFLOW: Cannot get %s node id", NG_NETFLOW_NODE_TYPE); |
| | goto fail; |
| | } |
| close(csock); |
close(csock); |
| return (0); |
return (0); |
| } |
} |
|
Line 179 NgFuncInitGlobalNetflow(void)
|
Line 182 NgFuncInitGlobalNetflow(void)
|
| } |
} |
| |
|
| /* Get new node ID. */ |
/* Get new node ID. */ |
| gNetflowNodeID = NgGetNodeID(csock, TEMPHOOK); | if ((gNetflowNodeID = NgGetNodeID(csock, TEMPHOOK)) == 0) { |
| | Perror("NETFLOW: Cannot get %s node id", NG_NETFLOW_NODE_TYPE); |
| | goto fail; |
| | } |
| |
|
| /* Set the new node's name. */ |
/* Set the new node's name. */ |
| strcpy(nm.name, gNetflowNodeName); |
strcpy(nm.name, gNetflowNodeName); |
|
Line 656 NgFuncClrStats(Bund b, u_int16_t linkNum)
|
Line 662 NgFuncClrStats(Bund b, u_int16_t linkNum)
|
| return(0); |
return(0); |
| } |
} |
| |
|
| |
#ifndef NG_PPP_STATS64 |
| |
|
| /* |
/* |
| * NgFuncGetStats() |
* NgFuncGetStats() |
| * |
* |
|
Line 684 NgFuncGetStats(Bund b, u_int16_t linkNum, struct ng_pp
|
Line 692 NgFuncGetStats(Bund b, u_int16_t linkNum, struct ng_pp
|
| return(0); |
return(0); |
| } |
} |
| |
|
| #ifdef NG_PPP_STATS64 | #else |
| /* |
/* |
| * NgFuncGetStats64() |
* NgFuncGetStats64() |
| * |
* |
|
Line 752 NgFuncErr(const char *fmt, ...)
|
Line 760 NgFuncErr(const char *fmt, ...)
|
| */ |
*/ |
| |
|
| static int |
static int |
| NetflowSetCommand(Context ctx, int ac, char *av[], void *arg) | NetflowSetCommand(Context ctx, int ac, const char *const av[], const void *arg) |
| { |
{ |
| struct sockaddr_storage *sin; |
struct sockaddr_storage *sin; |
| |
|
|
Line 795 NetflowSetCommand(Context ctx, int ac, char *av[], voi
|
Line 803 NetflowSetCommand(Context ctx, int ac, char *av[], voi
|
| case SET_MTU: |
case SET_MTU: |
| if (ac != 1) |
if (ac != 1) |
| return (-1); |
return (-1); |
| if (atoi(av[0]) < MIN_MTU || atoi(av[0]) > MAX_MTU) | if (atoi(av[0]) < (int)MIN_MTU || atoi(av[0]) > (int)MAX_MTU) |
| Error("Bad netflow v9 MTU \"%s\"", av[0]); |
Error("Bad netflow v9 MTU \"%s\"", av[0]); |
| gNetflowMTU = atoi(av[0]); /* Default 1500 */ |
gNetflowMTU = atoi(av[0]); /* Default 1500 */ |
| break; |
break; |
|
Line 838 NetflowSetCommand(Context ctx, int ac, char *av[], voi
|
Line 846 NetflowSetCommand(Context ctx, int ac, char *av[], voi
|
| */ |
*/ |
| |
|
| int |
int |
| ShowNetflow(Context ctx, int ac, char *av[], void *arg) | ShowNetflow(Context ctx, int ac, const char *const av[], const void *arg) |
| { |
{ |
| struct u_addr addr; |
struct u_addr addr; |
| in_port_t port; |
in_port_t port; |
|
Line 859 ShowNetflow(Context ctx, int ac, char *av[], void *arg
|
Line 867 ShowNetflow(Context ctx, int ac, char *av[], void *arg
|
| (struct ng_netflow_v9info *)(void *)uv9.reply.data; |
(struct ng_netflow_v9info *)(void *)uv9.reply.data; |
| #endif /* NGM_NETFLOW_V9_COOKIE */ |
#endif /* NGM_NETFLOW_V9_COOKIE */ |
| |
|
| |
(void)ac; |
| |
(void)av; |
| |
(void)arg; |
| |
|
| if (gNetflowNodeID>0) { |
if (gNetflowNodeID>0) { |
| snprintf(path, sizeof(path), "[%x]:", gNetflowNodeID); |
snprintf(path, sizeof(path), "[%x]:", gNetflowNodeID); |
| if (NgFuncSendQuery(path, NGM_NETFLOW_COOKIE, NGM_NETFLOW_INFO, |
if (NgFuncSendQuery(path, NGM_NETFLOW_COOKIE, NGM_NETFLOW_INFO, |
|
Line 978 NgGetNodeID(int csock, const char *path)
|
Line 990 NgGetNodeID(int csock, const char *path)
|
| /* Create a netgraph socket node */ |
/* Create a netgraph socket node */ |
| snprintf(name, sizeof(name), "mpd%d-stats", gPid); |
snprintf(name, sizeof(name), "mpd%d-stats", gPid); |
| if (NgMkSockNode(name, &gNgStatSock, NULL) < 0) { |
if (NgMkSockNode(name, &gNgStatSock, NULL) < 0) { |
| Perror("NgFuncSendQuery: can't create %s node", NG_SOCKET_NODE_TYPE); | Perror("NgMkSockNode: can't create %s node", |
| return(-1); | NG_SOCKET_NODE_TYPE); |
| | return (0); |
| } |
} |
| (void) fcntl(gNgStatSock, F_SETFD, 1); |
(void) fcntl(gNgStatSock, F_SETFD, 1); |
| } |
} |
|
Line 987 NgGetNodeID(int csock, const char *path)
|
Line 1000 NgGetNodeID(int csock, const char *path)
|
| } |
} |
| |
|
| if (NgSendMsg(csock, path, |
if (NgSendMsg(csock, path, |
| NGM_GENERIC_COOKIE, NGM_NODEINFO, NULL, 0) < 0) | NGM_GENERIC_COOKIE, NGM_NODEINFO, NULL, 0) < 0) { |
| return (0); | Perror("NgSendMsg to %s", path); |
| if (NgRecvMsg(csock, &u.reply, sizeof(u), NULL) < 0) | |
| return (0); |
return (0); |
| | } |
| | if (NgRecvMsg(csock, &u.reply, sizeof(u), NULL) < 0) { |
| | Perror("NgRecvMsg from %s", path); |
| | return (0); |
| | } |
| | |
| return (ni->id); |
return (ni->id); |
| } |
} |
| |
|