* compare two buffers with mask. * IN: * addr1: source * addr2: object * bits: Number of bits to compare * OUT: * 1 : equal * 0 : not equal */
| 4382 | * 0 : not equal |
| 4383 | */ |
| 4384 | static int |
| 4385 | key_bbcmp(const void *a1, const void *a2, u_int bits) |
| 4386 | { |
| 4387 | const unsigned char *p1 = a1; |
| 4388 | const unsigned char *p2 = a2; |
| 4389 | |
| 4390 | /* XXX: This could be considerably faster if we compare a word |
| 4391 | * at a time, but it is complicated on LSB Endian machines */ |
| 4392 | |
| 4393 | /* Handle null pointers */ |
| 4394 | if (p1 == NULL || p2 == NULL) |
| 4395 | return (p1 == p2); |
| 4396 | |
| 4397 | while (bits >= 8) { |
| 4398 | if (*p1++ != *p2++) |
| 4399 | return 0; |
| 4400 | bits -= 8; |
| 4401 | } |
| 4402 | |
| 4403 | if (bits > 0) { |
| 4404 | u_int8_t mask = ~((1<<(8-bits))-1); |
| 4405 | if ((*p1 & mask) != (*p2 & mask)) |
| 4406 | return 0; |
| 4407 | } |
| 4408 | return 1; /* Match! */ |
| 4409 | } |
| 4410 | |
| 4411 | static void |
| 4412 | key_flush_spd(time_t now) |
no outgoing calls
no test coverage detected