-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
28 changed files
with
1,002 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.