Skip to content

Commit

Permalink
tcpdump-112
Browse files Browse the repository at this point in the history
Imported from tcpdump-112.tar.gz
  • Loading branch information
AppleOSSDistributions committed Feb 7, 2022
1 parent 58ce3b9 commit ccacd09
Show file tree
Hide file tree
Showing 28 changed files with 1,002 additions and 179 deletions.
70 changes: 70 additions & 0 deletions Tests/pktmetadatafilter_test/pktmetadatafilter_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2021 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/

#include <err.h>
#include <sysexits.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "pktmetadatafilter.h"

int main(int argc, char * const argv[])
{
int ch;
char *input_str = NULL;
node_t *pkt_meta_data_expression = NULL;
int verbose = 0;

while ((ch = getopt(argc, argv, "Q:v")) != -1) {
switch (ch) {
case 'Q':
if (input_str != NULL) {
errx(EX_USAGE, "-Q used twice");
}
input_str = strdup(optarg);
if (input_str == NULL) {
errx(EX_OSERR, "calloc() failed");
}
break;
case 'v':
verbose = 1;
break;
}
}
set_parse_verbose(verbose);

pkt_meta_data_expression = parse_expression(input_str);
if (pkt_meta_data_expression == NULL)
errx(EX_SOFTWARE, "invalid expression \"%s\"", input_str);

free(input_str);

return 0;
}
42 changes: 35 additions & 7 deletions gen_tcpdump_version/gen_tcpdump_version.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,49 @@
#!/bin/sh

#RC_ProjectSourceVersion=1.2.3
#RC_ProjectSourceVersion=9999.99.99
#RC_ProjectNameAndSourceVersion=tcpdump-Branch.eng_PR_123456789__623e4dd2d9945f007629c0c7801b418635791e13
#RC_ProjectNameAndSourceVersion=tcpdump-Branch.SHA__ea89f6fda992afd6cd6fec108722c18034564220

print_tcpdump_version()
{
cat tcpdump/VERSION
cat tcpdump/VERSION 2>/dev/null
}


print_darwin_version()
{
darwin_version="${RC_ProjectSourceVersion}"
if [ -z ${darwin_version} ]; then
darwin_version="`git branch|grep '* '|awk '{ print $2 }'`"
fi
echo ${darwin_version}
}

version_string="tcpdump version `print_tcpdump_version` -- Apple version `print_darwin_version`"
if [ -z "${RC_ProjectSourceVersion}" ]; then
if [ -f .git/config ]; then
grep -q tcpdump.git .git/config
if [ $? -eq 0 ]; then
darwin_version="`git status|head -n 1|awk '{ print $NF }'` (`date '+%Y-%m-%d %H:%M:%S'`)"
fi
fi
elif [ "${RC_ProjectSourceVersion}" = "9999.99.99" ]; then
echo ${RC_ProjectNameAndSourceVersion}|grep -q "^tcpdump-Branch.*__"
if [ $? -eq 0 ]; then
branch="`echo ${RC_ProjectNameAndSourceVersion}|sed s/^tcpdump-Branch.*__//`"
if [ -n "${branch}" ]; then
darwin_version="${branch}"
fi
fi
else
darwin_version="${RC_ProjectSourceVersion}"
fi

if [ -z "${darwin_version}" ]; then
darwin_version="main (`date '+%Y-%m-%d %H:%M:%S'`)"
fi

version_string="`print_tcpdump_version` -- Apple version `print_darwin_version`"

if [ -z "${SHARED_DERIVED_FILE_DIR}" ]; then
echo ${version_string}
exit 0
fi

mkdir -p "${SHARED_DERIVED_FILE_DIR}"

Expand Down
47 changes: 47 additions & 0 deletions gen_tcpdump_version/print-tcpdump-git-branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh

#
# print-tcpdump-git-branch.sh
#

PROGNAME="`basename ${0}`"
COMMAND=tcpdump
USAGE="# usage: ${PROGNAME} [-h] [-p <path-of-tcdump-command>] [-v]"
VERBOSE=0

while getopts hp:v OPTION; do
case ${OPTION} in
h) echo "${USAGE}"; exit 0;;

p) COMMAND="${OPTARG}";;

v) VERBOSE=1;;

\?) echo "${USAGE}"; exit 0;;
esac
done

TMPFILE=`mktemp /tmp/${PROGNAME}.XXXXXX` || exit 1

#
# Grab the word after "Apple version ":
# - An official build version is made of digits [0-9] and dots '.'
# - A development build has the branch name followed by the build date
#
VERSION=`${COMMAND} --version 2>&1 |head -n 1|sed s/".*Apple version "//|awk '{ print $1}'`

if [ ${VERBOSE} -ge 1 ]; then
echo "base version of ${COMMAND}: ${VERSION}"
fi

echo "${VERSION}" > "${TMPFILE}"

# Add 'tcpdump-' prefix for official builds
grep -q "[^0-9.]" "${TMPFILE}" &> /dev/null
if [ $? -eq 1 ]; then
VERSION=tcpdump-"${VERSION}"
fi

rm "${TMPFILE}"

echo "${VERSION}"
6 changes: 1 addition & 5 deletions gen_tcpdump_version/print_tcpdump_version.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
//
// main.c
// gen_tcpdump_version.sh
//
// Created by Vincent Lubet on 2/7/17.
//
// print_tcpdump_version.c
//

#include <stdio.h>
Expand Down
Loading

0 comments on commit ccacd09

Please # to comment.