3 * ===================================
4 * HARP | Host ATM Research Platform
5 * ===================================
8 * This Host ATM Research Platform ("HARP") file (the "Software") is
9 * made available by Network Computing Services, Inc. ("NetworkCS")
10 * "AS IS". NetworkCS does not provide maintenance, improvements or
11 * support of any kind.
13 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17 * In no event shall NetworkCS be responsible for any damages, including
18 * but not limited to consequential damages, arising from or relating to
19 * any use of the Software or related support.
21 * Copyright 1994-1998 Network Computing Services, Inc.
23 * Copies of this Software may be made, however, the above copyright
24 * notice must be reproduced on all copies.
26 * $FreeBSD: src/lib/libatm/cache_key.c,v 1.3.2.1 2001/09/28 16:52:10 dillon Exp $
27 * $DragonFly: src/lib/libatm/cache_key.c,v 1.2 2003/06/17 04:26:41 dillon Exp $
31 * User Space Library Functions
32 * ----------------------------
34 * SCSP cache key computation
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <sys/socket.h>
42 #include <netinet/in.h>
43 #include <netatm/port.h>
44 #include <netatm/atm.h>
45 #include <netatm/atm_if.h>
46 #include <netatm/atm_sap.h>
47 #include <netatm/atm_sys.h>
48 #include <netatm/atm_ioctl.h>
56 * Compute an SCSP cache key
59 * ap pointer to an Atm_addr with the ATM address
60 * ip pointer to a struct in_addr with the IP address
61 * ol the required length of the cache key
62 * op pointer to receive cache key
69 scsp_cache_key(ap
, ip
, ol
, op
)
76 char buff
[32], digest
[16];
82 UM_ZERO(buff
, sizeof(buff
));
85 * Copy the addresses into a buffer for MD5 computation
87 len
= sizeof(struct in_addr
) + ap
->address_length
;
88 if (len
> sizeof(buff
))
90 UM_COPY(ip
, buff
, sizeof(struct in_addr
));
91 UM_COPY(ap
->address
, &buff
[sizeof(struct in_addr
)],
92 len
- sizeof(struct in_addr
));
95 * Compute the MD5 digest of the combined IP and ATM addresses
98 MD5Update(&context
, buff
, len
);
99 MD5Final(digest
, &context
);
102 * Fold the 16-byte digest to the required length
104 UM_ZERO((caddr_t
)op
, ol
);
105 for (i
= 0; i
< 16; i
++) {
106 op
[i
% ol
] = op
[i
% ol
] ^ digest
[i
];