18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: LGPL-2.1 28c2ecf20Sopenharmony_ci#include <sys/types.h> 38c2ecf20Sopenharmony_ci#include <sys/socket.h> 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#ifndef MSG_PROBE 68c2ecf20Sopenharmony_ci#define MSG_PROBE 0x10 78c2ecf20Sopenharmony_ci#endif 88c2ecf20Sopenharmony_ci#ifndef MSG_WAITFORONE 98c2ecf20Sopenharmony_ci#define MSG_WAITFORONE 0x10000 108c2ecf20Sopenharmony_ci#endif 118c2ecf20Sopenharmony_ci#ifndef MSG_SENDPAGE_NOTLAST 128c2ecf20Sopenharmony_ci#define MSG_SENDPAGE_NOTLAST 0x20000 138c2ecf20Sopenharmony_ci#endif 148c2ecf20Sopenharmony_ci#ifndef MSG_FASTOPEN 158c2ecf20Sopenharmony_ci#define MSG_FASTOPEN 0x20000000 168c2ecf20Sopenharmony_ci#endif 178c2ecf20Sopenharmony_ci#ifndef MSG_CMSG_CLOEXEC 188c2ecf20Sopenharmony_ci# define MSG_CMSG_CLOEXEC 0x40000000 198c2ecf20Sopenharmony_ci#endif 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistatic size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, 228c2ecf20Sopenharmony_ci struct syscall_arg *arg) 238c2ecf20Sopenharmony_ci{ 248c2ecf20Sopenharmony_ci bool show_prefix = arg->show_string_prefix; 258c2ecf20Sopenharmony_ci const char *prefix = "MSG_"; 268c2ecf20Sopenharmony_ci int printed = 0, flags = arg->val; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci if (flags == 0) 298c2ecf20Sopenharmony_ci return scnprintf(bf, size, "NONE"); 308c2ecf20Sopenharmony_ci#define P_MSG_FLAG(n) \ 318c2ecf20Sopenharmony_ci if (flags & MSG_##n) { \ 328c2ecf20Sopenharmony_ci printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \ 338c2ecf20Sopenharmony_ci flags &= ~MSG_##n; \ 348c2ecf20Sopenharmony_ci } 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci P_MSG_FLAG(OOB); 378c2ecf20Sopenharmony_ci P_MSG_FLAG(PEEK); 388c2ecf20Sopenharmony_ci P_MSG_FLAG(DONTROUTE); 398c2ecf20Sopenharmony_ci P_MSG_FLAG(CTRUNC); 408c2ecf20Sopenharmony_ci P_MSG_FLAG(PROBE); 418c2ecf20Sopenharmony_ci P_MSG_FLAG(TRUNC); 428c2ecf20Sopenharmony_ci P_MSG_FLAG(DONTWAIT); 438c2ecf20Sopenharmony_ci P_MSG_FLAG(EOR); 448c2ecf20Sopenharmony_ci P_MSG_FLAG(WAITALL); 458c2ecf20Sopenharmony_ci P_MSG_FLAG(FIN); 468c2ecf20Sopenharmony_ci P_MSG_FLAG(SYN); 478c2ecf20Sopenharmony_ci P_MSG_FLAG(CONFIRM); 488c2ecf20Sopenharmony_ci P_MSG_FLAG(RST); 498c2ecf20Sopenharmony_ci P_MSG_FLAG(ERRQUEUE); 508c2ecf20Sopenharmony_ci P_MSG_FLAG(NOSIGNAL); 518c2ecf20Sopenharmony_ci P_MSG_FLAG(MORE); 528c2ecf20Sopenharmony_ci P_MSG_FLAG(WAITFORONE); 538c2ecf20Sopenharmony_ci P_MSG_FLAG(SENDPAGE_NOTLAST); 548c2ecf20Sopenharmony_ci P_MSG_FLAG(FASTOPEN); 558c2ecf20Sopenharmony_ci P_MSG_FLAG(CMSG_CLOEXEC); 568c2ecf20Sopenharmony_ci#undef P_MSG_FLAG 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci if (flags) 598c2ecf20Sopenharmony_ci printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci return printed; 628c2ecf20Sopenharmony_ci} 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define SCA_MSG_FLAGS syscall_arg__scnprintf_msg_flags 65