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

Function sctp_addr_match

freebsd/netinet/sctp_asconf.c:886–933  ·  view source on GitHub ↗

* does the address match? returns 0 if not, 1 if so */

Source from the content-addressed store, hash-verified

884 * does the address match? returns 0 if not, 1 if so
885 */
886static uint32_t
887sctp_addr_match(struct sctp_paramhdr *ph, struct sockaddr *sa)
888{
889#if defined(INET) || defined(INET6)
890 uint16_t param_type, param_length;
891
892 param_type = ntohs(ph->param_type);
893 param_length = ntohs(ph->param_length);
894#endif
895 switch (sa->sa_family) {
896#ifdef INET6
897 case AF_INET6:
898 {
899 /* XXX scopeid */
900 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa;
901 struct sctp_ipv6addr_param *v6addr;
902
903 v6addr = (struct sctp_ipv6addr_param *)ph;
904 if ((param_type == SCTP_IPV6_ADDRESS) &&
905 (param_length == sizeof(struct sctp_ipv6addr_param)) &&
906 (memcmp(&v6addr->addr, &sin6->sin6_addr,
907 sizeof(struct in6_addr)) == 0)) {
908 return (1);
909 }
910 break;
911 }
912#endif
913#ifdef INET
914 case AF_INET:
915 {
916 struct sockaddr_in *sin = (struct sockaddr_in *)sa;
917 struct sctp_ipv4addr_param *v4addr;
918
919 v4addr = (struct sctp_ipv4addr_param *)ph;
920 if ((param_type == SCTP_IPV4_ADDRESS) &&
921 (param_length == sizeof(struct sctp_ipv4addr_param)) &&
922 (memcmp(&v4addr->addr, &sin->sin_addr,
923 sizeof(struct in_addr)) == 0)) {
924 return (1);
925 }
926 break;
927 }
928#endif
929 default:
930 break;
931 }
932 return (0);
933}
934
935/*
936 * Cleanup for non-responded/OP ERR'd ASCONF

Callers 1

sctp_is_addr_pendingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected