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

Function in_gre_attach

freebsd/netinet/ip_gre.c:363–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361}
362
363static int
364in_gre_attach(struct gre_softc *sc)
365{
366 struct grehdr *gh;
367 int error;
368
369 if (sc->gre_options & GRE_UDPENCAP) {
370 sc->gre_csumflags = CSUM_UDP;
371 sc->gre_hlen = sizeof(struct greudp);
372 sc->gre_oip.ip_p = IPPROTO_UDP;
373 gh = &sc->gre_udphdr->gi_gre;
374 gre_update_udphdr(sc, &sc->gre_udp,
375 in_pseudo(sc->gre_oip.ip_src.s_addr,
376 sc->gre_oip.ip_dst.s_addr, 0));
377 } else {
378 sc->gre_hlen = sizeof(struct greip);
379 sc->gre_oip.ip_p = IPPROTO_GRE;
380 gh = &sc->gre_iphdr->gi_gre;
381 }
382 sc->gre_oip.ip_v = IPVERSION;
383 sc->gre_oip.ip_hl = sizeof(struct ip) >> 2;
384 gre_update_hdr(sc, gh);
385
386 /*
387 * If we return error, this means that sc is not linked,
388 * and caller should reset gre_family and free(sc->gre_hdr).
389 */
390 if (sc->gre_options & GRE_UDPENCAP) {
391 error = in_gre_setup_socket(sc);
392 if (error != 0)
393 return (error);
394 } else
395 CK_LIST_INSERT_HEAD(&GRE_HASH_SC(sc), sc, chain);
396 CK_LIST_INSERT_HEAD(&GRE_SRCHASH(sc->gre_oip.ip_src.s_addr),
397 sc, srchash);
398
399 /* Set IFF_DRV_RUNNING if interface is ready */
400 in_gre_set_running(sc);
401 return (0);
402}
403
404int
405in_gre_setopts(struct gre_softc *sc, u_long cmd, uint32_t value)

Callers 2

in_gre_setoptsFunction · 0.85
in_gre_ioctlFunction · 0.85

Calls 5

gre_update_udphdrFunction · 0.85
gre_update_hdrFunction · 0.85
in_gre_setup_socketFunction · 0.85
in_gre_set_runningFunction · 0.85
in_pseudoFunction · 0.50

Tested by

no test coverage detected