0001
0002 #include <sys/types.h>
0003 #include <sys/socket.h>
0004
0005 #ifndef MSG_PROBE
0006 #define MSG_PROBE 0x10
0007 #endif
0008 #ifndef MSG_WAITFORONE
0009 #define MSG_WAITFORONE 0x10000
0010 #endif
0011 #ifndef MSG_SENDPAGE_NOTLAST
0012 #define MSG_SENDPAGE_NOTLAST 0x20000
0013 #endif
0014 #ifndef MSG_FASTOPEN
0015 #define MSG_FASTOPEN 0x20000000
0016 #endif
0017 #ifndef MSG_CMSG_CLOEXEC
0018 # define MSG_CMSG_CLOEXEC 0x40000000
0019 #endif
0020
0021 static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size,
0022 struct syscall_arg *arg)
0023 {
0024 bool show_prefix = arg->show_string_prefix;
0025 const char *prefix = "MSG_";
0026 int printed = 0, flags = arg->val;
0027
0028 if (flags == 0)
0029 return scnprintf(bf, size, "NONE");
0030 #define P_MSG_FLAG(n) \
0031 if (flags & MSG_##n) { \
0032 printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
0033 flags &= ~MSG_##n; \
0034 }
0035
0036 P_MSG_FLAG(OOB);
0037 P_MSG_FLAG(PEEK);
0038 P_MSG_FLAG(DONTROUTE);
0039 P_MSG_FLAG(CTRUNC);
0040 P_MSG_FLAG(PROBE);
0041 P_MSG_FLAG(TRUNC);
0042 P_MSG_FLAG(DONTWAIT);
0043 P_MSG_FLAG(EOR);
0044 P_MSG_FLAG(WAITALL);
0045 P_MSG_FLAG(FIN);
0046 P_MSG_FLAG(SYN);
0047 P_MSG_FLAG(CONFIRM);
0048 P_MSG_FLAG(RST);
0049 P_MSG_FLAG(ERRQUEUE);
0050 P_MSG_FLAG(NOSIGNAL);
0051 P_MSG_FLAG(MORE);
0052 P_MSG_FLAG(WAITFORONE);
0053 P_MSG_FLAG(SENDPAGE_NOTLAST);
0054 P_MSG_FLAG(FASTOPEN);
0055 P_MSG_FLAG(CMSG_CLOEXEC);
0056 #undef P_MSG_FLAG
0057
0058 if (flags)
0059 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
0060
0061 return printed;
0062 }
0063
0064 #define SCA_MSG_FLAGS syscall_arg__scnprintf_msg_flags