z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


IP_BLOCK_SOURCE and IP_UNBLOCK_SOURCE

z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
SC27-3660-00

The IP_BLOCK_SOURCE socket option enables the application to block IPv4 multicast packets that have a source address that matches the given IPv4 source address. The specified multicast group must have been joined previously. The IP_UNBLOCK_SOURCE socket option enables the application to unblock a previously blocked source for a given multicast group.

To block or unblock IPv4 multicast packets, use the SETSOCKOPT API and specify the IP_MREQ_SOURCE structure containing IPv4 multicast address, IPv4 source address, and the local IPv4 interface address. The format of the IP_MREQ_SOURCE structure is in the BPXYSOCK macro. The assembler program example in Figure 1 shows this socket option using the EZASMI macro:

Figure 1. IP_BLOCK_SOURCE and IP_UNBLOCK_SOURCE
***********************************************************************
*                                                                     *
*        Issue SETSOCKOPT - IP_BLOCK_SOURCE                           *
*                                                                     *
***********************************************************************
         MVC   IMRS_MULTIADD,MY_MULTICAST_ADDRESS
         MVC   IMRS_SOURCEADDR,MY_MULTICAST_SOURCE 
         MVC   IMRS_INTERFAC,MY_MULTICAST_INTERFACE
         EZASMI TYPE=SETSOCKOPT,  ISSUE SETSOCKOPT                     X
               S=S,               SOCKET DESCRIPTOR                    X
               OPTLEN=OPTLEN12,   OPTION LENGTH                        X
               OPTNAME='IP_BLOCK_SOURCE', OPTION NAME                  X
               OPTVAL=IP_MREQ_SOURCE,    OPTION VALUE                  X
               RETCODE=RETCODE,   (SPECIFY RETCODE FIELD)              X
               ERROR=ERROR        ABEND IF MACRO ERROR
         BAL   R14,RCCHECK         --> CHECK IT
*
* Here your program will perform normal processing such as sending or
* receiving message.
*
***********************************************************************
*                                                                     *
*        Issue SETSOCKOPT - IP_UNBLOCK_SOURCE                         *
*                                                                     *
***********************************************************************
         MVC   IMRS_MULTIADD,MY_MULTICAST_ADDRESS
         MVC   IMRS_SOURCEADDR,MY_MULTICAST_SOURCE
         MVC   IMRS_INTERFAC,MY_MULTICAST_INTERFACE
         EZASMI TYPE=SETSOCKOPT,  ISSUE SETSOCKOPT                     X
               S=S,               SOCKET DESCRIPTOR                    X
               OPTLEN=OPTLEN12,   OPTION LENGTH                        X
               OPTNAME='IP_UNBLOCK_SOURCE', OPTION NAME                X
               OPTVAL=IP_MREQ_SOURCE,    OPTION VALUE                  X
               RETCODE=RETCODE,   (SPECIFY RETCODE FIELD)              X
               ERROR=ERROR        ABEND IF MACRO ERROR
         BAL   R14,RCCHECK         --> CHECK IT

While the application is a member of the multicast host group, datagrams can be sent or received as required. To see the multicast groups that are joined on an interface, use the Netstat DEvlinks/-d command. To see the multicast groups that are joined on a socket, use the Netstat ALL/-A command.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014