Print this page
4823 don't open-code NSEC2MSEC and MSEC2NSEC

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/ip/ip.c
          +++ new/usr/src/uts/common/inet/ip/ip.c
↓ open down ↓ 1490 lines elided ↑ open up ↑
1491 1491                          mp = mp1;
1492 1492                          ipha = (ipha_t *)mp->b_rptr;
1493 1493                          icmph = (icmph_t *)&mp->b_rptr[ip_hdr_length];
1494 1494                  }
1495 1495                  icmph->icmph_type = ICMP_TIME_STAMP_REPLY;
1496 1496                  tsp = (uint32_t *)&icmph[1];
1497 1497                  tsp++;          /* Skip past 'originate time' */
1498 1498                  /* Compute # of milliseconds since midnight */
1499 1499                  gethrestime(&now);
1500 1500                  ts = (now.tv_sec % (24 * 60 * 60)) * 1000 +
1501      -                    now.tv_nsec / (NANOSEC / MILLISEC);
     1501 +                    NSEC2MSEC(now.tv_nsec);
1502 1502                  *tsp++ = htonl(ts);     /* Lay in 'receive time' */
1503 1503                  *tsp++ = htonl(ts);     /* Lay in 'send time' */
1504 1504                  BUMP_MIB(&ipst->ips_icmp_mib, icmpOutTimestampReps);
1505 1505                  icmp_send_reply_v4(mp, ipha, icmph, ira);
1506 1506                  return (NULL);
1507 1507  
1508 1508          case ICMP_TIME_STAMP_REPLY:
1509 1509                  BUMP_MIB(&ipst->ips_icmp_mib, icmpInTimestampReps);
1510 1510                  break;
1511 1511          case ICMP_INFO_REQUEST:
↓ open down ↓ 7598 lines elided ↑ open up ↑
9110 9110                                          ifaddr = INADDR_ANY;
9111 9111                                  }
9112 9112                                  bcopy(&ifaddr, (char *)opt + off, IP_ADDR_LEN);
9113 9113                                  opt[IPOPT_OFFSET] += IP_ADDR_LEN;
9114 9114                                  /* FALLTHRU */
9115 9115                          case IPOPT_TS_TSONLY:
9116 9116                                  off = opt[IPOPT_OFFSET] - 1;
9117 9117                                  /* Compute # of milliseconds since midnight */
9118 9118                                  gethrestime(&now);
9119 9119                                  ts = (now.tv_sec % (24 * 60 * 60)) * 1000 +
9120      -                                    now.tv_nsec / (NANOSEC / MILLISEC);
     9120 +                                    NSEC2MSEC(now.tv_nsec);
9121 9121                                  bcopy(&ts, (char *)opt + off, IPOPT_TS_TIMELEN);
9122 9122                                  opt[IPOPT_OFFSET] += IPOPT_TS_TIMELEN;
9123 9123                                  break;
9124 9124                          }
9125 9125                          break;
9126 9126                  }
9127 9127          }
9128 9128          return (B_TRUE);
9129 9129  }
9130 9130  
↓ open down ↓ 205 lines elided ↑ open up ↑
9336 9336                                          ifaddr = INADDR_ANY;
9337 9337                                  }
9338 9338                                  bcopy(&ifaddr, (char *)opt + off, IP_ADDR_LEN);
9339 9339                                  opt[IPOPT_OFFSET] += IP_ADDR_LEN;
9340 9340                                  /* FALLTHRU */
9341 9341                          case IPOPT_TS_TSONLY:
9342 9342                                  off = opt[IPOPT_OFFSET] - 1;
9343 9343                                  /* Compute # of milliseconds since midnight */
9344 9344                                  gethrestime(&now);
9345 9345                                  ts = (now.tv_sec % (24 * 60 * 60)) * 1000 +
9346      -                                    now.tv_nsec / (NANOSEC / MILLISEC);
     9346 +                                    NSEC2MSEC(now.tv_nsec);
9347 9347                                  bcopy(&ts, (char *)opt + off, IPOPT_TS_TIMELEN);
9348 9348                                  opt[IPOPT_OFFSET] += IPOPT_TS_TIMELEN;
9349 9349                                  break;
9350 9350                          }
9351 9351                          break;
9352 9352                  }
9353 9353          }
9354 9354          return (B_TRUE);
9355 9355  
9356 9356  bad_src_route:
↓ open down ↓ 2661 lines elided ↑ open up ↑
12018 12018                          case IPOPT_TS_TSANDADDR:
12019 12019                                  dst = htonl(INADDR_LOOPBACK);
12020 12020                                  bcopy(&dst, (char *)opt + off, IP_ADDR_LEN);
12021 12021                                  opt[IPOPT_OFFSET] += IP_ADDR_LEN;
12022 12022                                  /* FALLTHRU */
12023 12023                          case IPOPT_TS_TSONLY:
12024 12024                                  off = opt[IPOPT_OFFSET] - 1;
12025 12025                                  /* Compute # of milliseconds since midnight */
12026 12026                                  gethrestime(&now);
12027 12027                                  ts = (now.tv_sec % (24 * 60 * 60)) * 1000 +
12028      -                                    now.tv_nsec / (NANOSEC / MILLISEC);
     12028 +                                    NSEC2MSEC(now.tv_nsec);
12029 12029                                  bcopy(&ts, (char *)opt + off, IPOPT_TS_TIMELEN);
12030 12030                                  opt[IPOPT_OFFSET] += IPOPT_TS_TIMELEN;
12031 12031                                  break;
12032 12032                          }
12033 12033                          break;
12034 12034                  }
12035 12035          }
12036 12036  }
12037 12037  
12038 12038  /*
↓ open down ↓ 3234 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX