summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
19f3e4f)
SCCS-vsn: sbin/routed/input.c 5.20
SCCS-vsn: sbin/routed/main.c 5.17
SCCS-vsn: sbin/routed/trace.h 5.7
-static char sccsid[] = "@(#)input.c 5.19 (Berkeley) %G%";
+static char sccsid[] = "@(#)input.c 5.20 (Berkeley) %G%";
/*
* Process a newly received packet.
*/
/*
* Process a newly received packet.
*/
+rip_input(from, rip, size)
+ register struct rip *rip;
int size;
{
register struct rt_entry *rt;
int size;
{
register struct rt_entry *rt;
static struct sockaddr badfrom, badfrom2;
ifp = 0;
static struct sockaddr badfrom, badfrom2;
ifp = 0;
- TRACE_INPUT(ifp, from, size);
+ TRACE_INPUT(ifp, from, (char *)rip, size);
if (from->sa_family >= af_max ||
(afp = &afswitch[from->sa_family])->af_hash == (int (*)())0) {
syslog(LOG_INFO,
"\"from\" address in unsupported address family (%d), cmd %d\n",
if (from->sa_family >= af_max ||
(afp = &afswitch[from->sa_family])->af_hash == (int (*)())0) {
syslog(LOG_INFO,
"\"from\" address in unsupported address family (%d), cmd %d\n",
- from->sa_family, msg->rip_cmd);
+ from->sa_family, rip->rip_cmd);
- if (msg->rip_vers == 0) {
+ if (rip->rip_vers == 0) {
syslog(LOG_ERR,
"RIP version 0 packet received from %s! (cmd %d)",
syslog(LOG_ERR,
"RIP version 0 packet received from %s! (cmd %d)",
- (*afswitch[from->sa_family].af_format)(from), msg->rip_cmd);
+ (*afswitch[from->sa_family].af_format)(from), rip->rip_cmd);
- switch (msg->rip_cmd) {
+ switch (rip->rip_cmd) {
- n = msg->rip_nets;
- count = size - ((char *)n - (char *)msg);
+ n = rip->rip_nets;
+ count = size - ((char *)n - (char *)rip);
if (count < sizeof (struct netinfo))
return;
for (; count > 0; n++) {
if (count < sizeof (struct netinfo))
return;
for (; count > 0; n++) {
#endif
n->rip_metric = htonl(n->rip_metric);
}
#endif
n->rip_metric = htonl(n->rip_metric);
}
- msg->rip_cmd = RIPCMD_RESPONSE;
+ rip->rip_cmd = RIPCMD_RESPONSE;
+ bcopy((char *)rip, packet, size);
(*afp->af_output)(s, 0, from, size);
return;
(*afp->af_output)(s, 0, from, size);
return;
(*afswitch[from->sa_family].af_format)(from));
return;
}
(*afswitch[from->sa_family].af_format)(from));
return;
}
- packet[size] = '\0';
- if (msg->rip_cmd == RIPCMD_TRACEON)
- traceon(msg->rip_tracefile);
+ ((char *)rip)[size] = '\0';
+ if (rip->rip_cmd == RIPCMD_TRACEON)
+ traceon(rip->rip_tracefile);
return;
}
size -= 4 * sizeof (char);
return;
}
size -= 4 * sizeof (char);
for (; size > 0; size -= sizeof (struct netinfo), n++) {
if (size < sizeof (struct netinfo))
break;
for (; size > 0; size -= sizeof (struct netinfo), n++) {
if (size < sizeof (struct netinfo))
break;
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)main.c 5.16 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c 5.17 (Berkeley) %G%";
continue;
}
(void) gettimeofday(&now, (struct timezone *)NULL);
continue;
}
(void) gettimeofday(&now, (struct timezone *)NULL);
+ omask = sigblock(sigmask(SIGALRM));
#ifdef doesntwork
/*
printf("s %d, ibits %x index %d, mod %d, sh %x, or %x &ibits %x\n",
#ifdef doesntwork
/*
printf("s %d, ibits %x index %d, mod %d, sh %x, or %x &ibits %x\n",
#endif
process(s);
/* handle ICMP redirects */
#endif
process(s);
/* handle ICMP redirects */
int fd;
{
struct sockaddr from;
int fd;
{
struct sockaddr from;
- int fromlen, cc, omask;
+ int fromlen, cc;
+ union {
+ char buf[MAXPACKETSIZE+1];
+ struct rip rip;
+ } inbuf;
for (;;) {
fromlen = sizeof (from);
for (;;) {
fromlen = sizeof (from);
- cc = recvfrom(fd, packet, sizeof (packet), 0, &from, &fromlen);
+ cc = recvfrom(fd, &inbuf, sizeof (inbuf), 0, &from, &fromlen);
if (cc <= 0) {
if (cc < 0 && errno != EWOULDBLOCK)
perror("recvfrom");
if (cc <= 0) {
if (cc < 0 && errno != EWOULDBLOCK)
perror("recvfrom");
}
if (fromlen != sizeof (struct sockaddr_in))
break;
}
if (fromlen != sizeof (struct sockaddr_in))
break;
- omask = sigblock(sigmask(SIGALRM));
- rip_input(&from, cc);
- sigsetmask(omask);
+ rip_input(&from, &inbuf.rip, cc);
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#)trace.h 5.6 (Berkeley) %G%
+ * @(#)trace.h 5.7 (Berkeley) %G%
if (traceactions) \
tracenewmetric(ftrace, route, newmetric); \
}
if (traceactions) \
tracenewmetric(ftrace, route, newmetric); \
}
-#define TRACE_INPUT(ifp, src, size) { \
+#define TRACE_INPUT(ifp, src, pack, size) { \
if (tracehistory) { \
ifp = if_iflookup(src); \
if (ifp) \
if (tracehistory) { \
ifp = if_iflookup(src); \
if (ifp) \
- trace(&ifp->int_input, src, packet, size, \
+ trace(&ifp->int_input, src, pack, size, \
ntohl(ifp->int_metric)); \
} \
if (tracepackets) \
ntohl(ifp->int_metric)); \
} \
if (tracepackets) \
- dumppacket(ftrace, "from", src, packet, size, &now); \
+ dumppacket(ftrace, "from", src, pack, size, &now); \
}
#define TRACE_OUTPUT(ifp, dst, size) { \
if (tracehistory && ifp) \
}
#define TRACE_OUTPUT(ifp, dst, size) { \
if (tracehistory && ifp) \