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

Function ng_source_mod_counter

freebsd/netgraph/ng_source.c:839–865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

837}
838
839static void
840ng_source_mod_counter(sc_p sc, struct ng_source_embed_cnt_info *cnt,
841 struct mbuf *m, int increment)
842{
843 caddr_t cp;
844 uint32_t val;
845
846 val = htonl(cnt->next_val);
847 cp = (caddr_t)&val + sizeof(val) - cnt->width;
848 ng_source_packet_mod(sc, m, cnt->offset, cnt->width, cp, cnt->flags);
849
850 if (increment) {
851 cnt->next_val += increment;
852
853 if (increment > 0 && cnt->next_val > cnt->max_val) {
854 cnt->next_val = cnt->min_val - 1 +
855 (cnt->next_val - cnt->max_val);
856 if (cnt->next_val > cnt->max_val)
857 cnt->next_val = cnt->max_val;
858 } else if (increment < 0 && cnt->next_val < cnt->min_val) {
859 cnt->next_val = cnt->max_val + 1 +
860 (cnt->next_val - cnt->min_val);
861 if (cnt->next_val < cnt->min_val)
862 cnt->next_val = cnt->max_val;
863 }
864 }
865}
866
867static int
868ng_source_dup_mod(sc_p sc, struct mbuf *m0, struct mbuf **m_ptr)

Callers 1

ng_source_dup_modFunction · 0.85

Calls 1

ng_source_packet_modFunction · 0.85

Tested by

no test coverage detected