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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005
|
<pre>Network Working Group D. Thaler
Request for Comments: 3678 Microsoft
Category: Informational B. Fenner
AT&T Research
B. Quinn
Stardust.com
January 2004
<span class="h1">Socket Interface Extensions for Multicast Source Filters</span>
Status of this Memo
This memo provides information for the Internet community. It does
not specify an Internet standard of any kind. Distribution of this
memo is unlimited.
Copyright Notice
Copyright (C) The Internet Society (2004). All Rights Reserved.
Abstract
The Internet Group Management Protocol (IGMPv3) for IPv4 and the
Multicast Listener Discovery (MLDv2) for IPv6 add the capability for
applications to express source filters on multicast group
memberships, which allows receiver applications to determine the set
of senders (sources) from which to accept multicast traffic. This
capability also simplifies support of one-to-many type multicast
applications.
This document specifies new socket options and functions to manage
source filters for IP Multicast group memberships. It also defines
the socket structures to provide input and output arguments to these
new application program interfaces (APIs). These extensions are
designed to provide access to the source filtering features, while
introducing a minimum of change into the system and providing
complete compatibility for existing multicast applications.
Table of Contents
<a href="#section-1">1</a>. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-2">2</a>
<a href="#section-2">2</a>. Design Considerations. . . . . . . . . . . . . . . . . . . . . <a href="#page-3">3</a>
<a href="#section-2.1">2.1</a> What Needs to be Added . . . . . . . . . . . . . . . . . . <a href="#page-4">4</a>
<a href="#section-2.2">2.2</a> Data Types . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-4">4</a>
<a href="#section-2.3">2.3</a> Headers. . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-4">4</a>
<a href="#section-2.4">2.4</a> Structures . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-4">4</a>
<a href="#section-3">3</a>. Overview of APIs. . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-5">5</a>
<span class="grey">Thaler, et al. Informational [Page 1]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
<a href="#section-4">4</a>. IPv4 Multicast Source Filter APIs . . . . . . . . . . . . . . . <a href="#page-6">6</a>
<a href="#section-4.1">4.1</a> Basic (Delta-based) API for IPv4. . . . . . . . . . . . . . <a href="#page-6">6</a>
<a href="#section-4.1.1">4.1.1</a> IPv4 Any-Source Multicast API. . . . . . . . . . . . <a href="#page-7">7</a>
<a href="#section-4.1.2">4.1.2</a> IPv4 Source-Specific Multicast API . . . . . . . . . <a href="#page-7">7</a>
<a href="#section-4.1.3">4.1.3</a> Error Codes. . . . . . . . . . . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-4.2">4.2</a> Advanced (Full-state) API for IPv4. . . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-4.2.1">4.2.1</a> Set Source Filter. . . . . . . . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-4.2.2">4.2.2</a> Get Source Filter. . . . . . . . . . . . . . . . . . <a href="#page-9">9</a>
5: Protocol-Independent Multicast Source Filter APIs . . . . . . . <a href="#page-10">10</a>
<a href="#section-5.1">5.1</a> Basic (Delta-based) API . . . . . . . . . . . . . . . . . . <a href="#page-10">10</a>
<a href="#section-5.1.1">5.1.1</a> Any-Source Multicast API . . . . . . . . . . . . . . <a href="#page-11">11</a>
<a href="#section-5.1.2">5.1.2</a> Source-Specific Multicast API. . . . . . . . . . . . <a href="#page-11">11</a>
<a href="#section-5.2">5.2</a> Advanced (Full-state) API . . . . . . . . . . . . . . . . . <a href="#page-11">11</a>
<a href="#section-5.2.1">5.2.1</a> Set Source Filter. . . . . . . . . . . . . . . . . . <a href="#page-11">11</a>
<a href="#section-5.2.2">5.2.2</a> Get Source Filter. . . . . . . . . . . . . . . . . . <a href="#page-12">12</a>
<a href="#section-6">6</a>. Security Considerations. . . . . . . . . . . . . . . . . . . . <a href="#page-13">13</a>
<a href="#section-7">7</a>. Acknowledgments. . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-13">13</a>
<a href="#section-8">8</a>. <a href="#appendix-A">Appendix A</a>: Use of ioctl() for full-state operations . . . . . <a href="#page-14">14</a>
<a href="#section-8.1">8.1</a>. IPv4 Options. . . . . . . . . . . . . . . . . . . . . . . <a href="#page-14">14</a>
<a href="#section-8.2">8.2</a>. Protocol-Independent Options. . . . . . . . . . . . . . . <a href="#page-15">15</a>
<a href="#section-9">9</a>. Normative References . . . . . . . . . . . . . . . . . . . . . <a href="#page-16">16</a>
<a href="#section-10">10</a>. Informative References . . . . . . . . . . . . . . . . . . . . <a href="#page-16">16</a>
<a href="#section-11">11</a>. Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . <a href="#page-17">17</a>
<a href="#section-12">12</a>. Full Copyright Statement . . . . . . . . . . . . . . . . . . . <a href="#page-18">18</a>
<span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction</span>
The de facto standard application program interface (API) for TCP/IP
applications is the "sockets" interface. Although this API was
developed for Unix in the early 1980s it has also been implemented on
a wide variety of non-Unix systems. TCP/IP applications written
using the sockets API have in the past enjoyed a high degree of
portability and we would like the same portability with applications
that employ multicast source filters. Changes are required to the
sockets API to support such filtering and this memo describes these
changes.
This document specifies new socket options and functions to manage
source filters for IP Multicast group memberships. It also defines
the socket structures to provide input and output arguments to these
new APIs. These extensions are designed to provide access to the
source filtering features required by applications, while introducing
a minimum of change into the system and providing complete
compatibility for existing multicast applications.
Furthermore, <a href="./rfc3493">RFC 3493</a> [<a href="#ref-1" title=""Basic Socket Interface Extensions for IPv6"">1</a>] defines socket interface extensions for
IPv6, including protocol-independent functions for most operations.
<span class="grey">Thaler, et al. Informational [Page 2]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
However, while it defines join and leave functions for IPv6, it does
not provide protocol-independent versions of these operations. Such
functions will be described in this document.
The reader should note that this document is for informational
purposes only, and that the official standard specification of the
sockets API is [<a href="#ref-2" title="Issue 6">2</a>].
<span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Design Considerations</span>
There are a number of important considerations in designing changes
to this well-worn API:
o The API changes should provide both source and binary
compatibility for programs written to the original API. That
is, existing program binaries should continue to operate when
run on a system supporting the new API. In addition, existing
applications that are re-compiled and run on a system
supporting the new API should continue to operate. Simply put,
the API changes for multicast receivers that specify source
filters should not break existing programs.
o The changes to the API should be as small as possible in order
to simplify the task of converting existing multicast receiver
applications to use source filters.
o Applications should be able to detect when the new source
filter APIs are unavailable (e.g., calls fail with the ENOTSUPP
error) and react gracefully (e.g., revert to old non-source-
filter API or display a meaningful error message to the user).
o Lack of type-safety in an API is a bad thing which should be
avoided when possible.
Several implementations exist that use ioctl() for a portion of the
functionality described herein, and for historical purposes, the
ioctl API is documented in <a href="#appendix-A">Appendix A</a>. The preferred API, however,
includes new functions. The reasons for adding new functions are:
o New functions provide type-safety, unlike ioctl, getsockopt,
and setsockopt.
o A new function can be written as a wrapper over an ioctl,
getsockopt, or setsockopt call, if necessary. Hence, it
provides more freedom as to how the functionality is
implemented in an operating system. For example, a new
function might be implemented as an inline function in an
<span class="grey">Thaler, et al. Informational [Page 3]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
include file, or a function exported from a user-mode library
which internally uses some mechanism to exchange information
with the kernel, or be implemented directly in the kernel.
o At least one operation defined herein needs to be able to both
pass information to the TCP/IP stack, as well as retrieve
information from it. In some implementations this is
problematic without either changing getsockopt or using ioctl.
Using new functions avoids the need to change such
implementations.
<span class="h3"><a class="selflink" id="section-2.1" href="#section-2.1">2.1</a>. What Needs to be Added</span>
The current IP Multicast APIs allow a receiver application to specify
the group address (destination) and (optionally) the local interface.
These existing APIs need not change (and cannot, to retain binary
compatibility). Hence, what is needed are new source filter APIs
that provide the same functionality and also allow receiver multicast
applications to:
o Specify zero or more unicast (source) address(es) in a source
filter.
o Determine whether the source filter describes an inclusive or
exclusive list of sources.
The new API design must enable this functionality for both IPv4 and
IPv6.
<span class="h3"><a class="selflink" id="section-2.2" href="#section-2.2">2.2</a>. Data Types</span>
The data types of the structure elements given in this memo are
intended to be examples, not absolute requirements. Whenever
possible, data types from POSIX 1003.1g [<a href="#ref-2" title="Issue 6">2</a>] are used: uintN_t means
an unsigned integer of exactly N bits (e.g., uint32_t).
<span class="h3"><a class="selflink" id="section-2.3" href="#section-2.3">2.3</a>. Headers</span>
When function prototypes and structures are shown, we show the
headers that must be #included to cause that item to be defined.
<span class="h3"><a class="selflink" id="section-2.4" href="#section-2.4">2.4</a>. Structures</span>
When structures are described, the members shown are the ones that
must appear in an implementation. Additional, nonstandard members
may also be defined by an implementation. As an additional
<span class="grey">Thaler, et al. Informational [Page 4]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
precaution, nonstandard members could be verified by Feature Test
Macros as described in [<a href="#ref-2" title="Issue 6">2</a>]. (Such Feature Test Macros are not
defined by this RFC.)
The ordering shown for the members of a structure is the recommended
ordering, given alignment considerations of multibyte members, but an
implementation may order the members differently.
<span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. Overview of APIs</span>
There are a number of different APIs described in this document that
are appropriate for a number of different application types and IP
versions. Before providing detailed descriptions, this section
provides a "taxonomy" with a brief description of each.
There are two categories of source-filter APIs, both of which are
designed to allow multicast receiver applications to designate the
unicast address(es) of sender(s) along with the multicast group
(destination address) to receive.
o Basic (Delta-based): Some applications desire the simplicity of
a delta-based API in which each function call specifies a
single source address which should be added to or removed from
the existing filter for a given multicast group address on
which to listen. Such applications typically fall into either
of two categories:
+ Any-Source Multicast: By default, all sources are accepted.
Individual sources may be turned off and back on as needed
over time. This is also known as "exclude" mode, since the
source filter contains a list of excluded sources.
+ Source-Specific Multicast: Only sources in a given list are
allowed. The list may change over time. This is also known
as "include" mode, since the source filter contains a list
of included sources.
This API would be used, for example, by "single-source"
applications such as audio/video broadcasting. It would
also be used for logical multi-source sessions where each
source independently allocates its own Source-Specific
Multicast group address.
o Advanced (Full-state): This API allows an application to define
a complete source-filter comprised of zero or more source
addresses, and replace the previous filter with a new one.
<span class="grey">Thaler, et al. Informational [Page 5]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
Applications which require the ability to switch between filter
modes without leaving a group must use a full-state API (i.e.,
to change the semantics of the source filter from inclusive to
exclusive, or vice versa).
Applications which use a large source list for a given group
address should also use the full-state API, since filter
changes can be done atomically in a single operation.
The above types of APIs exist in IPv4-specific variants as well as
with protocol-independent variants. One might ask why the protocol-
independent APIs cannot accommodate IPv4 applications as well as
IPv6. Since any IPv4 application requires modification to use
multicast source filters anyway, it might seem like a good
opportunity to create IPv6-compatible source code.
The primary reasons for extending an IPv4-specific API are:
o To minimize changes needed in existing IPv4 multicast
application source code to add source filter support.
o To avoid overloading APIs to accommodate the differences
between IPv4 interface addresses (e.g., in the ip_mreq
structure) and interface indices.
<span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. IPv4 Multicast Source Filter APIs</span>
Version 3 of the Internet Group Management Protocol (IGMPv3) [<a href="#ref-3" title=""Internet Group Management Protocol, Version 3"">3</a>] and
version 2 of the Multicast Listener Discovery (MLDv2) protocol [<a href="#ref-4" title=""Multicast Listener Discovery Version 2 (MLDv2) for IPv6"">4</a>]
provide the ability to communicate source filter information to the
router and hence avoid pulling down data from unwanted sources onto
the local link. However, source filters may be implemented by the
operating system regardless of whether the routers support IGMPv3 or
MLDv2, so when the source-filter API is available, applications can
always benefit from using it.
<span class="h3"><a class="selflink" id="section-4.1" href="#section-4.1">4.1</a>. Basic (Delta-based) API for IPv4</span>
The reception of multicast packets is controlled by the setsockopt()
options summarized below. An error of EOPNOTSUPP is returned if
these options are used with getsockopt().
<span class="grey">Thaler, et al. Informational [Page 6]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
The following structures are used by both the Any-Source Multicast
and the Source-Specific Multicast API:
#include <netinet/in.h>
struct ip_mreq {
struct in_addr imr_multiaddr; /* IP address of group */
struct in_addr imr_interface; /* IP address of interface */
};
struct ip_mreq_source {
struct in_addr imr_multiaddr; /* IP address of group */
struct in_addr imr_sourceaddr; /* IP address of source */
struct in_addr imr_interface; /* IP address of interface */
};
<span class="h4"><a class="selflink" id="section-4.1.1" href="#section-4.1.1">4.1.1</a>. IPv4 Any-Source Multicast API</span>
The following socket options are defined in <netinet/in.h> for
applications in the Any-Source Multicast category:
Socket option Argument type
IP_ADD_MEMBERSHIP struct ip_mreq
IP_BLOCK_SOURCE struct ip_mreq_source
IP_UNBLOCK_SOURCE struct ip_mreq_source
IP_DROP_MEMBERSHIP struct ip_mreq
IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP are already implemented on
most operating systems, and are used to join and leave an any-source
group.
IP_BLOCK_SOURCE can be used to block data from a given source to a
given group (e.g., if the user "mutes" that source), and
IP_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then
"unmutes" the source).
<span class="h4"><a class="selflink" id="section-4.1.2" href="#section-4.1.2">4.1.2</a>. IPv4 Source-Specific Multicast API</span>
The following socket options are available for applications in the
Source-Specific category:
Socket option Argument type
IP_ADD_SOURCE_MEMBERSHIP struct ip_mreq_source
IP_DROP_SOURCE_MEMBERSHIP struct ip_mreq_source
IP_DROP_MEMBERSHIP struct ip_mreq
IP_ADD_SOURCE_MEMBERSHIP and IP_DROP_SOURCE_MEMBERSHIP are used to
join and leave a source-specific group.
<span class="grey">Thaler, et al. Informational [Page 7]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-8" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
IP_DROP_MEMBERSHIP is supported, as a convenience, to drop all
sources which have been joined for a particular group and interface.
The operations are the same as if the socket had been closed.
<span class="h4"><a class="selflink" id="section-4.1.3" href="#section-4.1.3">4.1.3</a>. Error Codes</span>
When the option would be legal on the group, but an address is
invalid (e.g., when trying to block a source that is already blocked
by the socket, or when trying to drop an unjoined group) the error
generated is EADDRNOTAVAIL.
When the option itself is not legal on the group (i.e., when trying a
Source-Specific option on a group after doing IP_ADD_MEMBERSHIP, or
when trying an Any-Source option without doing IP_ADD_MEMBERSHIP) the
error generated is EINVAL.
When any of these options are used with getsockopt(), the error
generated is EOPNOTSUPP.
Finally, if the implementation imposes a limit on the maximum number
of sources in a source filter, ENOBUFS is generated when an operation
would exceed the maximum.
<span class="h3"><a class="selflink" id="section-4.2" href="#section-4.2">4.2</a>. Advanced (Full-state) API for IPv4</span>
Several implementations exist that use ioctl() for this API, and for
historical purposes, the ioctl() API is documented in <a href="#appendix-A">Appendix A</a>.
The preferred API uses the new functions described below.
<span class="h4"><a class="selflink" id="section-4.2.1" href="#section-4.2.1">4.2.1</a>. Set Source Filter</span>
#include <netinet/in.h>
int setipv4sourcefilter(int s, struct in_addr interface,
struct in_addr group, uint32_t fmode,
uint32_t numsrc, struct in_addr *slist);
On success the value 0 is returned, and on failure, the value -1 is
returned and errno is set accordingly.
The s argument identifies the socket.
The interface argument holds the local IP address of the interface.
The group argument holds the IP multicast address of the group.
<span class="grey">Thaler, et al. Informational [Page 8]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-9" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
The fmode argument identifies the filter mode. The value of this
field must be either MCAST_INCLUDE or MCAST_EXCLUDE, which are
likewise defined in <netinet/in.h>.
The numsrc argument holds the number of source addresses in the slist
array.
The slist argument points to an array of IP addresses of sources to
include or exclude depending on the filter mode.
If the implementation imposes a limit on the maximum number of
sources in a source filter, ENOBUFS is generated when the operation
would exceed the maximum.
<span class="h4"><a class="selflink" id="section-4.2.2" href="#section-4.2.2">4.2.2</a>. Get Source Filter</span>
#include <netinet/in.h>
int getipv4sourcefilter(int s, struct in_addr interface,
struct in_addr group, uint32_t *fmode,
uint32_t *numsrc, struct in_addr *slist);
On success the value 0 is returned, and on failure, the value -1 is
returned and errno is set accordingly.
The s argument identifies the socket.
The interface argument holds the local IP address of the interface.
The group argument holds the IP multicast address of the group.
The fmode argument points to an integer that will contain the filter
mode on a successful return. The value of this field will be either
MCAST_INCLUDE or MCAST_EXCLUDE, which are likewise defined in
<netinet/in.h>.
On input, the numsrc argument holds the number of source addresses
that will fit in the slist array. On output, the numsrc argument
will hold the total number of sources in the filter.
The slist argument points to buffer into which an array of IP
addresses of included or excluded (depending on the filter mode)
sources will be written. If numsrc was 0 on input, a NULL pointer
may be supplied.
<span class="grey">Thaler, et al. Informational [Page 9]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-10" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
If the application does not know the size of the source list
beforehand, it can make a reasonable guess (e.g., 0), and if upon
completion, numsrc holds a larger value, the operation can be
repeated with a large enough buffer.
That is, on return, numsrc is always updated to be the total number
of sources in the filter, while slist will hold as many source
addresses as fit, up to the minimum of the array size passed in as
the original numsrc value and the total number of sources in the
filter.
<span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. Protocol-Independent Multicast Source Filter APIs</span>
Protocol-independent functions are provided for join and leave
operations so that an application may pass a sockaddr_storage
structure obtained from calls such as getaddrinfo() [<a href="#ref-1" title=""Basic Socket Interface Extensions for IPv6"">1</a>] as the group
to join. For example, an application can resolve a DNS name (e.g.,
NTP.MCAST.NET) to a multicast address which may be either IPv4 or
IPv6, and may easily join and leave the group.
<span class="h3"><a class="selflink" id="section-5.1" href="#section-5.1">5.1</a>. Basic (Delta-based) API</span>
The reception of multicast packets is controlled by the setsockopt()
options summarized below. An error of EOPNOTSUPP is returned if
these options are used with getsockopt().
The following structures are used by both the Any-Source Multicast
and the Source-Specific Multicast API: #include <netinet/in.h>
struct group_req {
uint32_t gr_interface; /* interface index */
struct sockaddr_storage gr_group; /* group address */
};
struct group_source_req {
uint32_t gsr_interface; /* interface index */
struct sockaddr_storage gsr_group; /* group address */
struct sockaddr_storage gsr_source; /* source address */
};
The sockaddr_storage structure is defined in <a href="./rfc3493">RFC 3493</a> [<a href="#ref-1" title=""Basic Socket Interface Extensions for IPv6"">1</a>] to be large
enough to hold either IPv4 or IPv6 address information.
The rules for generating errors are the same as those given in
<a href="#section-5.1.3">Section 5.1.3</a>.
<span class="grey">Thaler, et al. Informational [Page 10]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-11" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
<span class="h4"><a class="selflink" id="section-5.1.1" href="#section-5.1.1">5.1.1</a>. Any-Source Multicast API</span>
Socket option Argument type
MCAST_JOIN_GROUP struct group_req
MCAST_BLOCK_SOURCE struct group_source_req
MCAST_UNBLOCK_SOURCE struct group_source_req
MCAST_LEAVE_GROUP struct group_req
MCAST_JOIN_GROUP and MCAST_LEAVE_GROUP are used to join and leave an
any-source group.
MCAST_BLOCK_SOURCE can be used to block data from a given source to a
given group (e.g., if the user "mutes" that source), and
MCAST_UNBLOCK_SOURCE can be used to undo this (e.g., if the user then
"unmutes" the source).
<span class="h4"><a class="selflink" id="section-5.1.2" href="#section-5.1.2">5.1.2</a>. Source-Specific Multicast API</span>
Socket option Argument type
MCAST_JOIN_SOURCE_GROUP struct group_source_req
MCAST_LEAVE_SOURCE_GROUP struct group_source_req
MCAST_LEAVE_GROUP struct group_req
MCAST_JOIN_SOURCE_GROUP and MCAST_LEAVE_SOURCE_GROUP are used to join
and leave a source-specific group.
MCAST_LEAVE_GROUP is supported, as a convenience, to drop all sources
which have been joined for a particular group and interface. The
operations are the same as if the socket had been closed.
<span class="h3"><a class="selflink" id="section-5.2" href="#section-5.2">5.2</a>. Advanced (Full-state) API</span>
Implementations may exist that use ioctl() for this API, and for
historical purposes, the ioctl() API is documented in <a href="#appendix-A">Appendix A</a>.
The preferred API uses the new functions described below.
<span class="h4"><a class="selflink" id="section-5.2.1" href="#section-5.2.1">5.2.1</a>. Set Source Filter</span>
#include <netinet/in.h>
int setsourcefilter(int s, uint32_t interface,
struct sockaddr *group, socklen_t grouplen,
uint32_t fmode, uint_t numsrc,
struct sockaddr_storage *slist);
On success the value 0 is returned, and on failure, the value -1 is
returned and errno is set accordingly.
<span class="grey">Thaler, et al. Informational [Page 11]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-12" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
The s argument identifies the socket.
The interface argument holds the interface index of the interface.
The group argument points to either a sockaddr_in structure (for
IPv4) or a sockaddr_in6 structure (for IPv6) that holds the IP
multicast address of the group.
The grouplen argument gives the length of the sockaddr_in or
sockaddr_in6 structure.
The fmode argument identifies the filter mode. The value of this
field must be either MCAST_INCLUDE or MCAST_EXCLUDE, which are
likewise defined in <netinet/in.h>.
The numsrc argument holds the number of source addresses in the slist
array.
The slist argument points to an array of IP addresses of sources to
include or exclude depending on the filter mode.
If the implementation imposes a limit on the maximum number of
sources in a source filter, ENOBUFS is generated when the operation
would exceed the maximum.
<span class="h4"><a class="selflink" id="section-5.2.2" href="#section-5.2.2">5.2.2</a>. Get Source Filter</span>
#include <netinet/in.h>
int getsourcefilter(int s, uint32_t interface,
struct sockaddr *group, socklen_t grouplen,
uint32_t fmode, uint_t *numsrc,
struct sockaddr_storage *slist);
On success the value 0 is returned, and on failure, the value -1 is
returned and errno is set accordingly.
The s argument identifies the socket.
The interface argument holds the local IP address of the interface.
The group argument points to either a sockaddr_in structure (for
IPv4) or a sockaddr_in6 structure (for IPv6) that holds the IP
multicast address of the group.
<span class="grey">Thaler, et al. Informational [Page 12]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-13" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
The fmode argument points to an integer that will contain the filter
mode on a successful return. The value of this field will be either
MCAST_INCLUDE or MCAST_EXCLUDE, which are likewise defined in
<netinet/in.h>.
On input, the numsrc argument holds the number of source addresses
that will fit in the slist array. On output, the numsrc argument
will hold the total number of sources in the filter.
The slist argument points to buffer into which an array of IP
addresses of included or excluded (depending on the filter mode)
sources will be written. If numsrc was 0 on input, a NULL pointer
may be supplied.
If the application does not know the size of the source list
beforehand, it can make a reasonable guess (e.g., 0), and if upon
completion, numsrc holds a larger value, the operation can be
repeated with a large enough buffer.
That is, on return, numsrc is always updated to be the total number
of sources in the filter, while slist will hold as many source
addresses as fit, up to the minimum of the array size passed in as
the original numsrc value and the total number of sources in the
filter.
<span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. Security Considerations</span>
Although source filtering can help to combat denial-of-service
attacks, source filtering alone is not a complete solution, since it
does not provide protection against spoofing the source address to be
an allowed source. Multicast routing protocols which use reverse-
path forwarding based on the source address, however, do provide some
natural protection against spoofing the source address, since if a
router receives a packet on an interface other than the one toward
the "real" source, it will drop the packet. However, this still does
not provide any guarantee of protection.
<span class="h2"><a class="selflink" id="section-7" href="#section-7">7</a>. Acknowledgments</span>
This document was updated based on feedback from the IETF's IDMR and
MAGMA Working Groups, and the Austin Group. Wilbert de Graaf also
provided many helpful comments.
<span class="grey">Thaler, et al. Informational [Page 13]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-14" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
<span class="h2"><a class="selflink" id="section-8" href="#section-8">8</a>. <a href="#appendix-A">Appendix A</a>: Use of ioctl() for full-state operations</span>
The API defined here is historic, but is documented here for
informational purposes since it is implemented by multiple platforms.
The new functions defined earlier in this document should now be used
instead.
Retrieving the source filter for a given group cannot be done with
getsockopt() on some existing platforms, since the group and
interface must be passed down in order to retrieve the correct
filter, and getsockopt only supports an output buffer. This can,
however, be done with an ioctl(), and hence for symmetry, both gets
and sets are done with an ioctl.
<span class="h3"><a class="selflink" id="section-8.1" href="#section-8.1">8.1</a>. IPv4 Options</span>
The following are defined in <sys/sockio.h>:
o ioctl() SIOCGIPMSFILTER: to retrieve the list of source
addresses that comprise the source filter along with the
current filter mode.
o ioctl() SIOCSIPMSFILTER: to set or modify the source filter
content (e.g., unicast source address list) or mode (exclude or
include).
Ioctl option Argument type
SIOCGIPMSFILTER struct ip_msfilter
SIOCSIPMSFILTER struct ip_msfilter
struct ip_msfilter {
struct in_addr imsf_multiaddr; /* IP multicast address of group */
struct in_addr imsf_interface; /* local IP address of interface */
uint32_t imsf_fmode; /* filter mode */
uint32_t imsf_numsrc; /* number of sources in src_list */
struct in_addr imsf_slist[1]; /* start of source list */
};
#define IP_MSFILTER_SIZE(numsrc) \
(sizeof(struct ip_msfilter) - sizeof(struct in_addr) \
+ (numsrc) * sizeof(struct in_addr))
The imsf_fmode mode is a 32-bit integer that identifies the filter
mode. The value of this field must be either MCAST_INCLUDE or
MCAST_EXCLUDE, which are likewise defined in <netinet/in.h>.
<span class="grey">Thaler, et al. Informational [Page 14]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-15" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
The structure length pointed to must be at least IP_MSFILTER_SIZE(0)
bytes long, and the imsf_numsrc parameter should be set so that
IP_MSFILTER_SIZE(imsf_numsrc) indicates the buffer length.
If the implementation imposes a limit on the maximum number of
sources in a source filter, ENOBUFS is generated when a set operation
would exceed the maximum.
The result of a get operation (SIOCGIPMSFILTER) will be that the
imsf_multiaddr and imsf_interface fields will be unchanged, while
imsf_fmode, imsf_numsrc, and as many source addresses as fit will be
filled into the application's buffer.
If the application does not know the size of the source list
beforehand, it can make a reasonable guess (e.g., 0), and if upon
completion, the imsf_numsrc field holds a larger value, the operation
can be repeated with a large enough buffer.
That is, on return from SIOCGIPMSFILTER, imsf_numsrc is always
updated to be the total number of sources in the filter, while
imsf_slist will hold as many source addresses as fit, up to the
minimum of the array size passed in as the original imsf_numsrc value
and the total number of sources in the filter.
<span class="h3"><a class="selflink" id="section-8.2" href="#section-8.2">8.2</a>. Protocol-Independent Options</span>
The following are defined in <sys/sockio.h>:
o ioctl() SIOCGMSFILTER: to retrieve the list of source addresses
that comprise the source filter along with the current filter
mode.
o ioctl() SIOCSMSFILTER: to set or modify the source filter
content (e.g., unicast source address list) or mode (exclude or
include).
Ioctl option Argument type
SIOCGMSFILTER struct group_filter
SIOCSMSFILTER struct group_filter
struct group_filter {
uint32_t gf_interface; /* interface index */
struct sockaddr_storage gf_group; /* multicast address */
uint32_t gf_fmode; /* filter mode */
uint32_t gf_numsrc; /* number of sources */
struct sockaddr_storage gf_slist[1]; /* source address */
};
<span class="grey">Thaler, et al. Informational [Page 15]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-16" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
#define GROUP_FILTER_SIZE(numsrc) \
(sizeof(struct group_filter) - sizeof(struct sockaddr_storage) \
+ (numsrc) * sizeof(struct sockaddr_storage))
The imf_numsrc field is used in the same way as described for
imsf_numsrc above.
<span class="h2"><a class="selflink" id="section-9" href="#section-9">9</a>. Normative References</span>
[<a id="ref-1">1</a>] Gilligan, R., Thomson, S., Bound, J., McCann, J. and W.
Stevens, "Basic Socket Interface Extensions for IPv6", <a href="./rfc3493">RFC 3493</a>,
February 2003.
[<a id="ref-2">2</a>] IEEE Std. 1003.1-2001 Standard for Information Technology --
Portable Operating System Interface (POSIX). Open Group
Technical Standard: Base Specifications, Issue 6, December 2001.
ISO/IEC 9945:2002. <a href="http://www.opengroup.org/austin">http://www.opengroup.org/austin</a>
<span class="h2"><a class="selflink" id="section-10" href="#section-10">10</a>. Informative References</span>
[<a id="ref-3">3</a>] Cain, B., Deering, S., Kouvelas, I., Fenner, B. and A.
Thyagarajan, "Internet Group Management Protocol, Version 3",
<a href="./rfc3376">RFC 3376</a>, October 2002.
[<a id="ref-4">4</a>] Vida, R. and L. Costa, "Multicast Listener Discovery Version 2
(MLDv2) for IPv6", Work in Progress, December 2003.
<span class="grey">Thaler, et al. Informational [Page 16]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-17" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
<span class="h2"><a class="selflink" id="section-11" href="#section-11">11</a>. Authors' Addresses</span>
Dave Thaler
Microsoft Corporation
One Microsoft Way
Redmond, WA 98052-6399
Phone: +1 425 703 8835
EMail: dthaler@microsoft.com
Bill Fenner
75 Willow Road
Menlo Park, CA 94025
Phone: +1 650 867 6073
EMail: fenner@research.att.com
Bob Quinn
IP Multicast Initiative (IPMI)
Stardust.com
1901 S. Bascom Ave. #333
Campbell, CA 95008
Phone: +1 408 879 8080
EMail: rcq@ipmulticast.com
<span class="grey">Thaler, et al. Informational [Page 17]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-18" ></span>
<span class="grey"><a href="./rfc3678">RFC 3678</a> Multicast Source Filter API January 2004</span>
<span class="h2"><a class="selflink" id="section-12" href="#section-12">12</a>. Full Copyright Statement</span>
Copyright (C) The Internet Society (2004). All Rights Reserved.
This document and translations of it may be copied and furnished to
others, and derivative works that comment on or otherwise explain it
or assist in its implementation may be prepared, copied, published
and distributed, in whole or in part, without restriction of any
kind, provided that the above copyright notice and this paragraph are
included on all such copies and derivative works. However, this
document itself may not be modified in any way, such as by removing
the copyright notice or references to the Internet Society or other
Internet organizations, except as needed for the purpose of
developing Internet standards in which case the procedures for
copyrights defined in the Internet Standards process must be
followed, or as required to translate it into languages other than
English.
The limited permissions granted above are perpetual and will not be
revoked by the Internet Society or its successors or assignees.
This document and the information contained herein is provided on an
"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Acknowledgement
Funding for the RFC Editor function is currently provided by the
Internet Society.
Thaler, et al. Informational [Page 18]
</pre>
|