1 .\" Copyright (c) 1996-1999 Whistle Communications, Inc.
2 .\" All rights reserved.
4 .\" Subject to the following obligations and disclaimer of warranty, use and
5 .\" redistribution of this software, in source or object code forms, with or
6 .\" without modifications are expressly permitted by Whistle Communications;
7 .\" provided, however, that:
8 .\" 1. Any and all reproductions of the source or object code must include the
9 .\" copyright notice above and the following disclaimer of warranties; and
10 .\" 2. No rights are granted, in any manner or form, to use Whistle
11 .\" Communications, Inc. trademarks, including the mark "WHISTLE
12 .\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
13 .\" such appears in the above copyright notice or in the software.
15 .\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
16 .\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
17 .\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
18 .\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
19 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
20 .\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
21 .\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
22 .\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
23 .\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
24 .\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
25 .\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26 .\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
27 .\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
28 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 .\" THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
33 .\" Authors: Julian Elischer <julian@FreeBSD.org>
34 .\" Archie Cobbs <archie@FreeBSD.org>
36 .\" $FreeBSD: src/share/man/man4/netgraph.4,v 1.39.2.1 2001/12/21 09:00:50 ru Exp $
37 .\" $Whistle: netgraph.4,v 1.7 1999/01/28 23:54:52 julian Exp $
44 .Nd graph based kernel networking subsystem
48 system provides a uniform and modular system for the implementation
49 of kernel objects which perform various networking functions. The objects,
52 can be arranged into arbitrarily complicated graphs. Nodes have
54 which are used to connect two nodes together, forming the edges in the graph.
55 Nodes communicate along the edges to process data, implement protocols, etc.
59 is to supplement rather than replace the existing kernel networking
60 infrastructure. It provides:
62 .Bl -bullet -compact -offset 2n
64 A flexible way of combining protocol and link level drivers
66 A modular way to implement new protocols
68 A common framework for kernel entities to inter-communicate
70 A reasonably fast, kernel-based implementation
73 The most fundamental concept in
77 All nodes implement a number of predefined methods which allow them
78 to interact with other nodes in a well defined manner.
82 which is a static property of the node determined at node creation time.
83 A node's type is described by a unique
86 The type implies what the node does and how it may be connected
89 In object-oriented language, types are classes and nodes are instances
90 of their respective class. All node types are subclasses of the generic node
91 type, and hence inherit certain common functionality and capabilities
92 (e.g., the ability to have an
96 Nodes may be assigned a globally unique
99 used to refer to the node.
100 The name must not contain the characters
106 characters (including NUL byte).
108 Each node instance has a unique
110 which is expressed as a 32-bit hex value. This value may be used to
111 refer to a node when there is no
115 Nodes are connected to other nodes by connecting a pair of
117 one from each node. Data flows bidirectionally between nodes along
118 connected pairs of hooks. A node may have as many hooks as it
119 needs, and may assign whatever meaning it wants to a hook.
121 Hooks have these properties:
123 .Bl -bullet -compact -offset 2n
127 name which is unique among all hooks
128 on that node (other hooks on other nodes may have the same name).
129 The name must not contain a
136 characters (including NUL byte).
138 A hook is always connected to another hook. That is, hooks are
139 created at the time they are connected, and breaking an edge by
140 removing either hook destroys both hooks.
143 A node may decide to assign special meaning to some hooks.
144 For example, connecting to the hook named
147 the node to start sending debugging information to that hook.
149 Two types of information flow between nodes: data messages and
150 control messages. Data messages are passed in mbuf chains along the edges
151 in the graph, one edge at a time. The first mbuf in a chain must have the
153 flag set. Each node decides how to handle data coming in on its hooks.
155 Control messages are type-specific C structures sent from one node
156 directly to some arbitrary other node. Control messages have a common
157 header format, followed by type-specific data, and are binary structures
158 for efficiency. However, node types also may support conversion of the
159 type specific data between binary and
161 for debugging and human interface purposes (see the
165 generic control messages below). Nodes are not required to support
168 There are two ways to address a control message. If
169 there is a sequence of edges connecting the two nodes, the message
172 by specifying the corresponding sequence
173 of hooks as the destination address for the message (relative
174 addressing). Otherwise, the recipient node global
177 (or equivalent ID based name) is used as the destination address
178 for the message (absolute addressing). The two types of addressing
179 may be combined, by specifying an absolute start node and a sequence
182 Messages often represent commands that are followed by a reply message
183 in the reverse direction. To facilitate this, the recipient of a
184 control message is supplied with a
186 that is suitable for addressing a reply.
188 Each control message contains a 32 bit value called a
190 indicating the type of the message, i.e., how to interpret it.
191 Typically each type defines a unique typecookie for the messages
192 that it understands. However, a node may choose to recognize and
193 implement more than one type of message.
194 .Sh Netgraph is Functional
195 In order to minimize latency, most
197 operations are functional.
198 That is, data and control messages are delivered by making function
199 calls rather than by using queues and mailboxes. For example, if node
200 A wishes to send a data mbuf to neighboring node B, it calls the
203 data delivery function. This function in turn locates
206 method. While this mode of operation
207 results in good performance, it has a few implications for node
210 .Bl -bullet -compact -offset 2n
212 Whenever a node delivers a data or control message, the node
213 may need to allow for the possibility of receiving a returning
214 message before the original delivery function call returns.
216 Netgraph nodes and support routines generally run inside critical
218 However, some nodes may want to send data and control messages
219 from a different priority level. Netgraph supplies queueing routines which
220 utilize the NETISR system to move message delivery inside a critical
222 Note that messages are always received from inside a critical section.
224 It's possible for an infinite loop to occur if the graph contains cycles.
227 So far, these issues have not proven problematical in practice.
228 .Sh Interaction With Other Parts of the Kernel
229 A node may have a hidden interaction with other components of the
230 kernel outside of the
232 subsystem, such as device hardware,
233 kernel protocol stacks, etc. In fact, one of the benefits of
235 is the ability to join disparate kernel networking entities together in a
236 consistent communication framework.
238 An example is the node type
240 which is both a netgraph node and a
243 socket in the protocol family
245 Socket nodes allow user processes to participate in
247 Other nodes communicate with socket nodes using the usual methods, and the
248 node hides the fact that it is also passing information to and from a
249 cooperating user process.
251 Another example is a device driver that presents
252 a node interface to the hardware.
254 Nodes are notified of the following actions via function calls
255 to the following node methods (all from inside critical sections)
256 and may accept or reject that action (by returning the appropriate
259 .It Creation of a new node
260 The constructor for the type is called. If creation of a new node is
261 allowed, the constructor must call the generic node creation
262 function (in object-oriented terms, the superclass constructor)
263 and then allocate any special resources it needs. For nodes that
264 correspond to hardware, this is typically done during the device
265 attach routine. Often a global
267 name corresponding to the
268 device name is assigned here as well.
269 .It Creation of a new hook
270 The hook is created and tentatively
271 linked to the node, and the node is told about the name that will be
272 used to describe this hook. The node sets up any special data structures
273 it needs, or may reject the connection, based on the name of the hook.
274 .It Successful connection of two hooks
275 After both ends have accepted their
276 hooks, and the links have been made, the nodes get a chance to
277 find out who their peer is across the link and can then decide to reject
278 the connection. Tear-down is automatic.
279 .It Destruction of a hook
280 The node is notified of a broken connection. The node may consider some hooks
281 to be critical to operation and others to be expendable: the disconnection
282 of one hook may be an acceptable event while for another it
283 may affect a total shutdown for the node.
284 .It Shutdown of a node
285 This method allows a node to clean up
286 and to ensure that any actions that need to be performed
287 at this time are taken. The method must call the generic (i.e., superclass)
288 node destructor to get rid of the generic components of the node.
289 Some nodes (usually associated with a piece of hardware) may be
291 in that a shutdown breaks all edges and resets the node,
292 but doesn't remove it, in which case the generic destructor is not called.
294 .Sh Sending and Receiving Data
295 Three other methods are also supported by all nodes:
297 .It Receive data message
298 An mbuf chain is passed to the node.
299 The node is notified on which hook the data arrived,
300 and can use this information in its processing decision.
303 the mbuf chain on completion or error, or pass it on to another node
304 (or kernel module) which will then be responsible for freeing it.
306 In addition to the mbuf chain itself there is also a pointer to a
307 structure describing meta-data about the message
308 (e.g. priority information). This pointer may be
310 if there is no additional information. The format for this information is
312 .In netgraph/netgraph.h .
313 The memory for meta-data must allocated via
317 As with the data itself, it is the receiver's responsibility to
319 the meta-data. If the mbuf chain is freed the meta-data must
320 be freed at the same time. If the meta-data is freed but the
321 real data on is passed on, then a
323 pointer must be substituted.
325 The receiving node may decide to defer the data by queueing it in the
327 NETISR system (see below).
329 The structure and use of meta-data is still experimental, but is
330 presently used in frame-relay to indicate that management packets
331 should be queued for transmission
332 at a higher priority than data packets. This is required for
333 conformance with Frame Relay standards.
335 .It Receive queued data message
336 Usually this will be the same function as
337 .Em Receive data message.
338 This is the entry point called when a data message is being handed to
339 the node after having been queued in the NETISR system.
340 This allows a node to decide in the
341 .Em Receive data message
342 method that a message should be deferred and queued,
343 and be sure that when it is processed from the queue,
344 it will not be queued again.
345 .It Receive control message
346 This method is called when a control message is addressed to the node.
347 A return address is always supplied, giving the address of the node
348 that originated the message so a reply message can be sent anytime later.
350 It is possible for a synchronous reply to be made, and in fact this
351 is more common in practice.
352 This is done by setting a pointer (supplied as an extra function parameter)
353 to point to the reply.
354 Then when the control message delivery function returns,
355 the caller can check if this pointer has been made non-NULL,
356 and if so then it points to the reply message allocated via
358 and containing the synchronous response. In both directions,
359 (request and response) it is up to the
360 receiver of that message to
362 the control message buffer. All control messages and replies are
369 Much use has been made of reference counts, so that nodes being
370 free'd of all references are automatically freed, and this behaviour
371 has been tested and debugged to present a consistent and trustworthy
378 framework provides an unambiguous and simple to use method of specifically
379 addressing any single node in the graph. The naming of a node is
380 independent of its type, in that another node, or external component
381 need not know anything about the node's type in order to address it so as
382 to send it a generic message type. Node and hook names should be
383 chosen so as to make addresses meaningful.
385 Addresses are either absolute or relative. An absolute address begins
386 with a node name, (or ID), followed by a colon, followed by a sequence of hook
387 names separated by periods. This addresses the node reached by starting
388 at the named node and following the specified sequence of hooks.
389 A relative address includes only the sequence of hook names, implicitly
390 starting hook traversal at the local node.
392 There are a couple of special possibilities for the node name.
397 always refers to the local node.
398 Also, nodes that have no global name may be addressed by their ID numbers,
399 by enclosing the hex representation of the ID number within square brackets.
400 Here are some examples of valid netgraph addresses:
401 .Bd -literal -offset 4n -compact
410 Consider the following set of nodes might be created for a site with
411 a single physical frame relay line having two active logical DLCI channels,
412 with RFC 1490 frames on DLCI 16 and PPP frames over DLCI 20:
414 [type SYNC ] [type FRAME] [type RFC1490]
415 [ "Frame1" ](uplink)<-->(data)[<un-named>](dlci16)<-->(mux)[<un-named> ]
416 [ A ] [ B ](dlci20)<---+ [ C ]
423 One could always send a control message to node C from anywhere
425 .Em "Frame1:uplink.dlci16" .
427 .Em "Frame1:uplink.dlci20"
428 could reliably be used to reach node D, and node A could refer
433 Conversely, B can refer to A as
437 could be used by both nodes C and D to address a message to node A.
439 Note that this is only for
440 .Em control messages .
441 Data messages are routed one hop at a time, by specifying the departing
442 hook, with each node making the next routing decision. So when B
443 receives a frame on hook
445 it decodes the frame relay header to determine the DLCI,
446 and then forwards the unwrapped frame to either C or D.
447 .Sh Netgraph Structures
448 Interesting members of the node and hook structures are shown below:
451 char *name; /* Optional globally unique name */
452 void *private; /* Node implementation private info */
453 struct ng_type *type; /* The type of this node */
454 int refs; /* Number of references to this struct */
455 int numhooks; /* Number of connected hooks */
456 hook_p hooks; /* Linked list of (connected) hooks */
458 typedef struct ng_node *node_p;
461 char *name; /* This node's name for this hook */
462 void *private; /* Node implementation private info */
463 int refs; /* Number of references to this struct */
464 struct ng_node *node; /* The node this hook is attached to */
465 struct ng_hook *peer; /* The other hook in this connected pair */
466 struct ng_hook *next; /* Next in list of hooks for this node */
468 typedef struct ng_hook *hook_p;
471 The maintenance of the name pointers, reference counts, and linked list
472 of hooks for each node is handled automatically by the
475 Typically a node's private info contains a back-pointer to the node or hook
476 structure, which counts as a new reference that must be registered by
480 From a hook you can obtain the corresponding node, and from
481 a node the list of all active hooks.
483 Node types are described by these structures:
485 /** How to convert a control message from binary <-> ASCII */
487 u_int32_t cookie; /* typecookie */
488 int cmd; /* command number */
489 const char *name; /* command name */
490 const struct ng_parse_type *mesgType; /* args if !NGF_RESP */
491 const struct ng_parse_type *respType; /* args if NGF_RESP */
495 u_int32_t version; /* Must equal NG_VERSION */
496 const char *name; /* Unique type name */
498 /* Module event handler */
499 modeventhand_t mod_event; /* Handle load/unload (optional) */
502 int (*constructor)(node_p *node); /* Create a new node */
504 /** Methods using the node **/
505 int (*rcvmsg)(node_p node, /* Receive control message */
506 struct ng_mesg *msg, /* The message */
507 const char *retaddr, /* Return address */
508 struct ng_mesg **resp); /* Synchronous response */
509 int (*shutdown)(node_p node); /* Shutdown this node */
510 int (*newhook)(node_p node, /* create a new hook */
511 hook_p hook, /* Pre-allocated struct */
512 const char *name); /* Name for new hook */
514 /** Methods using the hook **/
515 int (*connect)(hook_p hook); /* Confirm new hook attachment */
516 int (*rcvdata)(hook_p hook, /* Receive data on a hook */
517 struct mbuf *m, /* The data in an mbuf */
518 meta_p meta); /* Meta-data, if any */
519 int (*disconnect)(hook_p hook); /* Notify disconnection of hook */
521 /** How to convert control messages binary <-> ASCII */
522 const struct ng_cmdlist *cmdlist; /* Optional; may be NULL */
526 Control messages have the following structure:
528 #define NG_CMDSTRSIZ 16 /* Max command string (including null) */
532 u_char version; /* Must equal NG_VERSION */
533 u_char spare; /* Pad to 2 bytes */
534 u_short arglen; /* Length of cmd/resp data */
535 u_long flags; /* Message status flags */
536 u_long token; /* Reply should have the same token */
537 u_long typecookie; /* Node type understanding this message */
538 u_long cmd; /* Command identifier */
539 u_char cmdstr[NG_CMDSTRSIZ]; /* Cmd string (for debug) */
541 char data[0]; /* Start of cmd/resp data */
544 #define NG_VERSION 1 /* Netgraph version */
545 #define NGF_ORIG 0x0000 /* Command */
546 #define NGF_RESP 0x0001 /* Response */
549 Control messages have the fixed header shown above, followed by a
550 variable length data section which depends on the type cookie
551 and the command. Each field is explained below:
554 Indicates the version of netgraph itself. The current version is
557 This is the length of any extra arguments, which begin at
560 Indicates whether this is a command or a response control message.
564 is a means by which a sender can match a reply message to the
565 corresponding command message; the reply always has the same token.
568 The corresponding node type's unique 32-bit value.
569 If a node doesn't recognize the type cookie it must reject the message
573 Each type should have an include file that defines the commands,
574 argument format, and cookie for its own messages.
576 insures that the same header file was included by both sender and
577 receiver; when an incompatible change in the header file is made,
581 The de facto method for generating unique type cookies is to take the
582 seconds from the epoch at the time the header file is written
584 .Dv "date -u +'%s'" ) .
586 There is a predefined typecookie
587 .Dv NGM_GENERIC_COOKIE
591 a corresponding set of generic messages which all nodes understand.
592 The handling of these messages is automatic.
594 The identifier for the message command. This is type specific,
595 and is defined in the same header file as the typecookie.
597 Room for a short human readable version of
599 (for debugging purposes only).
602 Some modules may choose to implement messages from more than one
603 of the header files and thus recognize more than one type cookie.
604 .Sh Control Message ASCII Form
605 Control messages are in binary format for efficiency. However, for
606 debugging and human interface purposes, and if the node type supports
607 it, control messages may be converted to and from an equivalent
611 form is similar to the binary form, with two exceptions:
613 .Bl -tag -compact -width xxx
617 header field must contain the
619 name of the command, corresponding to the
625 field contains a NUL-terminated
627 string version of the message arguments.
630 In general, the arguments field of a control message can be any
631 arbitrary C data type. Netgraph includes parsing routines to support
632 some pre-defined datatypes in
634 with this simple syntax:
636 .Bl -tag -compact -width xxx
638 Integer types are represented by base 8, 10, or 16 numbers.
640 Strings are enclosed in double quotes and respect the normal
641 C language backslash escapes.
643 IP addresses have the obvious form.
645 Arrays are enclosed in square brackets, with the elements listed
646 consecutively starting at index zero. An element may have an optional
647 index and equals sign preceding it. Whenever an element
648 does not have an explicit index, the index is implicitly the previous
649 element's index plus one.
651 Structures are enclosed in curly braces, and each field is specified
653 .Dq fieldname=value .
655 Any array element or structure field whose value is equal to its
657 may be omitted. For integer types, the default value
658 is usually zero; for string types, the empty string.
660 Array elements and structure fields may be specified in any order.
663 Each node type may define its own arbitrary types by providing
664 the necessary routines to parse and unparse.
667 for a specific node type are documented in the documentation for
669 .Sh Generic Control Messages
670 There are a number of standard predefined messages that will work
671 for any node, as they are supported directly by the framework itself.
673 .In netgraph/ng_message.h
674 along with the basic layout of messages and other similar information.
677 Connect to another node, using the supplied hook names on either end.
679 Construct a node of the given type and then connect to it using the
682 The target node should disconnect from all its neighbours and shut down.
683 Persistent nodes such as those representing physical hardware
684 might not disappear from the node namespace, but only reset themselves.
685 The node must disconnect all of its hooks.
686 This may result in neighbors shutting themselves down, and possibly a
687 cascading shutdown of the entire connected graph.
689 Assign a name to a node. Nodes can exist without having a name, and this
690 is the default for nodes created using the
692 method. Such nodes can only be addressed relatively or by their ID number.
694 Ask the node to break a hook connection to one of its neighbours.
695 Both nodes will have their
698 Either node may elect to totally shut down as a result.
700 Asks the target node to describe itself. The four returned fields
701 are the node name (if named), the node type, the node ID and the
702 number of hooks attached. The ID is an internal number unique to that node.
704 This returns the information given by
707 includes an array of fields describing each link, and the description for
708 the node at the far end of that link.
710 This returns an array of node descriptions (as for
712 where each entry of the array describes a named node.
713 All named nodes will be described.
717 except that all nodes are listed regardless of whether they have a name or not.
719 This returns a list of all currently installed netgraph types.
720 .It Dv NGM_TEXT_STATUS
721 The node may return a text formatted status message.
722 The status information is determined entirely by the node type.
723 It is the only "generic" message
724 that requires any support within the node itself and as such the node may
725 elect to not support this message. The text response must be less than
727 bytes in length (presently 1024). This can be used to return general
728 status information in human readable form.
729 .It Dv NGM_BINARY2ASCII
730 This message converts a binary control message to its
733 The entire control message to be converted is contained within the
734 arguments field of the
736 message itself. If successful, the reply will contain the same control
740 A node will typically only know how to translate messages that it
741 itself understands, so the target node of the
743 is often the same node that would actually receive that message.
744 .It Dv NGM_ASCII2BINARY
746 .Dv NGM_BINARY2ASCII .
747 The entire control message to be converted, in
750 in the arguments section of the
752 and need only have the
757 header fields filled in, plus the NUL-terminated string version of
758 the arguments in the arguments field. If successful, the reply
759 contains the binary version of the control message.
762 Data moving through the
764 system can be accompanied by meta-data that describes some
765 aspect of that data. The form of the meta-data is a fixed header,
766 which contains enough information for most uses, and can optionally
767 be supplemented by trailing
769 structures, which contain a
771 (see the section on control messages), an identifier, a length and optional
772 data. If a node does not recognize the cookie associated with an option,
773 it should ignore that option.
775 Meta data might include such things as priority, discard eligibility,
776 or special processing requirements. It might also mark a packet for
777 debug status, etc. The use of meta-data is still experimental.
781 code may either be statically compiled
782 into the kernel or else loaded dynamically as a KLD via
784 In the former case, include
786 .D1 Cd options NETGRAPH
788 in your kernel configuration file. You may also include selected
789 node types in the kernel compilation, for example:
790 .Bd -unfilled -offset indent
792 .Cd options NETGRAPH_SOCKET
793 .Cd options NETGRAPH_ECHO
798 subsystem is loaded, individual node types may be loaded at any time
803 knows how to automatically do this; when a request to create a new
808 will attempt to load the KLD module
811 Types can also be installed at boot time, as certain device drivers
812 may want to export each instance of the device as a netgraph node.
814 In general, new types can be installed at any time from within the
817 supplying a pointer to the type's
823 macro automates this process by using a linker set.
824 .Sh EXISTING NODE TYPES
825 Several node types currently exist. Each is fully documented
829 The socket type implements two new sockets in the new protocol domain
831 The new sockets protocols are
837 Typically one of each is associated with a socket node.
838 When both sockets have closed, the node will shut down. The
840 socket is used for sending and receiving data, while the
842 socket is used for sending and receiving control messages.
843 Data and control messages are passed using the
848 .Dv struct sockaddr_ng
852 Responds only to generic messages and is a
854 for data, Useful for testing. Always accepts new hooks.
857 Responds only to generic messages and always echoes data back through the
858 hook from which it arrived. Returns any non generic messages as their
859 own response. Useful for testing. Always accepts new hooks.
862 This node is useful for
870 Data entering from the right is passed to the left and duplicated on
872 and data entering from the left is passed to the right and
877 is sent to the right and data from
882 Encapsulates/de-encapsulates frames encoded according to RFC 1490.
883 Has a hook for the encapsulated packets
886 for each protocol (i.e., IP, PPP, etc.).
889 Encapsulates/de-encapsulates Frame Relay frames.
890 Has a hook for the encapsulated packets
896 Automatically handles frame relay
898 (link management interface) operations and packets.
899 Automatically probes and detects which of several LMI standards
900 is in use at the exchange.
903 This node is also a line discipline. It simply converts between mbuf
904 frames and sequential serial data, allowing a tty to appear as a netgraph
905 node. It has a programmable
910 This node encapsulates and de-encapsulates asynchronous frames
911 according to RFC 1662. This is used in conjunction with the TTY node
912 type for supporting PPP links over asynchronous serial lines.
915 This node is also a system networking interface. It has hooks representing
916 each protocol family (IP, AppleTalk, IPX, etc.) and appears in the output of
918 The interfaces are named
924 Whether a named node exists can be checked by trying to send a control message
927 If it does not exist,
931 All data messages are mbuf chains with the M_PKTHDR flag set.
933 Nodes are responsible for freeing what they allocate.
934 There are three exceptions:
937 Mbufs sent across a data link are never to be freed by the sender.
939 Any meta-data information traveling with the data has the same restriction.
940 It might be freed by any node the data passes through, and a
942 passed onwards, but the caller will never free it.
944 .Fn NG_FREE_META "meta"
946 .Fn NG_FREE_DATA "m" "meta"
947 should be used if possible to free data and meta data (see
948 .In netgraph/netgraph.h ) .
952 are freed by the callee. As in the case above, the addresses
953 associated with the message are freed by whatever allocated them so the
954 recipient should copy them if it wants to keep that information.
957 .Bl -tag -width xxxxx -compact
958 .It In netgraph/netgraph.h
959 Definitions for use solely within the kernel by
962 .It In netgraph/ng_message.h
963 Definitions needed by any file that needs to deal with
966 .It In netgraph/socket/ng_socket.h
967 Definitions needed to use
970 .It In netgraph/{type}/ng_{type}.h
971 Definitions needed to use
974 nodes, including the type cookie definition.
975 .It Pa /boot/modules/netgraph.ko
976 Netgraph subsystem loadable KLD module.
977 .It Pa /boot/modules/ng_{type}.ko
978 Loadable KLD module for node type {type}.
980 .Sh USER MODE SUPPORT
981 There is a library for supporting user-mode programs that wish
982 to interact with the netgraph system. See
986 Two user-mode support programs,
990 are available to assist manual configuration and debugging.
992 There are a few useful techniques for debugging new node types.
993 First, implementing new node types in user-mode first
994 makes debugging easier.
997 node type is also useful for debugging, especially in conjunction with
1012 .Xr ng_frame_relay 4 ,
1033 system was designed and first implemented at Whistle Communications, Inc.\&
1036 customized for the Whistle InterJet.
1037 It first made its debut in the main tree in
1041 .An Julian Elischer Aq julian@FreeBSD.org ,
1042 with contributions by
1043 .An Archie Cobbs Aq archie@FreeBSD.org .