aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2008-05-20 21:51:01 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2008-05-20 21:51:01 +0000
commit58459d3fba39398b53294beccc307d539bd0db33 (patch)
tree7d78ccd8aad555faaf4ef91c0acc48b9a04ff2de /wiretap
parent5364227de00058969236206467448325f4c823b6 (diff)
Create a new "Wireshark utility" library and move the mpeg-audio stuff from
wiretap to this new libwsutil. This solves http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1677 by making libwireshark no longer depend on libwiretap. svn path=/trunk/; revision=25330
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/Makefile.am2
-rw-r--r--wiretap/Makefile.common2
-rw-r--r--wiretap/Makefile.nmake1
-rw-r--r--wiretap/libwiretap.vcproj8
-rw-r--r--wiretap/mpeg-audio.c96
-rw-r--r--wiretap/mpeg-audio.h98
-rw-r--r--wiretap/mpeg.c2
-rw-r--r--wiretap/wtap.def7
8 files changed, 4 insertions, 212 deletions
diff --git a/wiretap/Makefile.am b/wiretap/Makefile.am
index 179f1ec729..273799ecbb 100644
--- a/wiretap/Makefile.am
+++ b/wiretap/Makefile.am
@@ -35,6 +35,8 @@ if HAVE_WARNINGS_AS_ERRORS
AM_NON_GENERATED_CFLAGS = -Werror
endif
+INCLUDES = -I$(srcdir)/..
+
CLEANFILES = \
libwiretap.a \
libwiretap.la \
diff --git a/wiretap/Makefile.common b/wiretap/Makefile.common
index 5b86801f37..a9d96e9ef7 100644
--- a/wiretap/Makefile.common
+++ b/wiretap/Makefile.common
@@ -54,7 +54,6 @@ NONGENERATED_C_FILES = \
lanalyzer.c \
libpcap.c \
mpeg.c \
- mpeg-audio.c \
netmon.c \
netscreen.c \
nettl.c \
@@ -99,7 +98,6 @@ NONGENERATED_HEADER_FILES = \
lanalyzer.h \
libpcap.h \
mpeg.h \
- mpeg-audio.h \
netmon.h \
netscreen.h \
nettl.h \
diff --git a/wiretap/Makefile.nmake b/wiretap/Makefile.nmake
index 7b60aef4e0..425de19459 100644
--- a/wiretap/Makefile.nmake
+++ b/wiretap/Makefile.nmake
@@ -21,6 +21,7 @@ OBJECTS=$(NONGENERATED_C_FILES:.c=.obj) $(GENERATED_C_FILES:.c=.obj) file_util.o
wiretap_LIBS = \
$(GLIB_LIBS) \
+ ..\wsutil\wsutil.lib \
$(ZLIB_LIBS)
all: checkapi wiretap-$(WTAP_VERSION).dll
diff --git a/wiretap/libwiretap.vcproj b/wiretap/libwiretap.vcproj
index 82ada99379..438d5373c6 100644
--- a/wiretap/libwiretap.vcproj
+++ b/wiretap/libwiretap.vcproj
@@ -156,10 +156,6 @@
>
</File>
<File
- RelativePath=".\mpeg-audio.c"
- >
- </File>
- <File
RelativePath=".\mpeg.c"
>
</File>
@@ -322,10 +318,6 @@
>
</File>
<File
- RelativePath=".\mpeg-audio.h"
- >
- </File>
- <File
RelativePath=".\mpeg.h"
>
</File>
diff --git a/wiretap/mpeg-audio.c b/wiretap/mpeg-audio.c
deleted file mode 100644
index cca12be56b..0000000000
--- a/wiretap/mpeg-audio.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/* mpeg-audio.c
- *
- * MPEG Audio header dissection
- * Written by Shaun Jackman <sjackman@gmail.com>
- * Copyright 2007 Shaun Jackman
- *
- * $Id$
- *
- * Wiretap Library
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "mpeg-audio.h"
-
-static const int mpa_versions[4] = { 2, -1, 1, 0 };
-static const int mpa_layers[4] = { -1, 2, 1, 0 };
-
-static const unsigned mpa_samples_data[3][3] = {
- { 384, 1152, 1152 },
- { 384, 1152, 576 },
- { 384, 1152, 576 },
-};
-
-static const unsigned mpa_bitrates[3][3][16] = { /* kb/s */
- {
- { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 },
- { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 },
- { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 },
- },
- {
- { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256 },
- { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 },
- { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 },
- },
- {
- { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256 },
- { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 },
- { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160 },
- },
-};
-
-static const unsigned mpa_frequencies[3][4] = {
- { 44100, 48000, 32000 },
- { 22050, 24000, 16000 },
- { 11025, 12000, 8000 },
-};
-
-static const unsigned mpa_padding_data[3] = { 4, 1, 1 };
-
-int
-mpa_version(const struct mpa *mpa)
-{
- return mpa_versions[mpa->version];
-}
-
-int
-mpa_layer(const struct mpa *mpa)
-{
- return mpa_layers[mpa->layer];
-}
-
-unsigned
-mpa_samples(const struct mpa *mpa)
-{
- return mpa_samples_data[mpa_versions[mpa->version]][mpa_layer(mpa)];
-}
-
-unsigned
-mpa_bitrate(const struct mpa *mpa)
-{
- return (1000 * (mpa_bitrates[mpa_versions[mpa->version]][mpa_layers[mpa->layer]][mpa->bitrate]));
-}
-
-unsigned
-mpa_frequency(const struct mpa *mpa)
-{
- return(mpa_frequencies[mpa_versions[mpa->version]][mpa->frequency]);
-}
-
-unsigned
-mpa_padding(const struct mpa *mpa)
-{
- return(mpa->padding ? mpa_padding_data[mpa_layers[mpa->layer]] : 0);
-}
diff --git a/wiretap/mpeg-audio.h b/wiretap/mpeg-audio.h
deleted file mode 100644
index d0dfd26da2..0000000000
--- a/wiretap/mpeg-audio.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* mpeg-audio.h
- *
- * MPEG Audio header dissection
- * Written by Shaun Jackman <sjackman@gmail.com>
- * Copyright 2007 Shaun Jackman
- *
- * $Id$
- *
- * Wiretap Library
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef MPA_H
-#define MPA_H 1
-
-struct mpa {
- unsigned emphasis :2;
- unsigned original :1;
- unsigned copyright :1;
- unsigned modeext :2;
- unsigned mode :2;
- unsigned private :1;
- unsigned padding :1;
- unsigned frequency :2;
- unsigned bitrate :4;
- unsigned protection :1;
- unsigned layer :2;
- unsigned version :2;
- unsigned sync :11;
-};
-
-#define MPA_UNMARSHAL_SYNC(n) ((n) >> 21 & 0x7ff)
-#define MPA_UNMARSHAL_VERSION(n) ((n) >> 19 & 0x3)
-#define MPA_UNMARSHAL_LAYER(n) ((n) >> 17 & 0x3)
-#define MPA_UNMARSHAL_PROTECTION(n) ((n) >> 16 & 0x1)
-#define MPA_UNMARSHAL_BITRATE(n) ((n) >> 12 & 0xf)
-#define MPA_UNMARSHAL_FREQUENCY(n) ((n) >> 10 & 0x3)
-#define MPA_UNMARSHAL_PADDING(n) ((n) >> 9 & 0x1)
-#define MPA_UNMARSHAL_PRIVATE(n) ((n) >> 8 & 0x1)
-#define MPA_UNMARSHAL_MODE(n) ((n) >> 6 & 0x3)
-#define MPA_UNMARSHAL_MODEEXT(n) ((n) >> 4 & 0x3)
-#define MPA_UNMARSHAL_COPYRIGHT(n) ((n) >> 3 & 0x1)
-#define MPA_UNMARSHAL_ORIGINAL(n) ((n) >> 2 & 0x1)
-#define MPA_UNMARSHAL_EMPHASIS(n) ((n) >> 0 & 0x3)
-
-#define MPA_UNMARSHAL(mpa, n) do { \
- (mpa)->sync = MPA_UNMARSHAL_SYNC(n); \
- (mpa)->version = MPA_UNMARSHAL_VERSION(n); \
- (mpa)->layer = MPA_UNMARSHAL_LAYER(n); \
- (mpa)->protection = MPA_UNMARSHAL_PROTECTION(n); \
- (mpa)->bitrate = MPA_UNMARSHAL_BITRATE(n); \
- (mpa)->frequency = MPA_UNMARSHAL_FREQUENCY(n); \
- (mpa)->padding = MPA_UNMARSHAL_PADDING(n); \
- (mpa)->private = MPA_UNMARSHAL_PRIVATE(n); \
- (mpa)->mode = MPA_UNMARSHAL_MODE(n); \
- (mpa)->modeext = MPA_UNMARSHAL_MODEEXT(n); \
- (mpa)->copyright = MPA_UNMARSHAL_COPYRIGHT(n); \
- (mpa)->original = MPA_UNMARSHAL_ORIGINAL(n); \
- (mpa)->emphasis = MPA_UNMARSHAL_EMPHASIS(n); \
- } while (0)
-
-int mpa_version(const struct mpa *);
-int mpa_layer(const struct mpa *);
-unsigned mpa_samples(const struct mpa *);
-unsigned mpa_bitrate(const struct mpa *);
-unsigned mpa_frequency(const struct mpa *);
-unsigned mpa_padding(const struct mpa *);
-
-#define MPA_DATA_BYTES(mpa) (mpa_bitrate(mpa) * mpa_samples(mpa) \
- / mpa_frequency(mpa) / 8)
-#define MPA_BYTES(mpa) (MPA_DATA_BYTES(mpa) + mpa_padding(mpa))
-#define MPA_DURATION_NS(mpa) \
- (1000000000 / mpa_frequency(mpa) * mpa_samples(mpa))
-
-enum { MPA_SYNC = 0x7ff };
-
-#define MPA_SYNC_VALID(mpa) ((mpa)->sync == MPA_SYNC)
-#define MPA_VERSION_VALID(mpa) (mpa_version(mpa) >= 0)
-#define MPA_LAYER_VALID(mpa) (mpa_layer(mpa) >= 0)
-#define MPA_BITRATE_VALID(mpa) (mpa_bitrate(mpa) > 0)
-#define MPA_FREQUENCY_VALID(mpa) (mpa_frequency(mpa) > 0)
-#define MPA_VALID(mpa) (MPA_SYNC_VALID(mpa) \
- && MPA_VERSION_VALID(mpa) && MPA_LAYER_VALID(mpa) \
- && MPA_BITRATE_VALID(mpa) && MPA_FREQUENCY_VALID(mpa))
-
-#endif
diff --git a/wiretap/mpeg.c b/wiretap/mpeg.c
index 1e15045cc0..8ec9e65fbe 100644
--- a/wiretap/mpeg.c
+++ b/wiretap/mpeg.c
@@ -35,7 +35,7 @@
#endif
#include "mpeg.h"
-#include "mpeg-audio.h"
+#include "wsutil/mpeg-audio.h"
#include "wtap-int.h"
#include "buffer.h"
diff --git a/wiretap/wtap.def b/wiretap/wtap.def
index 573a0e0eed..ce8f7eeaeb 100644
--- a/wiretap/wtap.def
+++ b/wiretap/wtap.def
@@ -28,13 +28,6 @@ file_seek
file_tell
file_error
-mpa_bitrate
-mpa_frequency
-mpa_layer
-mpa_padding
-mpa_samples
-mpa_version
-
wtap_buf_ptr
wtap_close
wtap_dump