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

Function ifclonecreate

tools/ifconfig/ifclone.c:171–212  ·  view source on GitHub ↗

* Do the actual clone operation. Any parameters must have been * setup by now. If a callback has been setup to do the work * then defer to it; otherwise do a simple create operation with * no parameters. */

Source from the content-addressed store, hash-verified

169 * no parameters.
170 */
171static void
172ifclonecreate(int s, void *arg)
173{
174 struct ifreq ifr;
175 struct clone_defcb *dcp;
176
177 memset(&ifr, 0, sizeof(ifr));
178 (void) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
179
180 /* Try to find a default callback by filter */
181 SLIST_FOREACH(dcp, &clone_defcbh, next) {
182 if (dcp->clone_mt == MT_FILTER &&
183 dcp->ifmatch(ifr.ifr_name) != 0)
184 break;
185 }
186
187 if (dcp == NULL) {
188 /* Try to find a default callback by prefix */
189 SLIST_FOREACH(dcp, &clone_defcbh, next) {
190 if (dcp->clone_mt == MT_PREFIX &&
191 strncmp(dcp->ifprefix, ifr.ifr_name,
192 strlen(dcp->ifprefix)) == 0)
193 break;
194 }
195 }
196
197 if (dcp == NULL || dcp->clone_cb == NULL) {
198 /* NB: no parameters */
199 ioctl_ifcreate(s, &ifr);
200 } else {
201 dcp->clone_cb(s, &ifr);
202 }
203
204 /*
205 * If we get a different name back than we put in, update record and
206 * indicate it should be printed later.
207 */
208 if (strncmp(name, ifr.ifr_name, sizeof(name)) != 0) {
209 strlcpy(name, ifr.ifr_name, sizeof(name));
210 printifname = 1;
211 }
212}
213
214static
215DECL_CMD_FUNC(clone_create, arg, d)

Callers

nothing calls this directly

Calls 4

memsetFunction · 0.85
strncmpFunction · 0.85
ioctl_ifcreateFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected