xref: /openbmc/linux/tools/perf/trace/beauty/socket.sh (revision 2cf1c348)
1#!/bin/sh
2# SPDX-License-Identifier: LGPL-2.1
3
4if [ $# -gt 0 ] ; then
5	uapi_header_dir=$1
6	beauty_header_dir=$2
7else
8	uapi_header_dir=tools/include/uapi/linux/
9	beauty_header_dir=tools/perf/trace/beauty/include/linux/
10fi
11
12printf "static const char *socket_ipproto[] = {\n"
13ipproto_regex='^[[:space:]]+IPPROTO_(\w+)[[:space:]]+=[[:space:]]+([[:digit:]]+),.*'
14
15egrep $ipproto_regex ${uapi_header_dir}/in.h | \
16	sed -r "s/$ipproto_regex/\2 \1/g"	| \
17	sort -n | xargs printf "\t[%s] = \"%s\",\n"
18printf "};\n\n"
19
20printf "static const char *socket_level[] = {\n"
21socket_level_regex='^#define[[:space:]]+SOL_(\w+)[[:space:]]+([[:digit:]]+)([[:space:]]+\/.*)?'
22
23egrep $socket_level_regex ${beauty_header_dir}/socket.h | \
24	sed -r "s/$socket_level_regex/\2 \1/g"	| \
25	sort -n | xargs printf "\t[%s] = \"%s\",\n"
26printf "};\n\n"
27
28printf 'DEFINE_STRARRAY(socket_level, "SOL_");\n'
29