changeset 406:1a852266ba74

tfo moved to gsm-net-reveng repository
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 24 May 2024 21:19:59 +0000
parents f7df0f4d7d4f
children 183e81c8f6c0
files .hgignore tfo/Makefile tfo/find-is-hdr.c
diffstat 3 files changed, 0 insertions(+), 98 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sat Mar 18 05:57:23 2023 +0000
+++ b/.hgignore	Fri May 24 21:19:59 2024 +0000
@@ -82,5 +82,3 @@
 ^pirollback/dumpjournal$
 ^pirollback/inopath$
 ^pirollback/rollback$
-
-^tfo/find-is-hdr$
--- a/tfo/Makefile	Sat Mar 18 05:57:23 2023 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-CC=	gcc
-CFLAGS=	-O2
-STD=	find-is-hdr
-PROGS=	${STD}
-
-all:	${PROGS}
-
-${STD}:
-	${CC} ${CFLAGS} -o $@ $@.c
-
-find-is-hdr:	find-is-hdr.c
-
-clean:
-	rm -f ${PROGS} *.o *errs *.out
--- a/tfo/find-is-hdr.c	Sat Mar 18 05:57:23 2023 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * This program reads a binary file containing a G.711 PCM stream capture
- * and looks for an IS_Header pattern as defined in ETSI TS 101 504
- * (GSM 08.62) section A.1.2.  The objective is to analyze PCM streams
- * originating from extant commercial GSM network operators and see if
- * they implement in-band TFO.
- */
-
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-static char *pcmfile;
-static size_t pcm_file_size;
-static u_char *filemap;
-
-static const u_char hdr_pattern[20] =	{0, 1, 0, 1, 0, 1, 1, 0, 1, 0,
-					 0, 1, 1, 0, 1, 0, 1, 0, 0, 1};
-
-static void
-mmap_pcm_file()
-{
-	int fd;
-	struct stat st;
-
-	fd = open(pcmfile, O_RDONLY);
-	if (fd < 0) {
-		perror(pcmfile);
-		exit(1);
-	}
-	fstat(fd, &st);
-	if (!S_ISREG(st.st_mode)) {
-		fprintf(stderr, "error: %s is not a regular file\n", pcmfile);
-		exit(1);
-	}
-	pcm_file_size = st.st_size;
-	if (pcm_file_size < 320) {
-		fprintf(stderr, "error: %s is too short\n", pcmfile);
-		exit(1);
-	}
-	filemap = mmap(NULL, pcm_file_size, PROT_READ, MAP_PRIVATE, fd, 0L);
-	if (filemap == MAP_FAILED) {
-		perror("mmap");
-		exit(1);
-	}
-	close(fd);
-}
-
-static void
-try_offset(offset)
-	size_t offset;
-{
-	unsigned n;
-
-	for (n = 0; n < 20; n++) {
-		if ((filemap[offset + n * 16] & 1) != hdr_pattern[n])
-			return;
-	}
-	printf("Found IS_Header at offset %lu (0x%lx)\n", (u_long) offset,
-		(u_long) offset);
-}
-
-main(argc, argv)
-	char **argv;
-{
-	size_t offset, endoff;
-
-	if (argc != 2) {
-		fprintf(stderr, "usage: %s pcm-capture-file\n", argv[0]);
-		exit(1);
-	}
-	pcmfile = argv[1];
-	mmap_pcm_file();
-	endoff = pcm_file_size - 320;
-	for (offset = 0; offset <= endoff; offset++)
-		try_offset(offset);
-	exit(0);
-}