at master 76 lines 1.7 kB view raw
1// SPDX-License-Identifier: LGPL-2.1 2#include <sys/types.h> 3#include <sys/socket.h> 4 5#ifndef MSG_PROBE 6#define MSG_PROBE 0x10 7#endif 8#ifndef MSG_WAITFORONE 9#define MSG_WAITFORONE 0x10000 10#endif 11#ifndef MSG_BATCH 12#define MSG_BATCH 0x40000 13#endif 14#ifndef MSG_SOCK_DEVMEM 15#define MSG_SOCK_DEVMEM 0x2000000 16#endif 17#ifndef MSG_ZEROCOPY 18#define MSG_ZEROCOPY 0x4000000 19#endif 20#ifndef MSG_SPLICE_PAGES 21#define MSG_SPLICE_PAGES 0x8000000 22#endif 23#ifndef MSG_FASTOPEN 24#define MSG_FASTOPEN 0x20000000 25#endif 26#ifndef MSG_CMSG_CLOEXEC 27# define MSG_CMSG_CLOEXEC 0x40000000 28#endif 29 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_FLAG 69 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_flags