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

Function setpfsync_syncpeer

tools/ifconfig/ifpfsync.c:96–126  ·  view source on GitHub ↗

ARGSUSED */

Source from the content-addressed store, hash-verified

94
95/* ARGSUSED */
96void
97setpfsync_syncpeer(const char *val, int d, int s, const struct afswtch *rafp)
98{
99 struct pfsyncreq preq;
100 struct addrinfo hints, *peerres;
101 int ecode;
102
103 bzero((char *)&preq, sizeof(struct pfsyncreq));
104 ifr.ifr_data = (caddr_t)&preq;
105
106 if (ioctl(s, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
107 err(1, "SIOCGETPFSYNC");
108
109 memset(&hints, 0, sizeof(hints));
110 hints.ai_family = AF_INET;
111 hints.ai_socktype = SOCK_DGRAM; /*dummy*/
112
113 if ((ecode = getaddrinfo(val, NULL, &hints, &peerres)) != 0)
114 errx(1, "error in parsing address string: %s",
115 gai_strerror(ecode));
116
117 if (peerres->ai_addr->sa_family != AF_INET)
118 errx(1, "only IPv4 addresses supported for the syncpeer");
119
120 preq.pfsyncr_syncpeer.s_addr = ((struct sockaddr_in *)
121 peerres->ai_addr)->sin_addr.s_addr;
122
123 if (ioctl(s, SIOCSETPFSYNC, (caddr_t)&ifr) == -1)
124 err(1, "SIOCSETPFSYNC");
125 freeaddrinfo(peerres);
126}
127
128/* ARGSUSED */
129void

Callers

nothing calls this directly

Calls 6

bzeroFunction · 0.85
memsetFunction · 0.85
getaddrinfoFunction · 0.85
gai_strerrorFunction · 0.85
freeaddrinfoFunction · 0.85
ioctlFunction · 0.50

Tested by

no test coverage detected