socket.sh (03ab8e6297acd1bc0eedaa050e2a1635c576fd11) socket.sh (818448e9cf92e5c6b3c10320372eefcbe4174e4f)
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
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 | \
15grep -E $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
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 | \
23grep -E $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'
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'