- struct sockaddr* multi_addr;
- struct ndrv_multiaddr* ndrv_entry = NULL;
- int result;
-
- if (sopt->sopt_val == 0 || sopt->sopt_valsize < 2 ||
- sopt->sopt_level != SOL_NDRVPROTO)
- return EINVAL;
- if (np->nd_if == NULL || np->nd_dlist_cnt == 0)
- return ENXIO;
-
- // Allocate storage
- MALLOC(multi_addr, struct sockaddr*, sopt->sopt_valsize,
- M_TEMP, M_WAITOK);
- if (multi_addr == NULL)
- return ENOMEM;
-
- // Copy in the address
- result = copyin(sopt->sopt_val, multi_addr, sopt->sopt_valsize);
-
- // Validate the sockaddr
- if (result == 0 && sopt->sopt_valsize != multi_addr->sa_len)
- result = EINVAL;
-
- if (result == 0)
- {
- /* Find the old entry */
- ndrv_entry = ndrv_have_multicast(np, multi_addr);
-
- if (ndrv_entry == NULL)
- result = ENOENT;
- }
-
- if (result == 0)
- {
- // Try deleting the multicast
- result = ifnet_remove_multicast(ndrv_entry->ifma);
- }
-
- if (result == 0)
- {
- // Remove from our linked list
- struct ndrv_multiaddr* cur = np->nd_multiaddrs;
-
- ifmaddr_release(ndrv_entry->ifma);
-
- if (cur == ndrv_entry)
- {
- np->nd_multiaddrs = cur->next;
- }
- else
- {
- for (cur = cur->next; cur != NULL; cur = cur->next)
- {
- if (cur->next == ndrv_entry)
- {
- cur->next = cur->next->next;
- break;
- }
- }
- }
+ struct sockaddr* multi_addr;
+ struct ndrv_multiaddr* ndrv_entry = NULL;
+ int result;
+
+ if (sopt->sopt_val == 0 || sopt->sopt_valsize < 2 ||
+ sopt->sopt_level != SOL_NDRVPROTO) {
+ return EINVAL;
+ }
+ if (np->nd_if == NULL || np->nd_dlist_cnt == 0) {
+ return ENXIO;
+ }
+
+ // Allocate storage
+ MALLOC(multi_addr, struct sockaddr*, sopt->sopt_valsize,
+ M_TEMP, M_WAITOK);
+ if (multi_addr == NULL) {
+ return ENOMEM;
+ }
+
+ // Copy in the address
+ result = copyin(sopt->sopt_val, multi_addr, sopt->sopt_valsize);
+
+ // Validate the sockaddr
+ if (result == 0 && sopt->sopt_valsize != multi_addr->sa_len) {
+ result = EINVAL;
+ }
+
+ if (result == 0) {
+ /* Find the old entry */
+ ndrv_entry = ndrv_have_multicast(np, multi_addr);
+
+ if (ndrv_entry == NULL) {
+ result = ENOENT;
+ }
+ }
+
+ if (result == 0) {
+ // Try deleting the multicast
+ result = ifnet_remove_multicast(ndrv_entry->ifma);
+ }
+
+ if (result == 0) {
+ // Remove from our linked list
+ struct ndrv_multiaddr* cur = np->nd_multiaddrs;
+
+ ifmaddr_release(ndrv_entry->ifma);
+
+ if (cur == ndrv_entry) {
+ np->nd_multiaddrs = cur->next;
+ } else {
+ for (cur = cur->next; cur != NULL; cur = cur->next) {
+ if (cur->next == ndrv_entry) {
+ cur->next = cur->next->next;
+ break;
+ }
+ }
+ }