summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_ppp.c
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>1999-11-30 02:45:32 +0000
committerarchie <archie@FreeBSD.org>1999-11-30 02:45:32 +0000
commit81fceb37a95304786f88f6611289a27c7262d394 (patch)
tree321a35b746bb34b931d0691c03f9888db83ed68b /sys/netgraph/ng_ppp.c
parent9716636318d4160418baceabe7ba05ce065692fc (diff)
downloadFreeBSD-src-81fceb37a95304786f88f6611289a27c7262d394.zip
FreeBSD-src-81fceb37a95304786f88f6611289a27c7262d394.tar.gz
Add two new generic control messages, NGM_ASCII2BINARY and
NGM_BINARY2ASCII, which convert control messages to ASCII and back. This allows control messages to be sent and received in ASCII form using ngctl(8), which makes ngctl a lot more useful. This also allows all the type-specific debugging code in libnetgraph to go away -- instead, we just ask the node itself to do the ASCII translation for us. Currently, all generic control messages are supported, as well as messages associated with the following node types: async, cisco, ksocket, and ppp. See /usr/share/examples/netgraph/ngctl for an example of using this. Also give ngctl(8) the ability to print out incoming data and control messages at any time. Eventually nghook(8) may be subsumed. Several other misc. bug fixes. Reviewed by: julian
Diffstat (limited to 'sys/netgraph/ng_ppp.c')
-rw-r--r--sys/netgraph/ng_ppp.c78
1 files changed, 76 insertions, 2 deletions
diff --git a/sys/netgraph/ng_ppp.c b/sys/netgraph/ng_ppp.c
index 2097de1..7cfb4b6 100644
--- a/sys/netgraph/ng_ppp.c
+++ b/sys/netgraph/ng_ppp.c
@@ -57,6 +57,7 @@
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
+#include <netgraph/ng_parse.h>
#include <netgraph/ng_ppp.h>
#include <netgraph/ng_vjc.h>
@@ -205,6 +206,78 @@ static int ng_ppp_config_valid(node_p node,
static void ng_ppp_update(node_p node, int newConf);
static void ng_ppp_free_frags(node_p node);
+/* Parse type for struct ng_ppp_link_config */
+static const struct ng_parse_struct_info
+ ng_ppp_link_type_info = NG_PPP_LINK_TYPE_INFO;
+static const struct ng_parse_type ng_ppp_link_type = {
+ &ng_parse_struct_type,
+ &ng_ppp_link_type_info,
+};
+
+/* Parse type for struct ng_ppp_node_config */
+struct ng_parse_fixedarray_info ng_ppp_array_info = {
+ &ng_ppp_link_type,
+ NG_PPP_MAX_LINKS
+};
+static const struct ng_parse_type ng_ppp_link_array_type = {
+ &ng_parse_fixedarray_type,
+ &ng_ppp_array_info,
+};
+static const struct ng_parse_struct_info ng_ppp_config_type_info
+ = NG_PPP_CONFIG_TYPE_INFO(&ng_ppp_link_array_type);
+static const struct ng_parse_type ng_ppp_config_type = {
+ &ng_parse_struct_type,
+ &ng_ppp_config_type_info
+};
+
+/* Parse type for struct ng_ppp_link_stat */
+static const struct ng_parse_struct_info
+ ng_ppp_stats_type_info = NG_PPP_STATS_TYPE_INFO;
+static const struct ng_parse_type ng_ppp_stats_type = {
+ &ng_parse_struct_type,
+ &ng_ppp_stats_type_info
+};
+
+/* List of commands and how to convert arguments to/from ASCII */
+static const struct ng_cmdlist ng_ppp_cmds[] = {
+ {
+ NGM_PPP_COOKIE,
+ NGM_PPP_SET_CONFIG,
+ "setconfig",
+ &ng_ppp_config_type,
+ NULL
+ },
+ {
+ NGM_PPP_COOKIE,
+ NGM_PPP_GET_CONFIG,
+ "getconfig",
+ NULL,
+ &ng_ppp_config_type
+ },
+ {
+ NGM_PPP_COOKIE,
+ NGM_PPP_GET_LINK_STATS,
+ "getstats",
+ &ng_parse_int16_type,
+ &ng_ppp_stats_type
+ },
+ {
+ NGM_PPP_COOKIE,
+ NGM_PPP_CLR_LINK_STATS,
+ "clrstats",
+ &ng_parse_int16_type,
+ NULL
+ },
+ {
+ NGM_PPP_COOKIE,
+ NGM_PPP_GETCLR_LINK_STATS,
+ "getclrstats",
+ &ng_parse_int16_type,
+ &ng_ppp_stats_type
+ },
+ { 0 }
+};
+
/* Node type descriptor */
static struct ng_type ng_ppp_typestruct = {
NG_VERSION,
@@ -218,7 +291,8 @@ static struct ng_type ng_ppp_typestruct = {
NULL,
ng_ppp_rcvdata,
ng_ppp_rcvdata,
- ng_ppp_disconnect
+ ng_ppp_disconnect,
+ ng_ppp_cmds
};
NETGRAPH_INIT(ppp, &ng_ppp_typestruct);
@@ -334,7 +408,7 @@ ng_ppp_rcvmsg(node_p node, struct ng_mesg *msg,
case NGM_PPP_SET_CONFIG:
{
struct ng_ppp_node_config *const newConf =
- (struct ng_ppp_node_config *) msg->data;
+ (struct ng_ppp_node_config *) msg->data;
/* Check for invalid or illegal config */
if (msg->header.arglen != sizeof(*newConf))
OpenPOWER on IntegriCloud