MCPcopy Create free account
hub / github.com/F-Stack/f-stack / _FindLinkIn

Function _FindLinkIn

freebsd/netinet/libalias/alias_db.c:1157–1268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1155}
1156
1157static struct alias_link *
1158_FindLinkIn(struct libalias *la, struct in_addr dst_addr,
1159 struct in_addr alias_addr,
1160 u_short dst_port,
1161 u_short alias_port,
1162 int link_type,
1163 int replace_partial_links)
1164{
1165 int flags_in;
1166 u_int start_point;
1167 struct alias_link *lnk;
1168 struct alias_link *lnk_fully_specified;
1169 struct alias_link *lnk_unknown_all;
1170 struct alias_link *lnk_unknown_dst_addr;
1171 struct alias_link *lnk_unknown_dst_port;
1172
1173 LIBALIAS_LOCK_ASSERT(la);
1174/* Initialize pointers */
1175 lnk_fully_specified = NULL;
1176 lnk_unknown_all = NULL;
1177 lnk_unknown_dst_addr = NULL;
1178 lnk_unknown_dst_port = NULL;
1179
1180/* If either the dest addr or port is unknown, the search
1181 loop will have to know about this. */
1182
1183 flags_in = 0;
1184 if (dst_addr.s_addr == INADDR_ANY)
1185 flags_in |= LINK_UNKNOWN_DEST_ADDR;
1186 if (dst_port == 0)
1187 flags_in |= LINK_UNKNOWN_DEST_PORT;
1188
1189/* Search loop */
1190 start_point = StartPointIn(alias_addr, alias_port, link_type);
1191 LIST_FOREACH(lnk, &la->linkTableIn[start_point], list_in) {
1192 int flags;
1193
1194 flags = flags_in | lnk->flags;
1195 if (!(flags & LINK_PARTIALLY_SPECIFIED)) {
1196 if (lnk->alias_addr.s_addr == alias_addr.s_addr
1197 && lnk->alias_port == alias_port
1198 && lnk->dst_addr.s_addr == dst_addr.s_addr
1199 && lnk->dst_port == dst_port
1200 && lnk->link_type == link_type) {
1201 lnk_fully_specified = lnk;
1202 break;
1203 }
1204 } else if ((flags & LINK_UNKNOWN_DEST_ADDR)
1205 && (flags & LINK_UNKNOWN_DEST_PORT)) {
1206 if (lnk->alias_addr.s_addr == alias_addr.s_addr
1207 && lnk->alias_port == alias_port
1208 && lnk->link_type == link_type) {
1209 if (lnk_unknown_all == NULL)
1210 lnk_unknown_all = lnk;
1211 }
1212 } else if (flags & LINK_UNKNOWN_DEST_ADDR) {
1213 if (lnk->alias_addr.s_addr == alias_addr.s_addr
1214 && lnk->alias_port == alias_port

Callers 1

FindLinkInFunction · 0.85

Calls 2

StartPointInFunction · 0.85
ReLinkFunction · 0.85

Tested by

no test coverage detected