~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/trace/beauty/sockaddr.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/perf/trace/beauty/sockaddr.c (Architecture ppc) and /tools/perf/trace/beauty/sockaddr.c (Architecture sparc)


  1 // SPDX-License-Identifier: LGPL-2.1                1 // SPDX-License-Identifier: LGPL-2.1
  2 // Copyright (C) 2018, Red Hat Inc, Arnaldo Ca      2 // Copyright (C) 2018, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
  3                                                     3 
  4 #include "trace/beauty/beauty.h"                    4 #include "trace/beauty/beauty.h"
  5 #include <sys/socket.h>                             5 #include <sys/socket.h>
  6 #include <sys/types.h>                              6 #include <sys/types.h>
  7 #include <sys/un.h>                                 7 #include <sys/un.h>
  8 #include <arpa/inet.h>                              8 #include <arpa/inet.h>
  9                                                     9 
 10 #include "trace/beauty/generated/sockaddr.c"       10 #include "trace/beauty/generated/sockaddr.c"
 11 DEFINE_STRARRAY(socket_families, "PF_");           11 DEFINE_STRARRAY(socket_families, "PF_");
 12                                                    12 
 13 static size_t af_inet__scnprintf(struct sockad     13 static size_t af_inet__scnprintf(struct sockaddr *sa, char *bf, size_t size)
 14 {                                                  14 {
 15         struct sockaddr_in *sin = (struct sock     15         struct sockaddr_in *sin = (struct sockaddr_in *)sa;
 16         char tmp[16];                              16         char tmp[16];
 17         return scnprintf(bf, size, ", port: %d     17         return scnprintf(bf, size, ", port: %d, addr: %s", ntohs(sin->sin_port),
 18                          inet_ntop(sin->sin_fa     18                          inet_ntop(sin->sin_family, &sin->sin_addr, tmp, sizeof(tmp)));
 19 }                                                  19 }
 20                                                    20 
 21 static size_t af_inet6__scnprintf(struct socka     21 static size_t af_inet6__scnprintf(struct sockaddr *sa, char *bf, size_t size)
 22 {                                                  22 {
 23         struct sockaddr_in6 *sin6 = (struct so     23         struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa;
 24         u32 flowinfo = ntohl(sin6->sin6_flowin     24         u32 flowinfo = ntohl(sin6->sin6_flowinfo);
 25         char tmp[512];                             25         char tmp[512];
 26         size_t printed = scnprintf(bf, size, "     26         size_t printed = scnprintf(bf, size, ", port: %d, addr: %s", ntohs(sin6->sin6_port),
 27                                    inet_ntop(s     27                                    inet_ntop(sin6->sin6_family, &sin6->sin6_addr, tmp, sizeof(tmp)));
 28         if (flowinfo != 0)                         28         if (flowinfo != 0)
 29                 printed += scnprintf(bf + prin     29                 printed += scnprintf(bf + printed, size - printed, ", flowinfo: %lu", flowinfo);
 30         if (sin6->sin6_scope_id != 0)              30         if (sin6->sin6_scope_id != 0)
 31                 printed += scnprintf(bf + prin     31                 printed += scnprintf(bf + printed, size - printed, ", scope_id: %lu", sin6->sin6_scope_id);
 32                                                    32 
 33         return printed;                            33         return printed;
 34 }                                                  34 }
 35                                                    35 
 36 static size_t af_local__scnprintf(struct socka     36 static size_t af_local__scnprintf(struct sockaddr *sa, char *bf, size_t size)
 37 {                                                  37 {
 38         struct sockaddr_un *sun = (struct sock     38         struct sockaddr_un *sun = (struct sockaddr_un *)sa;
 39         return scnprintf(bf, size, ", path: %s     39         return scnprintf(bf, size, ", path: %s", sun->sun_path);
 40 }                                                  40 }
 41                                                    41 
 42 static size_t (*af_scnprintfs[])(struct sockad     42 static size_t (*af_scnprintfs[])(struct sockaddr *sa, char *bf, size_t size) = {
 43         [AF_LOCAL] = af_local__scnprintf,          43         [AF_LOCAL] = af_local__scnprintf,
 44         [AF_INET]  = af_inet__scnprintf,           44         [AF_INET]  = af_inet__scnprintf,
 45         [AF_INET6] = af_inet6__scnprintf,          45         [AF_INET6] = af_inet6__scnprintf,
 46 };                                                 46 };
 47                                                    47 
 48 static size_t syscall_arg__scnprintf_augmented     48 static size_t syscall_arg__scnprintf_augmented_sockaddr(struct syscall_arg *arg, char *bf, size_t size)
 49 {                                                  49 {
 50         struct sockaddr *sa = (struct sockaddr     50         struct sockaddr *sa = (struct sockaddr *)&arg->augmented.args->value;
 51         char family[32];                           51         char family[32];
 52         size_t printed;                            52         size_t printed;
 53                                                    53 
 54         strarray__scnprintf(&strarray__socket_     54         strarray__scnprintf(&strarray__socket_families, family, sizeof(family), "%d", arg->show_string_prefix, sa->sa_family);
 55         printed = scnprintf(bf, size, "{ .fami     55         printed = scnprintf(bf, size, "{ .family: %s", family);
 56                                                    56 
 57         if (sa->sa_family < ARRAY_SIZE(af_scnp     57         if (sa->sa_family < ARRAY_SIZE(af_scnprintfs) && af_scnprintfs[sa->sa_family])
 58                 printed += af_scnprintfs[sa->s     58                 printed += af_scnprintfs[sa->sa_family](sa, bf + printed, size - printed);
 59                                                    59 
 60         return printed + scnprintf(bf + printe     60         return printed + scnprintf(bf + printed, size - printed, " }");
 61 }                                                  61 }
 62                                                    62 
 63 size_t syscall_arg__scnprintf_sockaddr(char *b     63 size_t syscall_arg__scnprintf_sockaddr(char *bf, size_t size, struct syscall_arg *arg)
 64 {                                                  64 {
 65         if (arg->augmented.args)                   65         if (arg->augmented.args)
 66                 return syscall_arg__scnprintf_     66                 return syscall_arg__scnprintf_augmented_sockaddr(arg, bf, size);
 67                                                    67 
 68         return scnprintf(bf, size, "%#lx", arg     68         return scnprintf(bf, size, "%#lx", arg->val);
 69 }                                                  69 }
 70                                                    70 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php