* Get a netgraph control message. * Check it is one we understand. If needed, send a response. * We sometimes save the address for an async action later. * Always free the message. */
| 760 | * Always free the message. |
| 761 | */ |
| 762 | static int |
| 763 | ng_pppoe_rcvmsg(node_p node, item_p item, hook_p lasthook) |
| 764 | { |
| 765 | struct epoch_tracker et; |
| 766 | priv_p privp = NG_NODE_PRIVATE(node); |
| 767 | struct ngpppoe_init_data *ourmsg = NULL; |
| 768 | struct ng_mesg *resp = NULL; |
| 769 | int error = 0; |
| 770 | hook_p hook = NULL; |
| 771 | sessp sp = NULL; |
| 772 | negp neg = NULL; |
| 773 | struct ng_mesg *msg; |
| 774 | |
| 775 | NGI_GET_MSG(item, msg); |
| 776 | CTR5(KTR_NET, "%20s: node [%x] (%p) got message %d with cookie %d", |
| 777 | __func__, node->nd_ID, node, msg->header.cmd, |
| 778 | msg->header.typecookie); |
| 779 | |
| 780 | /* Deal with message according to cookie and command. */ |
| 781 | switch (msg->header.typecookie) { |
| 782 | case NGM_PPPOE_COOKIE: |
| 783 | switch (msg->header.cmd) { |
| 784 | case NGM_PPPOE_CONNECT: |
| 785 | case NGM_PPPOE_LISTEN: |
| 786 | case NGM_PPPOE_OFFER: |
| 787 | case NGM_PPPOE_SERVICE: |
| 788 | case NGM_PPPOE_SEND_HURL: |
| 789 | case NGM_PPPOE_SEND_MOTM: |
| 790 | ourmsg = (struct ngpppoe_init_data *)msg->data; |
| 791 | if (msg->header.arglen < sizeof(*ourmsg)) { |
| 792 | log(LOG_ERR, "ng_pppoe[%x]: init data too " |
| 793 | "small\n", node->nd_ID); |
| 794 | LEAVE(EMSGSIZE); |
| 795 | } |
| 796 | if (msg->header.cmd == NGM_PPPOE_SEND_HURL || |
| 797 | msg->header.cmd == NGM_PPPOE_SEND_MOTM) { |
| 798 | if (msg->header.arglen - sizeof(*ourmsg) > |
| 799 | PPPOE_PADM_VALUE_SIZE) { |
| 800 | log(LOG_ERR, "ng_pppoe[%x]: message " |
| 801 | "too big\n", node->nd_ID); |
| 802 | LEAVE(EMSGSIZE); |
| 803 | } |
| 804 | } else { |
| 805 | if (msg->header.arglen - sizeof(*ourmsg) > |
| 806 | PPPOE_SERVICE_NAME_SIZE) { |
| 807 | log(LOG_ERR, "ng_pppoe[%x]: service name " |
| 808 | "too big\n", node->nd_ID); |
| 809 | LEAVE(EMSGSIZE); |
| 810 | } |
| 811 | } |
| 812 | if (msg->header.arglen - sizeof(*ourmsg) < |
| 813 | ourmsg->data_len) { |
| 814 | log(LOG_ERR, "ng_pppoe[%x]: init data has bad " |
| 815 | "length, %d should be %zd\n", node->nd_ID, |
| 816 | ourmsg->data_len, |
| 817 | msg->header.arglen - sizeof (*ourmsg)); |
| 818 | LEAVE(EMSGSIZE); |
| 819 | } |
nothing calls this directly
no test coverage detected