| 835 | } |
| 836 | |
| 837 | static void |
| 838 | DeleteLink(struct alias_link *lnk) |
| 839 | { |
| 840 | struct libalias *la = lnk->la; |
| 841 | |
| 842 | LIBALIAS_LOCK_ASSERT(la); |
| 843 | /* Don't do anything if the link is marked permanent */ |
| 844 | if (la->deleteAllLinks == 0 && lnk->flags & LINK_PERMANENT) |
| 845 | return; |
| 846 | |
| 847 | #ifndef NO_FW_PUNCH |
| 848 | /* Delete associated firewall hole, if any */ |
| 849 | ClearFWHole(lnk); |
| 850 | #endif |
| 851 | |
| 852 | /* Free memory allocated for LSNAT server pool */ |
| 853 | if (lnk->server != NULL) { |
| 854 | struct server *head, *curr, *next; |
| 855 | |
| 856 | head = curr = lnk->server; |
| 857 | do { |
| 858 | next = curr->next; |
| 859 | free(curr); |
| 860 | } while ((curr = next) != head); |
| 861 | } |
| 862 | /* Adjust output table pointers */ |
| 863 | LIST_REMOVE(lnk, list_out); |
| 864 | |
| 865 | /* Adjust input table pointers */ |
| 866 | LIST_REMOVE(lnk, list_in); |
| 867 | #ifndef NO_USE_SOCKETS |
| 868 | /* Close socket, if one has been allocated */ |
| 869 | if (lnk->sockfd != -1) { |
| 870 | la->sockCount--; |
| 871 | close(lnk->sockfd); |
| 872 | } |
| 873 | #endif |
| 874 | /* Link-type dependent cleanup */ |
| 875 | switch (lnk->link_type) { |
| 876 | case LINK_ICMP: |
| 877 | la->icmpLinkCount--; |
| 878 | break; |
| 879 | case LINK_UDP: |
| 880 | la->udpLinkCount--; |
| 881 | break; |
| 882 | case LINK_TCP: |
| 883 | la->tcpLinkCount--; |
| 884 | free(lnk->data.tcp); |
| 885 | break; |
| 886 | case LINK_PPTP: |
| 887 | la->pptpLinkCount--; |
| 888 | break; |
| 889 | case LINK_FRAGMENT_ID: |
| 890 | la->fragmentIdLinkCount--; |
| 891 | break; |
| 892 | case LINK_FRAGMENT_PTR: |
| 893 | la->fragmentPtrLinkCount--; |
| 894 | if (lnk->data.frag_ptr != NULL) |
no test coverage detected