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

Function ng_vjc_rcvdata

freebsd/netgraph/ng_vjc.c:397–537  ·  view source on GitHub ↗

* Receive data */

Source from the content-addressed store, hash-verified

395 * Receive data
396 */
397static int
398ng_vjc_rcvdata(hook_p hook, item_p item)
399{
400 const node_p node = NG_HOOK_NODE(hook);
401 const priv_p priv = NG_NODE_PRIVATE(node);
402 int error = 0;
403 struct mbuf *m;
404
405 NGI_GET_M(item, m);
406 if (hook == priv->ip) { /* outgoing packet */
407 u_int type = TYPE_IP;
408
409 /* Compress packet if enabled and proto is TCP */
410 if (priv->conf.enableComp) {
411 struct ip *ip;
412
413 if ((m = ng_vjc_pulluphdrs(m, 0)) == NULL) {
414 NG_FREE_ITEM(item);
415 return (ENOBUFS);
416 }
417 ip = mtod(m, struct ip *);
418 if (ip->ip_p == IPPROTO_TCP) {
419 const int origLen = m->m_len;
420
421 type = sl_compress_tcp(m, ip,
422 &priv->slc, priv->conf.compressCID);
423 m->m_pkthdr.len += m->m_len - origLen;
424 }
425 }
426
427 /* Dispatch to the appropriate outgoing hook */
428 switch (type) {
429 case TYPE_IP:
430 hook = priv->vjip;
431 break;
432 case TYPE_UNCOMPRESSED_TCP:
433 hook = priv->vjuncomp;
434 break;
435 case TYPE_COMPRESSED_TCP:
436 hook = priv->vjcomp;
437 break;
438 default:
439 panic("%s: type=%d", __func__, type);
440 }
441 } else if (hook == priv->vjcomp) { /* incoming compressed packet */
442 int vjlen, need2pullup;
443 struct mbuf *hm;
444 u_char *hdr;
445 u_int hlen;
446
447 /* Are we decompressing? */
448 if (!priv->conf.enableDecomp) {
449 NG_FREE_M(m);
450 NG_FREE_ITEM(item);
451 return (ENXIO);
452 }
453
454 /* Pull up the necessary amount from the mbuf */

Callers

nothing calls this directly

Calls 7

ng_vjc_pulluphdrsFunction · 0.85
sl_compress_tcpFunction · 0.85
m_pullupFunction · 0.85
sl_uncompress_tcp_coreFunction · 0.85
m_adjFunction · 0.85
panicFunction · 0.50
m_freemFunction · 0.50

Tested by

no test coverage detected