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

Function sctp_count_max_addresses_vrf

freebsd/netinet/sctp_usrreq.c:1252–1328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1250}
1251
1252static int
1253sctp_count_max_addresses_vrf(struct sctp_inpcb *inp, uint32_t vrf_id)
1254{
1255 int cnt = 0;
1256 struct sctp_vrf *vrf = NULL;
1257
1258 /*
1259 * In both sub-set bound an bound_all cases we return the MAXIMUM
1260 * number of addresses that you COULD get. In reality the sub-set
1261 * bound may have an exclusion list for a given TCB OR in the
1262 * bound-all case a TCB may NOT include the loopback or other
1263 * addresses as well.
1264 */
1265 SCTP_IPI_ADDR_LOCK_ASSERT();
1266 vrf = sctp_find_vrf(vrf_id);
1267 if (vrf == NULL) {
1268 return (0);
1269 }
1270 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
1271 struct sctp_ifn *sctp_ifn;
1272 struct sctp_ifa *sctp_ifa;
1273
1274 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
1275 LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
1276 /* Count them if they are the right type */
1277 switch (sctp_ifa->address.sa.sa_family) {
1278#ifdef INET
1279 case AF_INET:
1280#ifdef INET6
1281 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4))
1282 cnt += sizeof(struct sockaddr_in6);
1283 else
1284 cnt += sizeof(struct sockaddr_in);
1285#else
1286 cnt += sizeof(struct sockaddr_in);
1287#endif
1288 break;
1289#endif
1290#ifdef INET6
1291 case AF_INET6:
1292 cnt += sizeof(struct sockaddr_in6);
1293 break;
1294#endif
1295 default:
1296 break;
1297 }
1298 }
1299 }
1300 } else {
1301 struct sctp_laddr *laddr;
1302
1303 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
1304 switch (laddr->ifa->address.sa.sa_family) {
1305#ifdef INET
1306 case AF_INET:
1307#ifdef INET6
1308 if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4))
1309 cnt += sizeof(struct sockaddr_in6);

Callers 1

sctp_count_max_addressesFunction · 0.85

Calls 1

sctp_find_vrfFunction · 0.85

Tested by

no test coverage detected