98
98
static void do_setclr_trap P((struct sockaddr_storage *, struct interface *, struct req_pkt *, int));
99
99
static void set_request_keyid P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
100
100
static void set_control_keyid P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
101
static void get_ctl_stats P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
101
static void get_ctl_stats P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
102
static void get_if_stats P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
103
static void do_if_reload P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
102
104
#ifdef KERNEL_PLL
103
105
static void get_kernel_info P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
104
106
#endif /* KERNEL_PLL */
171
173
{ REQ_GET_CLKBUGINFO, NOAUTH, sizeof(u_int32), sizeof(u_int32),
172
174
get_clkbug_info },
176
{ REQ_IF_STATS, AUTH, 0, 0, get_if_stats },
177
{ REQ_IF_RELOAD, AUTH, 0, 0, do_if_reload },
174
179
{ NO_REQUEST, NOAUTH, 0, 0, 0 }
495
500
!(inpkt->implementation == IMPL_XNTPD &&
496
501
inpkt->request == REQ_CONFIG &&
497
502
temp_size == sizeof(struct old_conf_peer))) {
499
505
printf("process_private: wrong item size, received %d, should be %d or %d\n",
500
506
temp_size, proc->sizeofitem, proc->v6_sizeofitem);
501
508
req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
504
511
if ((proc->sizeofitem != 0) &&
505
512
((temp_size * INFO_NITEMS(inpkt->err_nitems)) >
506
513
(rbufp->recv_length - REQ_LEN_HDR))) {
508
516
printf("process_private: not enough data\n");
509
518
req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
738
750
if (client_v6_capable)
739
751
ips->v6_flag = 0;
740
752
/* XXX PDM This code is buggy. Need to replace with a straightforward assignment */
741
ips->dstadr = (pp->processed) ?
742
pp->cast_flags == MDF_BCAST ?
743
GET_INADDR(pp->dstadr->bcast):
745
GET_INADDR(pp->dstadr->sin) ?
746
GET_INADDR(pp->dstadr->sin):
747
GET_INADDR(pp->dstadr->bcast):
748
1 : GET_INADDR(pp->dstadr->sin);
755
ips->dstadr = (pp->processed) ?
756
pp->cast_flags == MDF_BCAST ?
757
GET_INADDR(pp->dstadr->bcast):
759
GET_INADDR(pp->dstadr->sin) ?
760
GET_INADDR(pp->dstadr->sin):
761
GET_INADDR(pp->dstadr->bcast):
762
1 : GET_INADDR(pp->dstadr->sin);
764
memset(&ips->dstadr, 0, sizeof(ips->dstadr));
753
770
ips->srcport = NSRCPORT(&pp->srcadr);
754
771
ips->stratum = pp->stratum;
828
845
if ((pp = findexistingpeer(&addr, (struct peer *)0, -1)) == 0)
830
847
if (pp->srcadr.ss_family == AF_INET6) {
831
ip->dstadr6 = pp->cast_flags == MDF_BCAST ?
832
GET_INADDR6(pp->dstadr->bcast) :
833
GET_INADDR6(pp->dstadr->sin);
849
ip->dstadr6 = pp->cast_flags == MDF_BCAST ?
850
GET_INADDR6(pp->dstadr->bcast) :
851
GET_INADDR6(pp->dstadr->sin);
853
memset(&ip->dstadr6, 0, sizeof(ip->dstadr6));
834
855
ip->srcadr6 = GET_INADDR6(pp->srcadr);
837
858
/* XXX PDM This code is buggy. Need to replace with a straightforward assignment */
838
ip->dstadr = (pp->processed) ?
839
pp->cast_flags == MDF_BCAST ?
840
GET_INADDR(pp->dstadr->bcast):
842
GET_INADDR(pp->dstadr->sin) ?
843
GET_INADDR(pp->dstadr->sin):
844
GET_INADDR(pp->dstadr->bcast):
845
2 : GET_INADDR(pp->dstadr->sin);
860
ip->dstadr = (pp->processed) ?
861
pp->cast_flags == MDF_BCAST ?
862
GET_INADDR(pp->dstadr->bcast):
864
GET_INADDR(pp->dstadr->sin) ?
865
GET_INADDR(pp->dstadr->sin):
866
GET_INADDR(pp->dstadr->bcast):
867
2 : GET_INADDR(pp->dstadr->sin);
869
memset(&ip->dstadr, 0, sizeof(ip->dstadr));
847
871
ip->srcadr = GET_INADDR(pp->srcadr);
848
872
if (client_v6_capable)
928
952
struct sockaddr_storage addr;
929
953
extern struct peer *sys_peer;
931
printf("peer_stats: called\n");
957
printf("peer_stats: called\n");
932
959
items = INFO_NITEMS(inpkt->err_nitems);
933
960
ipl = (struct info_peer_list *) inpkt->data;
934
961
ip = (struct info_peer_stats *)prepare_pkt(srcadr, inter, inpkt,
946
973
#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
947
974
addr.ss_len = SOCKLEN(&addr);
949
printf("peer_stats: looking for %s, %d, %d\n", stoa(&addr),
978
printf("peer_stats: looking for %s, %d, %d\n", stoa(&addr),
950
979
ipl->port, ((struct sockaddr_in6 *)&addr)->sin6_port);
951
981
ipl = (struct info_peer_list *)((char *)ipl +
952
982
INFO_ITEMSIZE(inpkt->mbz_itemsize));
954
984
if ((pp = findexistingpeer(&addr, (struct peer *)0, -1)) == 0)
956
printf("peer_stats: found %s\n", stoa(&addr));
988
printf("peer_stats: found %s\n", stoa(&addr));
957
990
if (pp->srcadr.ss_family == AF_INET) {
958
ip->dstadr = (pp->processed) ?
959
pp->cast_flags == MDF_BCAST ?
960
GET_INADDR(pp->dstadr->bcast):
962
GET_INADDR(pp->dstadr->sin) ?
963
GET_INADDR(pp->dstadr->sin):
964
GET_INADDR(pp->dstadr->bcast):
992
ip->dstadr = (pp->processed) ?
993
pp->cast_flags == MDF_BCAST ?
994
GET_INADDR(pp->dstadr->bcast):
996
GET_INADDR(pp->dstadr->sin) ?
997
GET_INADDR(pp->dstadr->sin):
998
GET_INADDR(pp->dstadr->bcast):
1001
memset(&ip->dstadr, 0, sizeof(ip->dstadr));
966
1003
ip->srcadr = GET_INADDR(pp->srcadr);
967
1004
if (client_v6_capable)
968
1005
ip->v6_flag = 0;
970
ip->dstadr6 = pp->cast_flags == MDF_BCAST ?
971
GET_INADDR6(pp->dstadr->bcast):
972
GET_INADDR6(pp->dstadr->sin);
1008
ip->dstadr6 = pp->cast_flags == MDF_BCAST ?
1009
GET_INADDR6(pp->dstadr->bcast):
1010
GET_INADDR6(pp->dstadr->sin);
1012
memset(&ip->dstadr6, 0, sizeof(ip->dstadr6));
973
1014
ip->srcadr6 = GET_INADDR6(pp->srcadr);
974
1015
ip->v6_flag = 1;
987
1028
ip->flags |= INFO_FLAG_PREFER;
988
1029
if (pp->flags & FLAG_BURST)
989
1030
ip->flags |= INFO_FLAG_BURST;
1031
if (pp->flags & FLAG_IBURST)
1032
ip->flags |= INFO_FLAG_IBURST;
990
1033
if (pp->status == CTL_PST_SEL_SYNCCAND)
991
1034
ip->flags |= INFO_FLAG_SEL_CANDIDATE;
992
1035
if (pp->status >= CTL_PST_SEL_SYSPEER)
993
1036
ip->flags |= INFO_FLAG_SHORTLIST;
1037
ip->flags = htons(ip->flags);
994
1038
ip->timereceived = htonl((u_int32)(current_time - pp->timereceived));
995
1039
ip->timetosend = htonl(pp->nextdate - current_time);
996
1040
ip->timereachable = htonl((u_int32)(current_time - pp->timereachable));
1021
1065
register struct info_sys *is;
1024
* Importations from the protocol module
1026
extern u_char sys_leap;
1027
extern u_char sys_stratum;
1028
extern s_char sys_precision;
1029
extern double sys_rootdelay;
1030
extern double sys_rootdispersion;
1031
extern u_int32 sys_refid;
1032
extern l_fp sys_reftime;
1033
extern u_char sys_poll;
1034
extern struct peer *sys_peer;
1035
extern int sys_bclient;
1036
extern double sys_bdelay;
1037
extern l_fp sys_authdelay;
1038
extern double clock_stability;
1039
extern double sys_jitter;
1041
1067
is = (struct info_sys *)prepare_pkt(srcadr, inter, inpkt,
1042
1068
v6sizeof(struct info_sys));
1345
1371
if (temp_cp.flags & CONF_FLAG_AUTHENABLE)
1346
fl |= FLAG_AUTHENABLE;
1372
fl |= FLAG_AUTHENABLE;
1347
1373
if (temp_cp.flags & CONF_FLAG_PREFER)
1349
1375
if (temp_cp.flags & CONF_FLAG_BURST)
1350
1376
fl |= FLAG_BURST;
1377
if (temp_cp.flags & CONF_FLAG_IBURST)
1351
1379
if (temp_cp.flags & CONF_FLAG_SKEY)
1352
1380
fl |= FLAG_SKEY;
1381
if (temp_cp.flags & CONF_FLAG_DYNAMIC)
1353
1384
if (client_v6_capable && temp_cp.v6_flag != 0) {
1354
1385
peeraddr.ss_family = AF_INET6;
1355
1386
GET_INADDR6(peeraddr) = temp_cp.peeraddr6;
1658
1695
if (flags & SYS_FLAG_CAL)
1659
1696
proto_config(PROTO_CAL, set, 0., NULL);
1660
1697
req_ack(srcadr, inter, inpkt, INFO_OKAY);
1699
/* Reset the kernel ntp parameters if the kernel flag changed. */
1700
if (prev_kern_enable && !kern_enable)
1701
loop_config(LOOP_KERN_CLEAR, 0.0);
1702
if (!prev_kern_enable && kern_enable)
1703
loop_config(LOOP_DRIFTCOMP, drift_comp);
2805
* receiver of interface structures
2808
fill_info_if_stats(void *data, interface_info_t *interface_info)
2810
struct info_if_stats **ifsp = (struct info_if_stats **)data;
2811
struct info_if_stats *ifs = *ifsp;
2812
struct interface *interface = interface_info->interface;
2814
memset((char*)ifs, 0, sizeof(*ifs));
2816
if (interface->sin.ss_family == AF_INET6) {
2817
if (!client_v6_capable) {
2821
memcpy((char *)&ifs->unaddr.addr6, (char *)&CAST_V6(interface->sin)->sin6_addr, sizeof(struct in6_addr));
2822
memcpy((char *)&ifs->unbcast.addr6, (char *)&CAST_V6(interface->bcast)->sin6_addr, sizeof(struct in6_addr));
2823
memcpy((char *)&ifs->unmask.addr6, (char *)&CAST_V6(interface->mask)->sin6_addr, sizeof(struct in6_addr));
2826
memcpy((char *)&ifs->unaddr.addr, (char *)&CAST_V4(interface->sin)->sin_addr, sizeof(struct in_addr));
2827
memcpy((char *)&ifs->unbcast.addr, (char *)&CAST_V4(interface->bcast)->sin_addr, sizeof(struct in_addr));
2828
memcpy((char *)&ifs->unmask.addr, (char *)&CAST_V4(interface->mask)->sin_addr, sizeof(struct in_addr));
2830
ifs->v6_flag = htonl(ifs->v6_flag);
2831
strcpy(ifs->name, interface->name);
2832
ifs->family = htons(interface->family);
2833
ifs->flags = htonl(interface->flags);
2834
ifs->last_ttl = htonl(interface->last_ttl);
2835
ifs->num_mcast = htonl(interface->num_mcast);
2836
ifs->received = htonl(interface->received);
2837
ifs->sent = htonl(interface->sent);
2838
ifs->notsent = htonl(interface->notsent);
2839
ifs->scopeid = htonl(interface->scopeid);
2840
ifs->ifindex = htonl(interface->ifindex);
2841
ifs->ifnum = htonl(interface->ifnum);
2842
ifs->uptime = htonl(current_time - interface->starttime);
2843
ifs->ignore_packets = interface->ignore_packets;
2844
ifs->peercnt = htonl(interface->peercnt);
2845
ifs->action = interface_info->action;
2847
*ifsp = (struct info_if_stats *)more_pkt();
2851
* get_if_stats - get interface statistics
2855
struct sockaddr_storage *srcadr,
2856
struct interface *inter,
2857
struct req_pkt *inpkt
2860
struct info_if_stats *ifs;
2862
DPRINTF(3, ("wants interface statistics\n"));
2864
ifs = (struct info_if_stats *)prepare_pkt(srcadr, inter, inpkt,
2865
v6sizeof(struct info_if_stats));
2867
interface_enumerate(fill_info_if_stats, &ifs);
2874
struct sockaddr_storage *srcadr,
2875
struct interface *inter,
2876
struct req_pkt *inpkt
2879
struct info_if_stats *ifs;
2881
DPRINTF(3, ("wants interface reload\n"));
2883
ifs = (struct info_if_stats *)prepare_pkt(srcadr, inter, inpkt,
2884
v6sizeof(struct info_if_stats));
2886
interface_update(fill_info_if_stats, &ifs);