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

Function pf_send_icmp

freebsd/netpfil/pf/pf.c:2715–2767  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2713}
2714
2715static void
2716pf_send_icmp(struct mbuf *m, u_int8_t type, u_int8_t code, sa_family_t af,
2717 struct pf_krule *r)
2718{
2719 struct pf_send_entry *pfse;
2720 struct mbuf *m0;
2721 struct pf_mtag *pf_mtag;
2722
2723 /* Allocate outgoing queue entry, mbuf and mbuf tag. */
2724 pfse = malloc(sizeof(*pfse), M_PFTEMP, M_NOWAIT);
2725 if (pfse == NULL)
2726 return;
2727
2728 if ((m0 = m_copypacket(m, M_NOWAIT)) == NULL) {
2729 free(pfse, M_PFTEMP);
2730 return;
2731 }
2732
2733 if ((pf_mtag = pf_get_mtag(m0)) == NULL) {
2734 free(pfse, M_PFTEMP);
2735 return;
2736 }
2737 /* XXX: revisit */
2738 m0->m_flags |= M_SKIP_FIREWALL;
2739
2740 if (r->rtableid >= 0)
2741 M_SETFIB(m0, r->rtableid);
2742
2743#ifdef ALTQ
2744 if (r->qid) {
2745 pf_mtag->qid = r->qid;
2746 /* add hints for ecn */
2747 pf_mtag->hdr = mtod(m0, struct ip *);
2748 }
2749#endif /* ALTQ */
2750
2751 switch (af) {
2752#ifdef INET
2753 case AF_INET:
2754 pfse->pfse_type = PFSE_ICMP;
2755 break;
2756#endif /* INET */
2757#ifdef INET6
2758 case AF_INET6:
2759 pfse->pfse_type = PFSE_ICMP6;
2760 break;
2761#endif /* INET6 */
2762 }
2763 pfse->pfse_m = m0;
2764 pfse->icmpopts.type = type;
2765 pfse->icmpopts.code = code;
2766 pf_send(pfse);
2767}
2768
2769/*
2770 * Return 1 if the addresses a and b match (with mask m), otherwise return 0.

Callers 1

pf_returnFunction · 0.85

Calls 5

mallocFunction · 0.85
m_copypacketFunction · 0.85
pf_get_mtagFunction · 0.85
pf_sendFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected