MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vxlan_status

Function vxlan_status

tools/ifconfig/ifvxlan.c:112–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112static void
113vxlan_status(int s)
114{
115 struct ifvxlancfg cfg;
116 char src[NI_MAXHOST], dst[NI_MAXHOST];
117 char srcport[NI_MAXSERV], dstport[NI_MAXSERV];
118 struct sockaddr *lsa, *rsa;
119 int vni, mc, ipv6;
120
121 bzero(&cfg, sizeof(cfg));
122
123 if (do_cmd(s, VXLAN_CMD_GET_CONFIG, &cfg, sizeof(cfg), 0) < 0)
124 return;
125
126 vni = cfg.vxlc_vni;
127 lsa = &cfg.vxlc_local_sa.sa;
128 rsa = &cfg.vxlc_remote_sa.sa;
129 ipv6 = rsa->sa_family == AF_INET6;
130
131 /* Just report nothing if the network identity isn't set yet. */
132 if (vni >= VXLAN_VNI_MAX)
133 return;
134
135#ifndef FSTACK
136 if (getnameinfo(lsa, lsa->sa_len, src, sizeof(src),
137 srcport, sizeof(srcport), NI_NUMERICHOST | NI_NUMERICSERV) != 0)
138 src[0] = srcport[0] = '\0';
139 if (getnameinfo(rsa, rsa->sa_len, dst, sizeof(dst),
140 dstport, sizeof(dstport), NI_NUMERICHOST | NI_NUMERICSERV) != 0)
141 dst[0] = dstport[0] = '\0';
142#else
143 // FIXME: ipv6
144 struct sockaddr_in *sin = (struct sockaddr_in *)lsa;
145 if (inet_ntop(AF_INET, &sin->sin_addr, src, sizeof(src)) == NULL)
146 return;
147
148 sin = (struct sockaddr_in *)rsa;
149 if (inet_ntop(AF_INET, &sin->sin_addr, dst, sizeof(dst)) == NULL)
150 return;
151#endif
152
153 if (!ipv6) {
154 struct sockaddr_in *sin = (struct sockaddr_in *)rsa;
155 mc = IN_MULTICAST(ntohl(sin->sin_addr.s_addr));
156 } else {
157 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)rsa;
158 mc = IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr);
159 }
160
161 printf("\tvxlan vni %d", vni);
162 printf(" local %s%s%s:%s", ipv6 ? "[" : "", src, ipv6 ? "]" : "",
163 srcport);
164 printf(" %s %s%s%s:%s", mc ? "group" : "remote", ipv6 ? "[" : "",
165 dst, ipv6 ? "]" : "", dstport);
166
167 if (verbose) {
168 printf("\n\t\tconfig: ");
169 printf("%slearning portrange %d-%d ttl %d",

Callers

nothing calls this directly

Calls 5

bzeroFunction · 0.85
inet_ntopFunction · 0.85
putcharFunction · 0.85
do_cmdFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected