Check-in Number:
|
1122 | |
Date: |
2001-Oct-09 16:05:55 (local)
2001-Oct-09 14:05:55 (UTC) |
User: | rse |
Branch: | |
Comment: |
Support prefixlen == 0 for an "always matches" and instead
use prefixlen == -1 for "full match". Credits to Thomas ;) |
Tickets: |
|
Inspections: |
|
Files: |
|
ossp-pkg/sa/sa.c 1.15 -> 1.16
--- sa.c 2001/10/09 13:19:25 1.15
+++ sa.c 2001/10/09 14:05:55 1.16
@@ -706,7 +706,7 @@
return SA_OK;
}
-sa_rc_t sa_addr_match(sa_addr_t *saa1, sa_addr_t *saa2, size_t prefixlen)
+sa_rc_t sa_addr_match(sa_addr_t *saa1, sa_addr_t *saa2, int prefixlen)
{
const unsigned char *ucp1, *ucp2;
unsigned int uc1, uc2, mask;
@@ -716,7 +716,7 @@
int nBits;
/* argument sanity check(s) */
- if (saa1 == NULL || saa2 == NULL)
+ if (saa1 == NULL || saa2 == NULL || prefixlen < -1)
return SA_ERR_ARG;
/* match short circuiting */
@@ -730,7 +730,7 @@
ucp2 = (const unsigned char *)(((struct sockaddr_un *)saa2->saBuf)->sun_path);
l1 = strlen(((struct sockaddr_un *)saa1->saBuf)->sun_path) * 8;
l2 = strlen(((struct sockaddr_un *)saa2->saBuf)->sun_path) * 8;
- if (prefixlen == 0) {
+ if (prefixlen == -1) {
if (l1 != l2)
return SA_ERR_MTC;
nBits = l1;
@@ -761,7 +761,7 @@
return SA_ERR_ARG;
/* support equal matching (= all bits) */
- if (prefixlen == 0)
+ if (prefixlen == -1)
prefixlen = nBits;
/* perform address representation comparison
|
|
ossp-pkg/sa/sa.h 1.16 -> 1.17
--- sa.h 2001/10/09 13:19:25 1.16
+++ sa.h 2001/10/09 14:05:55 1.17
@@ -148,7 +148,7 @@
sa_rc_t sa_addr_s2a (sa_addr_t *saa, const struct sockaddr *sabuf, socklen_t salen);
sa_rc_t sa_addr_a2u (sa_addr_t *saa, char **uri);
sa_rc_t sa_addr_a2s (sa_addr_t *saa, struct sockaddr **sabuf, socklen_t *salen);
-sa_rc_t sa_addr_match (sa_addr_t *saa1, sa_addr_t *saa2, size_t prefixlen);
+sa_rc_t sa_addr_match (sa_addr_t *saa1, sa_addr_t *saa2, int prefixlen);
/* socket object operations */
sa_rc_t sa_create (sa_t **sa);
|
|