View | Details | Raw Unified | Return to bug 95277
Collapse All | Expand All

(-)/home/bms/fp4/nethead/sys/netinet/ip_encap.c (-16 / +13 lines)
Lines 403-408 Link Here
403
	const struct sockaddr *sp;
403
	const struct sockaddr *sp;
404
	const struct sockaddr *dp;
404
	const struct sockaddr *dp;
405
{
405
{
406
	const int hdrlen = offsetof(struct sockaddr, sa_data);
406
	struct sockaddr_storage s;
407
	struct sockaddr_storage s;
407
	struct sockaddr_storage d;
408
	struct sockaddr_storage d;
408
	int i;
409
	int i;
Lines 419-450 Link Here
419
420
420
	matchlen = 0;
421
	matchlen = 0;
421
422
422
	p = (const u_int8_t *)sp;
423
	p = (const u_int8_t *)&sp->sa_data;
423
	q = (const u_int8_t *)&ep->srcmask;
424
	q = (const u_int8_t *)&ep->srcmask + hdrlen;
424
	r = (u_int8_t *)&s;
425
	r = (u_int8_t *)&s + hdrlen;
425
	for (i = 0 ; i < sp->sa_len; i++) {
426
	for (i = 0 ; i < sp->sa_len - hdrlen; i++) {
426
		r[i] = p[i] & q[i];
427
		r[i] = p[i] & q[i];
427
		/* XXX estimate */
428
		/* XXX estimate */
428
		matchlen += (q[i] ? 8 : 0);
429
		matchlen += (q[i] ? 8 : 0);
429
	}
430
	}
430
431
431
	p = (const u_int8_t *)dp;
432
	p = (const u_int8_t *)&dp->sa_data;
432
	q = (const u_int8_t *)&ep->dstmask;
433
	q = (const u_int8_t *)&ep->dstmask + hdrlen;
433
	r = (u_int8_t *)&d;
434
	r = (u_int8_t *)&d + hdrlen;
434
	for (i = 0 ; i < dp->sa_len; i++) {
435
	for (i = 0 ; i < dp->sa_len - hdrlen; i++) {
435
		r[i] = p[i] & q[i];
436
		r[i] = p[i] & q[i];
436
		/* XXX rough estimate */
437
		/* XXX rough estimate */
437
		matchlen += (q[i] ? 8 : 0);
438
		matchlen += (q[i] ? 8 : 0);
438
	}
439
	}
439
440
440
	/* need to overwrite len/family portion as we don't compare them */
441
	if (bcmp((u_int8_t *)&s + hdrlen, (const u_int8_t *)&ep->src + hdrlen,
441
	s.ss_len = sp->sa_len;
442
	    ep->src.ss_len - hdrlen) == 0 &&
442
	s.ss_family = sp->sa_family;
443
	    bcmp((u_int8_t *)&d + hdrlen, (const u_int8_t *)&ep->dst + hdrlen,
443
	d.ss_len = dp->sa_len;
444
	    ep->dst.ss_len - hdrlen) == 0) {
444
	d.ss_family = dp->sa_family;
445
446
	if (bcmp(&s, &ep->src, ep->src.ss_len) == 0 &&
447
	    bcmp(&d, &ep->dst, ep->dst.ss_len) == 0) {
448
		return matchlen;
445
		return matchlen;
449
	} else
446
	} else
450
		return 0;
447
		return 0;

Return to bug 95277