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

Function pf_send_tcp

freebsd/netpfil/pf/pf.c:2442–2600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2440}
2441
2442static void
2443pf_send_tcp(struct mbuf *replyto, const struct pf_krule *r, sa_family_t af,
2444 const struct pf_addr *saddr, const struct pf_addr *daddr,
2445 u_int16_t sport, u_int16_t dport, u_int32_t seq, u_int32_t ack,
2446 u_int8_t flags, u_int16_t win, u_int16_t mss, u_int8_t ttl, int tag,
2447 u_int16_t rtag, struct ifnet *ifp)
2448{
2449 struct pf_send_entry *pfse;
2450 struct mbuf *m;
2451 int len, tlen;
2452#ifdef INET
2453 struct ip *h = NULL;
2454#endif /* INET */
2455#ifdef INET6
2456 struct ip6_hdr *h6 = NULL;
2457#endif /* INET6 */
2458 struct tcphdr *th;
2459 char *opt;
2460 struct pf_mtag *pf_mtag;
2461
2462 len = 0;
2463 th = NULL;
2464
2465 /* maximum segment size tcp option */
2466 tlen = sizeof(struct tcphdr);
2467 if (mss)
2468 tlen += 4;
2469
2470 switch (af) {
2471#ifdef INET
2472 case AF_INET:
2473 len = sizeof(struct ip) + tlen;
2474 break;
2475#endif /* INET */
2476#ifdef INET6
2477 case AF_INET6:
2478 len = sizeof(struct ip6_hdr) + tlen;
2479 break;
2480#endif /* INET6 */
2481 default:
2482 panic("%s: unsupported af %d", __func__, af);
2483 }
2484
2485 /* Allocate outgoing queue entry, mbuf and mbuf tag. */
2486 pfse = malloc(sizeof(*pfse), M_PFTEMP, M_NOWAIT);
2487 if (pfse == NULL)
2488 return;
2489 m = m_gethdr(M_NOWAIT, MT_DATA);
2490 if (m == NULL) {
2491 free(pfse, M_PFTEMP);
2492 return;
2493 }
2494#ifdef MAC
2495 mac_netinet_firewall_send(m);
2496#endif
2497 if ((pf_mtag = pf_get_mtag(m)) == NULL) {
2498 free(pfse, M_PFTEMP);
2499 m_freem(m);

Callers 5

pf_unlink_stateFunction · 0.85
pf_returnFunction · 0.85
pf_create_stateFunction · 0.85
pf_tcp_track_fullFunction · 0.85
pf_test_state_tcpFunction · 0.85

Calls 12

mallocFunction · 0.85
pf_get_mtagFunction · 0.85
bzeroFunction · 0.85
in_cksumFunction · 0.85
in6_cksumFunction · 0.85
pf_sendFunction · 0.85
panicFunction · 0.50
m_gethdrFunction · 0.50
freeFunction · 0.50
m_freemFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected