Lines 119-129
static void init(void);
Link Here
|
119 |
/* For router advertisement */ |
119 |
/* For router advertisement */ |
120 |
struct icmp_ra |
120 |
struct icmp_ra |
121 |
{ |
121 |
{ |
122 |
u_char icmp_type; /* type of message, see below */ |
122 |
unsigned char icmp_type; /* type of message, see below */ |
123 |
u_char icmp_code; /* type sub code */ |
123 |
unsigned char icmp_code; /* type sub code */ |
124 |
u_short icmp_cksum; /* ones complement cksum of struct */ |
124 |
unsigned short icmp_cksum; /* ones complement cksum of struct */ |
125 |
u_char icmp_num_addrs; |
125 |
unsigned char icmp_num_addrs; |
126 |
u_char icmp_wpa; /* Words per address */ |
126 |
unsigned char icmp_wpa; /* Words per address */ |
127 |
short icmp_lifetime; |
127 |
short icmp_lifetime; |
128 |
}; |
128 |
}; |
129 |
|
129 |
|
Lines 208-214
static void graceful_finish(void);
Link Here
|
208 |
static void finish(void); |
208 |
static void finish(void); |
209 |
static void timer(void); |
209 |
static void timer(void); |
210 |
static void initifs(void); |
210 |
static void initifs(void); |
211 |
static u_short in_cksum(u_short *addr, int len); |
211 |
static unsigned short in_cksum(unsigned short *addr, int len); |
212 |
|
212 |
|
213 |
static int logging = 0; |
213 |
static int logging = 0; |
214 |
|
214 |
|
Lines 460-466
next:
Link Here
|
460 |
timer(); /* start things going */ |
460 |
timer(); /* start things going */ |
461 |
|
461 |
|
462 |
for (;;) { |
462 |
for (;;) { |
463 |
u_char packet[MAXPACKET]; |
463 |
unsigned char packet[MAXPACKET]; |
464 |
int len = sizeof (packet); |
464 |
int len = sizeof (packet); |
465 |
socklen_t fromlen = sizeof (from); |
465 |
socklen_t fromlen = sizeof (from); |
466 |
int cc; |
466 |
int cc; |
Lines 540-546
void timer()
Link Here
|
540 |
void |
540 |
void |
541 |
solicitor(struct sockaddr_in *sin) |
541 |
solicitor(struct sockaddr_in *sin) |
542 |
{ |
542 |
{ |
543 |
static u_char outpack[MAXPACKET]; |
543 |
static unsigned char outpack[MAXPACKET]; |
544 |
struct icmphdr *icp = (struct icmphdr *) ALLIGN(outpack); |
544 |
struct icmphdr *icp = (struct icmphdr *) ALLIGN(outpack); |
545 |
int packetlen, i; |
545 |
int packetlen, i; |
546 |
|
546 |
|
Lines 555-561
solicitor(struct sockaddr_in *sin)
Link Here
|
555 |
packetlen = 8; |
555 |
packetlen = 8; |
556 |
|
556 |
|
557 |
/* Compute ICMP checksum here */ |
557 |
/* Compute ICMP checksum here */ |
558 |
icp->checksum = in_cksum( (u_short *)icp, packetlen ); |
558 |
icp->checksum = in_cksum( (unsigned short *)icp, packetlen ); |
559 |
|
559 |
|
560 |
if (isbroadcast(sin)) |
560 |
if (isbroadcast(sin)) |
561 |
i = sendbcast(s, (char *)outpack, packetlen); |
561 |
i = sendbcast(s, (char *)outpack, packetlen); |
Lines 584-590
solicitor(struct sockaddr_in *sin)
Link Here
|
584 |
void |
584 |
void |
585 |
advertise(struct sockaddr_in *sin, int lft) |
585 |
advertise(struct sockaddr_in *sin, int lft) |
586 |
{ |
586 |
{ |
587 |
static u_char outpack[MAXPACKET]; |
587 |
static unsigned char outpack[MAXPACKET]; |
588 |
struct icmp_ra *rap = (struct icmp_ra *) ALLIGN(outpack); |
588 |
struct icmp_ra *rap = (struct icmp_ra *) ALLIGN(outpack); |
589 |
struct icmp_ra_addr *ap; |
589 |
struct icmp_ra_addr *ap; |
590 |
int packetlen, i, cc; |
590 |
int packetlen, i, cc; |
Lines 615-621
advertise(struct sockaddr_in *sin, int lft)
Link Here
|
615 |
rap->icmp_num_addrs++; |
615 |
rap->icmp_num_addrs++; |
616 |
|
616 |
|
617 |
/* Compute ICMP checksum here */ |
617 |
/* Compute ICMP checksum here */ |
618 |
rap->icmp_cksum = in_cksum( (u_short *)rap, packetlen ); |
618 |
rap->icmp_cksum = in_cksum( (unsigned short *)rap, packetlen ); |
619 |
|
619 |
|
620 |
if (isbroadcast(sin)) |
620 |
if (isbroadcast(sin)) |
621 |
cc = sendbcastif(s, (char *)outpack, packetlen, |
621 |
cc = sendbcastif(s, (char *)outpack, packetlen, |
Lines 749-755
pr_pack(char *buf, int cc, struct sockaddr_in *from)
Link Here
|
749 |
|
749 |
|
750 |
/* TBD verify that the link is multicast or broadcast */ |
750 |
/* TBD verify that the link is multicast or broadcast */ |
751 |
/* XXX Find out the link it came in over? */ |
751 |
/* XXX Find out the link it came in over? */ |
752 |
if (in_cksum((u_short *)ALLIGN(buf+hlen), cc)) { |
752 |
if (in_cksum((unsigned short *)ALLIGN(buf+hlen), cc)) { |
753 |
if (verbose) |
753 |
if (verbose) |
754 |
logtrace("ICMP %s from %s: Bad checksum\n", |
754 |
logtrace("ICMP %s from %s: Bad checksum\n", |
755 |
pr_type((int)rap->icmp_type), |
755 |
pr_type((int)rap->icmp_type), |
Lines 838-844
pr_pack(char *buf, int cc, struct sockaddr_in *from)
Link Here
|
838 |
/* TBD verify that the link is multicast or broadcast */ |
838 |
/* TBD verify that the link is multicast or broadcast */ |
839 |
/* XXX Find out the link it came in over? */ |
839 |
/* XXX Find out the link it came in over? */ |
840 |
|
840 |
|
841 |
if (in_cksum((u_short *)ALLIGN(buf+hlen), cc)) { |
841 |
if (in_cksum((unsigned short *)ALLIGN(buf+hlen), cc)) { |
842 |
if (verbose) |
842 |
if (verbose) |
843 |
logtrace("ICMP %s from %s: Bad checksum\n", |
843 |
logtrace("ICMP %s from %s: Bad checksum\n", |
844 |
pr_type((int)icp->type), |
844 |
pr_type((int)icp->type), |
Lines 914-929
pr_pack(char *buf, int cc, struct sockaddr_in *from)
Link Here
|
914 |
#if BYTE_ORDER == LITTLE_ENDIAN |
914 |
#if BYTE_ORDER == LITTLE_ENDIAN |
915 |
# define ODDBYTE(v) (v) |
915 |
# define ODDBYTE(v) (v) |
916 |
#elif BYTE_ORDER == BIG_ENDIAN |
916 |
#elif BYTE_ORDER == BIG_ENDIAN |
917 |
# define ODDBYTE(v) ((u_short)(v) << 8) |
917 |
# define ODDBYTE(v) ((unsigned short)(v) << 8) |
918 |
#else |
918 |
#else |
919 |
# define ODDBYTE(v) htons((u_short)(v) << 8) |
919 |
# define ODDBYTE(v) htons((unsigned short)(v) << 8) |
920 |
#endif |
920 |
#endif |
921 |
|
921 |
|
922 |
u_short in_cksum(u_short *addr, int len) |
922 |
unsigned short in_cksum(unsigned short *addr, int len) |
923 |
{ |
923 |
{ |
924 |
register int nleft = len; |
924 |
register int nleft = len; |
925 |
register u_short *w = addr; |
925 |
register unsigned short *w = addr; |
926 |
register u_short answer; |
926 |
register unsigned short answer; |
927 |
register int sum = 0; |
927 |
register int sum = 0; |
928 |
|
928 |
|
929 |
/* |
929 |
/* |
Lines 939-945
u_short in_cksum(u_short *addr, int len)
Link Here
|
939 |
|
939 |
|
940 |
/* mop up an odd byte, if necessary */ |
940 |
/* mop up an odd byte, if necessary */ |
941 |
if( nleft == 1 ) |
941 |
if( nleft == 1 ) |
942 |
sum += ODDBYTE(*(u_char *)w); /* le16toh() may be unavailable on old systems */ |
942 |
sum += ODDBYTE(*(unsigned char *)w); /* le16toh() may be unavailable on old systems */ |
943 |
|
943 |
|
944 |
/* |
944 |
/* |
945 |
* add back carry outs from top 16 bits to low 16 bits |
945 |
* add back carry outs from top 16 bits to low 16 bits |
Lines 1263-1269
join(int sock, struct sockaddr_in *sin)
Link Here
|
1263 |
int support_multicast() |
1263 |
int support_multicast() |
1264 |
{ |
1264 |
{ |
1265 |
int sock; |
1265 |
int sock; |
1266 |
u_char ttl = 1; |
1266 |
unsigned char ttl = 1; |
1267 |
|
1267 |
|
1268 |
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); |
1268 |
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); |
1269 |
if (sock < 0) { |
1269 |
if (sock < 0) { |