Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet6/ip6_input.c
| Show First 20 Lines • Show All 1,191 Lines • ▼ Show 20 Lines | |||||||||
| * options and handle the v6-only ones itself. | * options and handle the v6-only ones itself. | ||||||||
| */ | */ | ||||||||
| struct mbuf ** | struct mbuf ** | ||||||||
| ip6_savecontrol_v4(struct inpcb *inp, struct mbuf *m, struct mbuf **mp, | ip6_savecontrol_v4(struct inpcb *inp, struct mbuf *m, struct mbuf **mp, | ||||||||
| int *v4only) | int *v4only) | ||||||||
| { | { | ||||||||
| struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); | struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); | ||||||||
| #ifdef SO_TIMESTAMP | #if defined(SO_TIMESTAMP) && defined(SO_BINTIME) | ||||||||
| if ((inp->inp_socket->so_options & SO_TIMESTAMP) != 0) { | if ((inp->inp_socket->so_options & (SO_TIMESTAMP | SO_BINTIME)) != 0) { | ||||||||
markjUnsubmitted Done Inline Actions
markj: | |||||||||
| union { | union { | ||||||||
| struct timeval tv; | struct timeval tv; | ||||||||
| struct bintime bt; | struct bintime bt; | ||||||||
| struct timespec ts; | struct timespec ts; | ||||||||
| } t; | } t; | ||||||||
| struct bintime boottimebin, bt1; | struct bintime boottimebin, bt1; | ||||||||
| struct timespec ts1; | struct timespec ts1; | ||||||||
| int ts_clock; | |||||||||
| bool stamped; | bool stamped; | ||||||||
| ts_clock = inp->inp_socket->so_ts_clock; | |||||||||
| stamped = false; | stamped = false; | ||||||||
| switch (inp->inp_socket->so_ts_clock) { | |||||||||
| case SO_TS_REALTIME_MICRO: | /* | ||||||||
| * Handle BINTIME first. We create the same output options | |||||||||
| * for both SO_BINTIME and the case where SO_TIMESTAMP is | |||||||||
| * set with the timestamp clock set to SO_TS_BINTIME. | |||||||||
| */ | |||||||||
| if ((inp->inp_socket->so_options & SO_BINTIME) != 0 || | |||||||||
| ts_clock == SO_TS_BINTIME) { | |||||||||
| if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | | if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | | ||||||||
Done Inline ActionsFWIW, this diff looks messier than it should. This block was just moved from the case SO_TS_BINTIME block below. jtl: FWIW, this diff looks messier than it should. This block was just moved from the `case… | |||||||||
| M_TSTMP)) { | M_TSTMP)) { | ||||||||
| mbuf_tstmp2timespec(m, &ts1); | mbuf_tstmp2timespec(m, &ts1); | ||||||||
| timespec2bintime(&ts1, &bt1); | timespec2bintime(&ts1, &t.bt); | ||||||||
| getboottimebin(&boottimebin); | getboottimebin(&boottimebin); | ||||||||
| bintime_add(&bt1, &boottimebin); | bintime_add(&t.bt, &boottimebin); | ||||||||
| bintime2timeval(&bt1, &t.tv); | |||||||||
| } else { | } else { | ||||||||
| microtime(&t.tv); | bintime(&t.bt); | ||||||||
| } | } | ||||||||
| *mp = sbcreatecontrol(&t.tv, sizeof(t.tv), | *mp = sbcreatecontrol(&t.bt, sizeof(t.bt), SCM_BINTIME, | ||||||||
| SCM_TIMESTAMP, SOL_SOCKET, M_NOWAIT); | SOL_SOCKET, M_NOWAIT); | ||||||||
| if (*mp != NULL) { | if (*mp != NULL) { | ||||||||
| mp = &(*mp)->m_next; | mp = &(*mp)->m_next; | ||||||||
| stamped = true; | stamped = true; | ||||||||
| } | } | ||||||||
| break; | |||||||||
| case SO_TS_BINTIME: | /* | ||||||||
| * Suppress other timestamps if SO_TIMESTAMP is not | |||||||||
| * set. | |||||||||
| */ | |||||||||
| if ((inp->inp_socket->so_options & SO_TIMESTAMP) == 0) | |||||||||
| ts_clock = SO_TS_BINTIME; | |||||||||
| } | |||||||||
| switch (ts_clock) { | |||||||||
| case SO_TS_REALTIME_MICRO: | |||||||||
| if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | | if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | | ||||||||
| M_TSTMP)) { | M_TSTMP)) { | ||||||||
| mbuf_tstmp2timespec(m, &ts1); | mbuf_tstmp2timespec(m, &ts1); | ||||||||
| timespec2bintime(&ts1, &t.bt); | timespec2bintime(&ts1, &bt1); | ||||||||
| getboottimebin(&boottimebin); | getboottimebin(&boottimebin); | ||||||||
| bintime_add(&t.bt, &boottimebin); | bintime_add(&bt1, &boottimebin); | ||||||||
| bintime2timeval(&bt1, &t.tv); | |||||||||
| } else { | } else { | ||||||||
| bintime(&t.bt); | microtime(&t.tv); | ||||||||
| } | } | ||||||||
| *mp = sbcreatecontrol(&t.bt, sizeof(t.bt), SCM_BINTIME, | *mp = sbcreatecontrol(&t.tv, sizeof(t.tv), | ||||||||
| SOL_SOCKET, M_NOWAIT); | SCM_TIMESTAMP, SOL_SOCKET, M_NOWAIT); | ||||||||
| if (*mp != NULL) { | if (*mp != NULL) { | ||||||||
| mp = &(*mp)->m_next; | mp = &(*mp)->m_next; | ||||||||
| stamped = true; | stamped = true; | ||||||||
| } | } | ||||||||
| break; | |||||||||
| case SO_TS_BINTIME: | |||||||||
| break; | break; | ||||||||
| case SO_TS_REALTIME: | case SO_TS_REALTIME: | ||||||||
| if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | | if ((m->m_flags & (M_PKTHDR | M_TSTMP)) == (M_PKTHDR | | ||||||||
| M_TSTMP)) { | M_TSTMP)) { | ||||||||
| mbuf_tstmp2timespec(m, &t.ts); | mbuf_tstmp2timespec(m, &t.ts); | ||||||||
| getboottimebin(&boottimebin); | getboottimebin(&boottimebin); | ||||||||
| bintime2timespec(&boottimebin, &ts1); | bintime2timespec(&boottimebin, &ts1); | ||||||||
| ▲ Show 20 Lines • Show All 487 Lines • Show Last 20 Lines | |||||||||