- /* build a new list */
- multicast_list_init(&new_mc_list);
- error = ifnet_get_multicast_list(source_ifp, &source_multicast_list);
- if (error != 0) {
- printf("multicast_list_program: "
- "ifnet_get_multicast_list(%s%d) failed, %d\n",
- source_ifp->if_name, source_ifp->if_unit, error);
- return (error);
- }
- for (i = 0; source_multicast_list[i] != NULL; i++) {
- if (ifmaddr_address(source_multicast_list[i],
- (struct sockaddr *)&source_sdl,
- sizeof(source_sdl)) != 0
- || source_sdl.sdl_family != AF_LINK) {
- continue;
+ /* build a new list */
+ multicast_list_init(&new_mc_list);
+ error = ifnet_get_multicast_list(source_ifp, &source_multicast_list);
+ if (error != 0) {
+ printf("multicast_list_program: "
+ "ifnet_get_multicast_list(%s%d) failed, %d\n",
+ source_ifp->if_name, source_ifp->if_unit, error);
+ return error;
+ }
+ for (i = 0; source_multicast_list[i] != NULL; i++) {
+ if (ifmaddr_address(source_multicast_list[i],
+ (struct sockaddr *)&source_sdl,
+ sizeof(source_sdl)) != 0
+ || source_sdl.sdl_family != AF_LINK) {
+ continue;
+ }
+ mc = _MALLOC(sizeof(struct multicast_entry), M_DEVBUF, M_WAITOK);
+ if (mc == NULL) {
+ error = ENOBUFS;
+ break;
+ }
+ bcopy(LLADDR(&source_sdl), LLADDR(&target_sdl), alen);
+ error = ifnet_add_multicast(target_ifp, (struct sockaddr *)&target_sdl,
+ &mc->mc_ifma);
+ if (error != 0) {
+ FREE(mc, M_DEVBUF);
+ break;
+ }
+ SLIST_INSERT_HEAD(&new_mc_list, mc, mc_entries);