socket.sh 874 B

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