* 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. */
| 169 | * no parameters. |
| 170 | */ |
| 171 | static void |
| 172 | ifclonecreate(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 | |
| 214 | static |
| 215 | DECL_CMD_FUNC(clone_create, arg, d) |
nothing calls this directly
no test coverage detected