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

Function ng_pptpgre_rcvmsg

freebsd/netgraph/ng_pptpgre.c:413–499  ·  view source on GitHub ↗

* Receive a control message. */

Source from the content-addressed store, hash-verified

411 * Receive a control message.
412 */
413static int
414ng_pptpgre_rcvmsg(node_p node, item_p item, hook_p lasthook)
415{
416 const priv_p priv = NG_NODE_PRIVATE(node);
417 struct ng_mesg *resp = NULL;
418 int error = 0;
419 struct ng_mesg *msg;
420
421 NGI_GET_MSG(item, msg);
422 switch (msg->header.typecookie) {
423 case NGM_PPTPGRE_COOKIE:
424 switch (msg->header.cmd) {
425 case NGM_PPTPGRE_SET_CONFIG:
426 {
427 struct ng_pptpgre_conf *const newConf =
428 (struct ng_pptpgre_conf *) msg->data;
429 hpriv_p hpriv;
430 uint16_t hash;
431
432 /* Check for invalid or illegal config */
433 if (msg->header.arglen != sizeof(*newConf))
434 ERROUT(EINVAL);
435 /* Try to find session by cid. */
436 hpriv = ng_pptpgre_find_session(priv, newConf->cid);
437 /* If not present - use upper. */
438 if (hpriv == NULL) {
439 hpriv = &priv->uppersess;
440 LIST_REMOVE(hpriv, sessions);
441 hash = SESSHASH(newConf->cid);
442 LIST_INSERT_HEAD(&priv->sesshash[hash], hpriv,
443 sessions);
444 }
445 ng_pptpgre_reset(hpriv); /* reset on configure */
446 hpriv->conf = *newConf;
447 break;
448 }
449 case NGM_PPTPGRE_GET_CONFIG:
450 {
451 hpriv_p hpriv;
452
453 if (msg->header.arglen == 2) {
454 /* Try to find session by cid. */
455 hpriv = ng_pptpgre_find_session(priv,
456 *((uint16_t *)msg->data));
457 if (hpriv == NULL)
458 ERROUT(EINVAL);
459 } else if (msg->header.arglen == 0) {
460 /* Use upper. */
461 hpriv = &priv->uppersess;
462 } else
463 ERROUT(EINVAL);
464 NG_MKRESPONSE(resp, msg, sizeof(hpriv->conf), M_NOWAIT);
465 if (resp == NULL)
466 ERROUT(ENOMEM);
467 bcopy(&hpriv->conf, resp->data, sizeof(hpriv->conf));
468 break;
469 }
470 case NGM_PPTPGRE_GET_STATS:

Callers

nothing calls this directly

Calls 3

ng_pptpgre_find_sessionFunction · 0.85
ng_pptpgre_resetFunction · 0.85
bzeroFunction · 0.85

Tested by

no test coverage detected