# HG changeset patch # User Mychaela Falconia # Date 1716585599 0 # Node ID 1a852266ba741e66672e027d78ae2d5bdc2633ac # Parent f7df0f4d7d4f80f7a7ff860c98d8bf782104c147 tfo moved to gsm-net-reveng repository diff -r f7df0f4d7d4f -r 1a852266ba74 .hgignore --- 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$ diff -r f7df0f4d7d4f -r 1a852266ba74 tfo/Makefile --- 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 diff -r f7df0f4d7d4f -r 1a852266ba74 tfo/find-is-hdr.c --- 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 -#include -#include -#include -#include -#include -#include - -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); -}