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

Function ng_pred1_rcvmsg

freebsd/netgraph/ng_pred1.c:228–293  ·  view source on GitHub ↗

* Receive a control message. */

Source from the content-addressed store, hash-verified

226 * Receive a control message.
227 */
228static int
229ng_pred1_rcvmsg(node_p node, item_p item, hook_p lasthook)
230{
231 const priv_p priv = NG_NODE_PRIVATE(node);
232 struct ng_mesg *resp = NULL;
233 int error = 0;
234 struct ng_mesg *msg;
235
236 NGI_GET_MSG(item, msg);
237
238 if (msg->header.typecookie != NGM_PRED1_COOKIE)
239 ERROUT(EINVAL);
240
241 switch (msg->header.cmd) {
242 case NGM_PRED1_CONFIG:
243 {
244 struct ng_pred1_config *const cfg =
245 (struct ng_pred1_config *)msg->data;
246
247 /* Check configuration. */
248 if (msg->header.arglen != sizeof(*cfg))
249 ERROUT(EINVAL);
250
251 /* Configuration is OK, reset to it. */
252 priv->cfg = *cfg;
253
254 /* Save return address so we can send reset-req's. */
255 priv->ctrlnode = NGI_RETADDR(item);
256
257 /* Clear our state. */
258 Pred1Init(node);
259
260 break;
261 }
262 case NGM_PRED1_RESETREQ:
263 Pred1Init(node);
264 break;
265
266 case NGM_PRED1_GET_STATS:
267 case NGM_PRED1_CLR_STATS:
268 case NGM_PRED1_GETCLR_STATS:
269 {
270 /* Create response. */
271 if (msg->header.cmd != NGM_PRED1_CLR_STATS) {
272 NG_MKRESPONSE(resp, msg,
273 sizeof(struct ng_pred1_stats), M_NOWAIT);
274 if (resp == NULL)
275 ERROUT(ENOMEM);
276 bcopy(&priv->stats, resp->data,
277 sizeof(struct ng_pred1_stats));
278 }
279
280 if (msg->header.cmd != NGM_PRED1_GET_STATS)
281 bzero(&priv->stats, sizeof(struct ng_pred1_stats));
282 break;
283 }
284
285 default:

Callers

nothing calls this directly

Calls 2

Pred1InitFunction · 0.85
bzeroFunction · 0.85

Tested by

no test coverage detected