Deleted Added
full compact
ngctl (122758) ngctl (222179)
1# $FreeBSD: head/share/examples/netgraph/ngctl 122758 2003-11-15 15:26:35Z harti $
1# $FreeBSD: head/share/examples/netgraph/ngctl 222179 2011-05-22 14:23:48Z uqs $
2
3#
4# This is an example that shows how to send ASCII formatted control
5# messages to a node using ngctl(8).
6#
7# What we will do here create a divert(4) tap. This simply dumps
8# out all packets diverted by some ipfw(8) divert rule to the console.
9#

--- 31 unchanged lines hidden (view full) ---

41# node, which tells it what kind of socket to create.
42
43# Lets give our ksocket node a global name. How about ``fred'':
44
45 + name foo fred
46
47# Note that we used ngctl's ``name'' command to do this. However,
48# the following manually constructed netgraph message would have
2
3#
4# This is an example that shows how to send ASCII formatted control
5# messages to a node using ngctl(8).
6#
7# What we will do here create a divert(4) tap. This simply dumps
8# out all packets diverted by some ipfw(8) divert rule to the console.
9#

--- 31 unchanged lines hidden (view full) ---

41# node, which tells it what kind of socket to create.
42
43# Lets give our ksocket node a global name. How about ``fred'':
44
45 + name foo fred
46
47# Note that we used ngctl's ``name'' command to do this. However,
48# the following manually constructed netgraph message would have
49# acomplished the exact same thing:
49# accomplished the exact same thing:
50
51 + msg foo name { name="fred" }
52
53# Here we are using the ASCII <-> binary control message conversion
54# routines. ngctl does this for us automatically when we use the
55# ``msg'' command.
56
57# Now lets bind the socket associated with the ksocket node to a port

--- 22 unchanged lines hidden (view full) ---

80# number, we need to do a ``getname'' to see what port number we got:
81
82 + msg fred: getname
83 Rec'd response "getname" (5) from "fred:":
84 Args: inet/192.168.1.1:1029
85
86# As soon as we sent the message, we got back a response. Here
87# ngctl is telling us that it received a control message with the
50
51 + msg foo name { name="fred" }
52
53# Here we are using the ASCII <-> binary control message conversion
54# routines. ngctl does this for us automatically when we use the
55# ``msg'' command.
56
57# Now lets bind the socket associated with the ksocket node to a port

--- 22 unchanged lines hidden (view full) ---

80# number, we need to do a ``getname'' to see what port number we got:
81
82 + msg fred: getname
83 Rec'd response "getname" (5) from "fred:":
84 Args: inet/192.168.1.1:1029
85
86# As soon as we sent the message, we got back a response. Here
87# ngctl is telling us that it received a control message with the
88# NGF_RESP (response) flag set, the reponse was to a prior ``getname''
88# NGF_RESP (response) flag set, the response was to a prior ``getname''
89# control message, that the originator was the node addressable
90# as ``fred:''. The message arguments field is then displayed to
91# us in its ASCII form. In this case, what we get back is a struct
92# sockaddr, and there we see that our port number is 1029.
93
94# So now let's add the ipfw divert rule for whatever packets we
95# want to see. How about anything from 192.168.1.129.
96

--- 77 unchanged lines hidden ---
89# control message, that the originator was the node addressable
90# as ``fred:''. The message arguments field is then displayed to
91# us in its ASCII form. In this case, what we get back is a struct
92# sockaddr, and there we see that our port number is 1029.
93
94# So now let's add the ipfw divert rule for whatever packets we
95# want to see. How about anything from 192.168.1.129.
96

--- 77 unchanged lines hidden ---