PageRenderTime 46ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/cmpt471/a2/wireshark/packaging/u3/tools/sysdep.h

http://cwoodruf-sfu-cmpt.googlecode.com/
C Header | 99 lines | 40 code | 13 blank | 46 comment | 0 complexity | 09b724702433b764b93d9358072a956d MD5 | raw file
  1. /* sysdep.h
  2. * UUID system dependent routines
  3. *
  4. * $Id: sysdep.h 31341 2009-12-21 21:06:01Z gerald $
  5. *
  6. * Wireshark - Network traffic analyzer
  7. * By Gerald Combs <gerald@wireshark.org>
  8. * Copyright 1998 Gerald Combs
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version 2
  13. * of the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  23. */
  24. /*
  25. ** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
  26. ** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
  27. ** Digital Equipment Corporation, Maynard, Mass.
  28. ** Copyright (c) 1998 Microsoft.
  29. ** To anyone who acknowledges that this file is provided "AS IS"
  30. ** without any express or implied warranty: permission to use, copy,
  31. ** modify, and distribute this file for any purpose is hereby
  32. ** granted without fee, provided that the above copyright notices and
  33. ** this notice appears in all source code copies, and that none of
  34. ** the names of Open Software Foundation, Inc., Hewlett-Packard
  35. ** Company, Microsoft, or Digital Equipment Corporation be used in
  36. ** advertising or publicity pertaining to distribution of the software
  37. ** without specific, written prior permission. Neither Open Software
  38. ** Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital
  39. ** Equipment Corporation makes any representations about the
  40. ** suitability of this software for any purpose.
  41. */
  42. #ifdef HAVE_CONFIG_H
  43. #include "config.h"
  44. #endif
  45. #ifndef _WIN32
  46. #include <sys/types.h>
  47. #include <sys/time.h>
  48. #include <sys/sysinfo.h>
  49. #endif
  50. #ifdef HAVE_LIBGCRYPT
  51. #include <gcrypt.h>
  52. /* md5 /sha abstraction layer */
  53. #define SHA_CTX gcry_md_hd_t
  54. #define SHA1_Init(md) gcry_md_open(md, GCRY_MD_SHA1, 0)
  55. #define SHA1_Update(md, data, len) gcry_md_write(*(md), data, len)
  56. #define SHA1_Final(buf, md) memcpy(buf, gcry_md_read(*(md), GCRY_MD_SHA1), gcry_md_get_algo_dlen(GCRY_MD_SHA1))
  57. #define MD5_CTX gcry_md_hd_t
  58. #define MD5Init(md) gcry_md_open(md, GCRY_MD_MD5, 0)
  59. #define MD5Update(md, data, len) gcry_md_write(*(md), data, len)
  60. #define MD5Final(buf, md) memcpy(buf, gcry_md_read(*(md), GCRY_MD_MD5), gcry_md_get_algo_dlen(GCRY_MD_MD5))
  61. #endif
  62. /* set the following to the number of 100ns ticks of the actual
  63. resolution of your system's clock */
  64. #define UUIDS_PER_TICK 1024
  65. /* Set the following to a calls to get and release a global lock */
  66. #define LOCK
  67. #define UNLOCK
  68. typedef unsigned long unsigned32;
  69. typedef unsigned short unsigned16;
  70. typedef unsigned char unsigned8;
  71. typedef unsigned char byte;
  72. /* Set this to what your compiler uses for 64-bit data type */
  73. #ifdef _WIN32
  74. #define unsigned64_t unsigned __int64
  75. #define I64(C) C
  76. #else
  77. #define unsigned64_t unsigned long long
  78. #define I64(C) C##LL
  79. #endif
  80. typedef unsigned64_t uuid_time_t;
  81. typedef struct {
  82. char nodeID[6];
  83. } uuid_node_t;
  84. void get_ieee_node_identifier(uuid_node_t *node);
  85. void get_system_time(uuid_time_t *uuid_time);
  86. void get_random_info(char seed[16]);