77 lines · c
1// SPDX-License-Identifier: LGPL-2.12#include <sys/types.h>3#include <sys/socket.h>4 5#ifndef MSG_PROBE6#define MSG_PROBE 0x107#endif8#ifndef MSG_WAITFORONE9#define MSG_WAITFORONE 0x1000010#endif11#ifndef MSG_BATCH12#define MSG_BATCH 0x4000013#endif14#ifndef MSG_SOCK_DEVMEM15#define MSG_SOCK_DEVMEM 0x200000016#endif17#ifndef MSG_ZEROCOPY18#define MSG_ZEROCOPY 0x400000019#endif20#ifndef MSG_SPLICE_PAGES21#define MSG_SPLICE_PAGES 0x800000022#endif23#ifndef MSG_FASTOPEN24#define MSG_FASTOPEN 0x2000000025#endif26#ifndef MSG_CMSG_CLOEXEC27# define MSG_CMSG_CLOEXEC 0x4000000028#endif29 30static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size,31 struct syscall_arg *arg)32{33 bool show_prefix = arg->show_string_prefix;34 const char *prefix = "MSG_";35 int printed = 0, flags = arg->val;36 37 if (flags == 0)38 return scnprintf(bf, size, "NONE");39#define P_MSG_FLAG(n) \40 if (flags & MSG_##n) { \41 printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \42 flags &= ~MSG_##n; \43 }44 45 P_MSG_FLAG(OOB);46 P_MSG_FLAG(PEEK);47 P_MSG_FLAG(DONTROUTE);48 P_MSG_FLAG(CTRUNC);49 P_MSG_FLAG(PROBE);50 P_MSG_FLAG(TRUNC);51 P_MSG_FLAG(DONTWAIT);52 P_MSG_FLAG(EOR);53 P_MSG_FLAG(WAITALL);54 P_MSG_FLAG(FIN);55 P_MSG_FLAG(SYN);56 P_MSG_FLAG(CONFIRM);57 P_MSG_FLAG(RST);58 P_MSG_FLAG(ERRQUEUE);59 P_MSG_FLAG(NOSIGNAL);60 P_MSG_FLAG(MORE);61 P_MSG_FLAG(WAITFORONE);62 P_MSG_FLAG(BATCH);63 P_MSG_FLAG(SOCK_DEVMEM);64 P_MSG_FLAG(ZEROCOPY);65 P_MSG_FLAG(SPLICE_PAGES);66 P_MSG_FLAG(FASTOPEN);67 P_MSG_FLAG(CMSG_CLOEXEC);68#undef P_MSG_FLAG69 70 if (flags)71 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);72 73 return printed;74}75 76#define SCA_MSG_FLAGS syscall_arg__scnprintf_msg_flags77