| 250 | } |
| 251 | |
| 252 | static int |
| 253 | ng_vlan_rcvmsg(node_p node, item_p item, hook_p lasthook) |
| 254 | { |
| 255 | const priv_p priv = NG_NODE_PRIVATE(node); |
| 256 | struct ng_mesg *msg, *resp = NULL; |
| 257 | struct ng_vlan_filter *vf; |
| 258 | hook_p hook; |
| 259 | struct ng_vlan_table *t; |
| 260 | uintptr_t hook_data; |
| 261 | int i, vlan_count; |
| 262 | uint16_t vid; |
| 263 | int error = 0; |
| 264 | |
| 265 | NGI_GET_MSG(item, msg); |
| 266 | /* Deal with message according to cookie and command. */ |
| 267 | switch (msg->header.typecookie) { |
| 268 | case NGM_VLAN_COOKIE: |
| 269 | switch (msg->header.cmd) { |
| 270 | case NGM_VLAN_ADD_FILTER: |
| 271 | /* Check that message is long enough. */ |
| 272 | if (msg->header.arglen != sizeof(*vf)) { |
| 273 | error = EINVAL; |
| 274 | break; |
| 275 | } |
| 276 | vf = (struct ng_vlan_filter *)msg->data; |
| 277 | /* Sanity check the VLAN ID value. */ |
| 278 | #ifdef NG_VLAN_USE_OLD_VLAN_NAME |
| 279 | if (vf->vid == 0 && vf->vid != vf->vlan) { |
| 280 | vf->vid = vf->vlan; |
| 281 | } else if (vf->vid != 0 && vf->vlan != 0 && |
| 282 | vf->vid != vf->vlan) { |
| 283 | error = EINVAL; |
| 284 | break; |
| 285 | } |
| 286 | #endif |
| 287 | if (vf->vid & ~EVL_VLID_MASK || |
| 288 | vf->pcp & ~7 || |
| 289 | vf->cfi & ~1) { |
| 290 | error = EINVAL; |
| 291 | break; |
| 292 | } |
| 293 | /* Check that a referenced hook exists. */ |
| 294 | hook = ng_findhook(node, vf->hook_name); |
| 295 | if (hook == NULL) { |
| 296 | error = ENOENT; |
| 297 | break; |
| 298 | } |
| 299 | /* And is not one of the special hooks. */ |
| 300 | if (hook == priv->downstream_hook || |
| 301 | hook == priv->nomatch_hook) { |
| 302 | error = EINVAL; |
| 303 | break; |
| 304 | } |
| 305 | /* And is not already in service. */ |
| 306 | if (IS_HOOK_VLAN_SET(NG_HOOK_PRIVATE(hook))) { |
| 307 | error = EEXIST; |
| 308 | break; |
| 309 | } |
nothing calls this directly
no test coverage detected