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

Function tcp_ipsec_input

freebsd/netipsec/xform_tcp.c:256–286  ·  view source on GitHub ↗

* Compute TCP-MD5 hash of an *INBOUND* TCP segment. * Parameters: * m pointer to head of mbuf chain * th pointer to TCP header * buf pointer to storage for computed MD5 digest * * Return 0 if successful, otherwise return -1. */

Source from the content-addressed store, hash-verified

254 * Return 0 if successful, otherwise return -1.
255 */
256static int
257tcp_ipsec_input(struct mbuf *m, struct tcphdr *th, u_char *buf)
258{
259 char tmpdigest[TCP_SIGLEN];
260 struct secasindex saidx;
261 struct secasvar *sav;
262
263 setsockaddrs(m, &saidx.src, &saidx.dst);
264 saidx.proto = IPPROTO_TCP;
265 saidx.mode = IPSEC_MODE_TCPMD5;
266 saidx.reqid = 0;
267 sav = key_allocsa_tcpmd5(&saidx);
268 if (sav == NULL) {
269 KMOD_TCPSTAT_INC(tcps_sig_err_buildsig);
270 return (EACCES);
271 }
272 /*
273 * tcp_input() operates with TCP header fields in host
274 * byte order. We expect them in network byte order.
275 */
276 tcp_fields_to_net(th);
277 tcp_signature_compute(m, th, sav, tmpdigest);
278 tcp_fields_to_host(th);
279 key_freesav(&sav);
280 if (bcmp(buf, tmpdigest, TCP_SIGLEN) != 0) {
281 KMOD_TCPSTAT_INC(tcps_sig_rcvbadsig);
282 return (EACCES);
283 }
284 KMOD_TCPSTAT_INC(tcps_sig_rcvgoodsig);
285 return (0);
286}
287
288/*
289 * Compute TCP-MD5 hash of an *OUTBOUND* TCP segment.

Callers

nothing calls this directly

Calls 6

setsockaddrsFunction · 0.85
key_allocsa_tcpmd5Function · 0.85
tcp_signature_computeFunction · 0.85
key_freesavFunction · 0.85
tcp_fields_to_netFunction · 0.50
tcp_fields_to_hostFunction · 0.50

Tested by

no test coverage detected