| 1076 | } |
| 1077 | |
| 1078 | static struct alias_link * |
| 1079 | _FindLinkOut(struct libalias *la, struct in_addr src_addr, |
| 1080 | struct in_addr dst_addr, |
| 1081 | u_short src_port, |
| 1082 | u_short dst_port, |
| 1083 | int link_type, |
| 1084 | int replace_partial_links) |
| 1085 | { |
| 1086 | u_int i; |
| 1087 | struct alias_link *lnk; |
| 1088 | |
| 1089 | LIBALIAS_LOCK_ASSERT(la); |
| 1090 | i = StartPointOut(src_addr, dst_addr, src_port, dst_port, link_type); |
| 1091 | LIST_FOREACH(lnk, &la->linkTableOut[i], list_out) { |
| 1092 | if (lnk->dst_addr.s_addr == dst_addr.s_addr && |
| 1093 | lnk->src_addr.s_addr == src_addr.s_addr && |
| 1094 | lnk->src_port == src_port && |
| 1095 | lnk->dst_port == dst_port && |
| 1096 | lnk->link_type == link_type && |
| 1097 | lnk->server == NULL) { |
| 1098 | lnk->timestamp = la->timeStamp; |
| 1099 | break; |
| 1100 | } |
| 1101 | } |
| 1102 | |
| 1103 | /* Search for partially specified links. */ |
| 1104 | if (lnk == NULL && replace_partial_links) { |
| 1105 | if (dst_port != 0 && dst_addr.s_addr != INADDR_ANY) { |
| 1106 | lnk = _FindLinkOut(la, src_addr, dst_addr, src_port, 0, |
| 1107 | link_type, 0); |
| 1108 | if (lnk == NULL) |
| 1109 | lnk = _FindLinkOut(la, src_addr, la->nullAddress, src_port, |
| 1110 | dst_port, link_type, 0); |
| 1111 | } |
| 1112 | if (lnk == NULL && |
| 1113 | (dst_port != 0 || dst_addr.s_addr != INADDR_ANY)) { |
| 1114 | lnk = _FindLinkOut(la, src_addr, la->nullAddress, src_port, 0, |
| 1115 | link_type, 0); |
| 1116 | } |
| 1117 | if (lnk != NULL) { |
| 1118 | lnk = ReLink(lnk, |
| 1119 | src_addr, dst_addr, lnk->alias_addr, |
| 1120 | src_port, dst_port, lnk->alias_port, |
| 1121 | link_type); |
| 1122 | } |
| 1123 | } |
| 1124 | return (lnk); |
| 1125 | } |
| 1126 | |
| 1127 | static struct alias_link * |
| 1128 | FindLinkOut(struct libalias *la, struct in_addr src_addr, |
no test coverage detected