summaryrefslogtreecommitdiff
path: root/static/netbsd/man4/pim.4 3.html
blob: 9e21732068164ff6d62e00d4a5255dced68a8c11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<table class="head">
  <tr>
    <td class="head-ltitle">PIM(4)</td>
    <td class="head-vol">Device Drivers Manual</td>
    <td class="head-rtitle">PIM(4)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">pim</code> &#x2014; <span class="Nd">Protocol
    Independent Multicast</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="Cd">options MROUTING</code>
  <br/>
  <code class="Cd">options PIM</code></p>
<p class="Pp">
  <br/>
  <code class="In">#include &lt;<a class="In">sys/types.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">sys/socket.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">netinet/in.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">netinet/ip_mroute.h</a>&gt;</code>
  <br/>
  <code class="In">#include &lt;<a class="In">netinet/pim.h</a>&gt;</code></p>
<p class="Pp"><var class="Ft">int</var>
  <br/>
  <code class="Fn">getsockopt</code>(<var class="Fa" style="white-space: nowrap;">int
    s</var>, <var class="Fa" style="white-space: nowrap;">IPPROTO_IP</var>,
    <var class="Fa" style="white-space: nowrap;">MRT_PIM</var>,
    <var class="Fa" style="white-space: nowrap;">void *optval</var>,
    <var class="Fa" style="white-space: nowrap;">socklen_t *optlen</var>);</p>
<p class="Pp"><var class="Ft">int</var>
  <br/>
  <code class="Fn">setsockopt</code>(<var class="Fa" style="white-space: nowrap;">int
    s</var>, <var class="Fa" style="white-space: nowrap;">IPPROTO_IP</var>,
    <var class="Fa" style="white-space: nowrap;">MRT_PIM</var>,
    <var class="Fa" style="white-space: nowrap;">const void *optval</var>,
    <var class="Fa" style="white-space: nowrap;">socklen_t optlen</var>);</p>
<p class="Pp"><var class="Ft">int</var>
  <br/>
  <code class="Fn">getsockopt</code>(<var class="Fa" style="white-space: nowrap;">int
    s</var>, <var class="Fa" style="white-space: nowrap;">IPPROTO_IPV6</var>,
    <var class="Fa" style="white-space: nowrap;">MRT6_PIM</var>,
    <var class="Fa" style="white-space: nowrap;">void *optval</var>,
    <var class="Fa" style="white-space: nowrap;">socklen_t *optlen</var>);</p>
<p class="Pp"><var class="Ft">int</var>
  <br/>
  <code class="Fn">setsockopt</code>(<var class="Fa" style="white-space: nowrap;">int
    s</var>, <var class="Fa" style="white-space: nowrap;">IPPROTO_IPV6</var>,
    <var class="Fa" style="white-space: nowrap;">MRT6_PIM</var>,
    <var class="Fa" style="white-space: nowrap;">const void *optval</var>,
    <var class="Fa" style="white-space: nowrap;">socklen_t optlen</var>);</p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">PIM is the common name for two multicast routing protocols:
    Protocol Independent Multicast - Sparse Mode (PIM-SM) and Protocol
    Independent Multicast - Dense Mode (PIM-DM).</p>
<p class="Pp">PIM-SM is a multicast routing protocol that can use the underlying
    unicast routing information base or a separate multicast-capable routing
    information base. It builds unidirectional shared trees rooted at a
    Rendezvous Point (RP) per group, and optionally creates shortest-path trees
    per source.</p>
<p class="Pp">PIM-DM is a multicast routing protocol that uses the underlying
    unicast routing information base to flood multicast datagrams to all
    multicast routers. Prune messages are used to prevent future datagrams from
    propagating to routers with no group membership information.</p>
<p class="Pp">Both PIM-SM and PIM-DM are fairly complex protocols, though PIM-SM
    is much more complex. To enable PIM-SM or PIM-DM multicast routing in a
    router, the user must enable multicast routing and PIM processing in the
    kernel (see <a class="Sx" href="#SYNOPSIS">SYNOPSIS</a> about the kernel
    configuration options), and must run a PIM-SM or PIM-DM capable user-level
    process. From developer's point of view, the programming guide described in
    the <a class="Sx" href="#Programming_Guide">Programming Guide</a> section
    should be used to control the PIM processing in the kernel.</p>
<section class="Ss">
<h2 class="Ss" id="Programming_Guide"><a class="permalink" href="#Programming_Guide">Programming
  Guide</a></h2>
<p class="Pp">After a multicast routing socket is open and multicast forwarding
    is enabled in the kernel (see <a class="Xr">multicast(4)</a>), one of the
    following socket options should be used to enable or disable PIM processing
    in the kernel. Note that those options require certain privilege (i.e., root
    privilege):</p>
<div class="Bd Pp Li">
<pre>/* IPv4 */
int v = 1;        /* 1 to enable, or 0 to disable */
setsockopt(mrouter_s4, IPPROTO_IP, MRT_PIM, (void *)&amp;v, sizeof(v));</pre>
</div>
<div class="Bd Pp Li">
<pre>/* IPv6 */
int v = 1;        /* 1 to enable, or 0 to disable */
setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_PIM, (void *)&amp;v, sizeof(v));</pre>
</div>
<p class="Pp">After PIM processing is enabled, the multicast-capable interfaces
    should be added (see <a class="Xr">multicast(4)</a>). In case of PIM-SM, the
    PIM-Register virtual interface must be added as well. This can be
    accomplished by using the following options:</p>
<div class="Bd Pp Li">
<pre>/* IPv4 */
struct vifctl vc;
memset(&amp;vc, 0, sizeof(vc));
/* Assign all vifctl fields as appropriate */
...
if (is_pim_register_vif)
    vc.vifc_flags |= VIFF_REGISTER;
setsockopt(mrouter_s4, IPPROTO_IP, MRT_ADD_VIF, (void *)&amp;vc,
           sizeof(vc));</pre>
</div>
<div class="Bd Pp Li">
<pre>/* IPv6 */
struct mif6ctl mc;
memset(&amp;mc, 0, sizeof(mc));
/* Assign all mif6ctl fields as appropriate */
...
if (is_pim_register_vif)
    mc.mif6c_flags |= MIFF_REGISTER;
setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_ADD_MIF, (void *)&amp;mc,
           sizeof(mc));</pre>
</div>
<p class="Pp">Sending or receiving of PIM packets can be accomplished by opening
    first a &#x201C;raw socket&#x201D; (see <a class="Xr">socket(2)</a>), with
    protocol value of <code class="Dv">IPPROTO_PIM</code>:</p>
<div class="Bd Pp Li">
<pre>/* IPv4 */
int pim_s4;
pim_s4 = socket(AF_INET, SOCK_RAW, IPPROTO_PIM);</pre>
</div>
<div class="Bd Pp Li">
<pre>/* IPv6 */
int pim_s6;
pim_s6 = socket(AF_INET6, SOCK_RAW, IPPROTO_PIM);</pre>
</div>
<p class="Pp">Then, the following system calls can be used to send or receive
    PIM packets: <a class="Xr">sendto(2)</a>, <a class="Xr">sendmsg(2)</a>,
    <a class="Xr">recvfrom(2)</a>, <a class="Xr">recvmsg(2)</a>.</p>
</section>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr">getsockopt(2)</a>, <a class="Xr">recvfrom(2)</a>,
    <a class="Xr">recvmsg(2)</a>, <a class="Xr">sendmsg(2)</a>,
    <a class="Xr">sendto(2)</a>, <a class="Xr">setsockopt(2)</a>,
    <a class="Xr">socket(2)</a>, <a class="Xr">inet(4)</a>,
    <a class="Xr">intro(4)</a>, <a class="Xr">ip(4)</a>,
    <a class="Xr">multicast(4)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="STANDARDS"><a class="permalink" href="#STANDARDS">STANDARDS</a></h1>
<p class="Pp">The PIM-SM protocol is specified in RFC 2362 (to be replaced by
    <span class="RsT">draft-ietf-pim-sm-v2-new-*).</span> The PIM-DM protocol is
    specified in <span class="RsT">draft-ietf-pim-dm-new-v2-*).</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp">The original IPv4 PIM kernel support for IRIX and SunOS-4.x was
    implemented by <span class="An">Ahmed Helmy</span> (USC and SGI). Later the
    code was ported to various <span class="Ux">BSD</span> flavors and modified
    by <span class="An">George Edmond Eddy</span> (Rusty) (ISI),
    <span class="An">Hitoshi Asaeda</span> (WIDE Project), and
    <span class="An">Pavlin Radoslavov</span> (USC/ISI and ICSI). The IPv6 PIM
    kernel support was implemented by the KAME project
    (<a class="Lk" href="http://www.kame.net">http://www.kame.net</a>), and was
    based on the IPv4 PIM kernel support.</p>
<p class="Pp">This manual page was written by <span class="An">Pavlin
    Radoslavov</span> (ICSI).</p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">September 4, 2003</td>
    <td class="foot-os">NetBSD 10.1</td>
  </tr>
</table>