print-ah.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* $NetBSD: print-ah.c,v 1.4 1996/05/20 00:41:16 fvdl Exp $ */
  2. /*
  3. * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994
  4. * The Regents of the University of California. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that: (1) source code distributions
  8. * retain the above copyright notice and this paragraph in its entirety, (2)
  9. * distributions including binary code include the above copyright notice and
  10. * this paragraph in its entirety in the documentation or other materials
  11. * provided with the distribution, and (3) all advertising materials mentioning
  12. * features or use of this software display the following acknowledgement:
  13. * ``This product includes software developed by the University of California,
  14. * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
  15. * the University nor the names of its contributors may be used to endorse
  16. * or promote products derived from this software without specific prior
  17. * written permission.
  18. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  19. * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  20. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. */
  22. /* \summary: IPSEC Authentication Header printer */
  23. #ifdef HAVE_CONFIG_H
  24. #include "config.h"
  25. #endif
  26. #include <netdissect-stdinc.h>
  27. #include "ah.h"
  28. #include "netdissect.h"
  29. #include "extract.h"
  30. int
  31. ah_print(netdissect_options *ndo, register const u_char *bp)
  32. {
  33. register const struct ah *ah;
  34. int sumlen;
  35. ah = (const struct ah *)bp;
  36. ND_TCHECK(*ah);
  37. sumlen = ah->ah_len << 2;
  38. ND_PRINT((ndo, "AH(spi=0x%08x", EXTRACT_32BITS(&ah->ah_spi)));
  39. if (ndo->ndo_vflag)
  40. ND_PRINT((ndo, ",sumlen=%d", sumlen));
  41. ND_TCHECK_32BITS(ah + 1);
  42. ND_PRINT((ndo, ",seq=0x%x", EXTRACT_32BITS(ah + 1)));
  43. if (!ND_TTEST2(*bp, sizeof(struct ah) + sumlen)) {
  44. ND_PRINT((ndo, "[truncated]):"));
  45. return -1;
  46. }
  47. ND_PRINT((ndo, "): "));
  48. return sizeof(struct ah) + sumlen;
  49. trunc:
  50. ND_PRINT((ndo, "[|AH]"));
  51. return -1;
  52. }