Bring the routing seqno into struct bundle.

This commit is contained in:
Brian Somers 1998-02-02 19:33:02 +00:00
parent 42e91bc7b3
commit 820de6eb8e
6 changed files with 33 additions and 31 deletions

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: arp.c,v 1.26 1998/01/23 22:29:16 brian Exp $
* $Id: arp.c,v 1.27 1998/01/24 00:03:14 brian Exp $
*
*/
@ -51,6 +51,7 @@
#include "log.h"
#include "id.h"
#include "route.h"
#include "bundle.h"
#include "arp.h"
#ifdef DEBUG
@ -72,8 +73,6 @@
#define ID0ioctl ioctl
#endif
static int rtm_seq;
static int get_ether_addr(int, struct in_addr, struct sockaddr_dl *);
/*
@ -101,7 +100,7 @@ static struct {
static int arpmsg_valid;
int
sifproxyarp(int unit, struct in_addr hisaddr)
sifproxyarp(struct bundle *bundle, int s)
{
int routes;
@ -110,7 +109,7 @@ sifproxyarp(int unit, struct in_addr hisaddr)
* address.
*/
memset(&arpmsg, 0, sizeof arpmsg);
if (!get_ether_addr(unit, hisaddr, &arpmsg.hwa)) {
if (!get_ether_addr(s, bundle->if_peer, &arpmsg.hwa)) {
LogPrintf(LogERROR, "Cannot determine ethernet address for proxy ARP\n");
return 0;
}
@ -123,12 +122,12 @@ sifproxyarp(int unit, struct in_addr hisaddr)
arpmsg.hdr.rtm_type = RTM_ADD;
arpmsg.hdr.rtm_flags = RTF_ANNOUNCE | RTF_HOST | RTF_STATIC;
arpmsg.hdr.rtm_version = RTM_VERSION;
arpmsg.hdr.rtm_seq = ++rtm_seq;
arpmsg.hdr.rtm_seq = ++bundle->routing_seq;
arpmsg.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY;
arpmsg.hdr.rtm_inits = RTV_EXPIRE;
arpmsg.dst.sin_len = sizeof(struct sockaddr_inarp);
arpmsg.dst.sin_family = AF_INET;
arpmsg.dst.sin_addr.s_addr = hisaddr.s_addr;
arpmsg.dst.sin_addr.s_addr = bundle->if_peer.s_addr;
arpmsg.dst.sin_other = SIN_PROXY;
arpmsg.hdr.rtm_msglen = (char *) &arpmsg.hwa - (char *) &arpmsg
@ -147,7 +146,7 @@ sifproxyarp(int unit, struct in_addr hisaddr)
* cifproxyarp - Delete the proxy ARP entry for the peer.
*/
int
cifproxyarp(int unit, struct in_addr hisaddr)
cifproxyarp(struct bundle *bundle, int s)
{
int routes;
@ -156,7 +155,7 @@ cifproxyarp(int unit, struct in_addr hisaddr)
arpmsg_valid = 0;
arpmsg.hdr.rtm_type = RTM_DELETE;
arpmsg.hdr.rtm_seq = ++rtm_seq;
arpmsg.hdr.rtm_seq = ++bundle->routing_seq;
routes = ID0socket(PF_ROUTE, SOCK_RAW, AF_INET);
if (routes < 0) {
@ -179,7 +178,7 @@ cifproxyarp(int unit, struct in_addr hisaddr)
* sifproxyarp - Make a proxy ARP entry for the peer.
*/
int
sifproxyarp(int unit, struct in_addr hisaddr)
sifproxyarp(struct bundle *bundle, int s)
{
struct arpreq arpreq;
struct {
@ -193,7 +192,7 @@ sifproxyarp(int unit, struct in_addr hisaddr)
* Get the hardware address of an interface on the same subnet as our local
* address.
*/
if (!get_ether_addr(unit, hisaddr, &dls.sdl)) {
if (!get_ether_addr(s, bundle->if_peer, &dls.sdl)) {
LogPrintf(LOG_PHASE_BIT, "Cannot determine ethernet address for proxy ARP\n");
return 0;
}
@ -201,9 +200,10 @@ sifproxyarp(int unit, struct in_addr hisaddr)
arpreq.arp_ha.sa_family = AF_UNSPEC;
memcpy(arpreq.arp_ha.sa_data, LLADDR(&dls.sdl), dls.sdl.sdl_alen);
SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
((struct sockaddr_in *) & arpreq.arp_pa)->sin_addr.s_addr = hisaddr.s_addr;
((struct sockaddr_in *)&arpreq.arp_pa)->sin_addr.s_addr =
bundle->if_peer.s_addr;
arpreq.arp_flags = ATF_PERM | ATF_PUBL;
if (ID0ioctl(unit, SIOCSARP, (caddr_t) & arpreq) < 0) {
if (ID0ioctl(s, SIOCSARP, (caddr_t) & arpreq) < 0) {
LogPrintf(LogERROR, "sifproxyarp: ioctl(SIOCSARP): %s\n", strerror(errno));
return 0;
}
@ -214,14 +214,15 @@ sifproxyarp(int unit, struct in_addr hisaddr)
* cifproxyarp - Delete the proxy ARP entry for the peer.
*/
int
cifproxyarp(int unit, struct in_addr hisaddr)
cifproxyarp(struct bundle *bundle, int s)
{
struct arpreq arpreq;
memset(&arpreq, '\0', sizeof arpreq);
SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
((struct sockaddr_in *) & arpreq.arp_pa)->sin_addr.s_addr = hisaddr.s_addr;
if (ID0ioctl(unit, SIOCDARP, (caddr_t) & arpreq) < 0) {
((struct sockaddr_in *)&arpreq.arp_pa)->sin_addr.s_addr =
bundle->if_peer.s_addr;
if (ID0ioctl(s, SIOCDARP, (caddr_t) & arpreq) < 0) {
LogPrintf(LogERROR, "cifproxyarp: ioctl(SIOCDARP): %s\n", strerror(errno));
return 0;
}

View File

@ -17,9 +17,9 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: arp.h,v 1.6 1997/10/26 01:02:04 brian Exp $
* $Id: arp.h,v 1.7 1998/01/19 02:59:32 brian Exp $
*
*/
extern int cifproxyarp(int, struct in_addr);
extern int sifproxyarp(int, struct in_addr);
extern int cifproxyarp(struct bundle *, int);
extern int sifproxyarp(struct bundle *, int);

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: bundle.c,v 1.1.2.1 1998/02/02 19:32:01 brian Exp $
*/
#include <sys/param.h>
@ -137,7 +137,7 @@ bundle_SetIpDevice(struct bundle *bundle, struct in_addr myaddr,
bundle->if_mine.s_addr = myaddr.s_addr;
if (Enabled(ConfProxy))
sifproxyarp(s, hisaddr);
sifproxyarp(bundle, s);
close(s);
return (0);
@ -288,7 +288,7 @@ bundle_InterfaceDown(struct bundle *bundle)
}
if (Enabled(ConfProxy))
cifproxyarp(s, bundle->if_peer);
cifproxyarp(bundle, s);
memset(&ifrq, '\0', sizeof ifrq);
strncpy(ifrq.ifr_name, bundle->ifname, sizeof ifrq.ifr_name - 1);
@ -425,6 +425,7 @@ bundle_Create(const char *prefix)
bundle.linkup = 0;
bundle.if_mine.s_addr = bundle.if_peer.s_addr = INADDR_ANY;
bundle.routing_seq = 0;
/* Clean out any leftover crud */
bundle_CleanInterface(&bundle);
@ -438,7 +439,7 @@ struct rtmsg {
};
void
bundle_SetRoute(const struct bundle *bundle, int cmd, struct in_addr dst,
bundle_SetRoute(struct bundle *bundle, int cmd, struct in_addr dst,
struct in_addr gateway, struct in_addr mask, int bang)
{
struct rtmsg rtmes;
@ -446,7 +447,6 @@ bundle_SetRoute(const struct bundle *bundle, int cmd, struct in_addr dst,
char *cp;
const char *cmdstr;
struct sockaddr_in rtdata;
static int seqno;
if (bang)
cmdstr = (cmd == RTM_ADD ? "Add!" : "Delete!");
@ -461,7 +461,7 @@ bundle_SetRoute(const struct bundle *bundle, int cmd, struct in_addr dst,
rtmes.m_rtm.rtm_version = RTM_VERSION;
rtmes.m_rtm.rtm_type = cmd;
rtmes.m_rtm.rtm_addrs = RTA_DST;
rtmes.m_rtm.rtm_seq = ++seqno;
rtmes.m_rtm.rtm_seq = ++bundle->routing_seq;
rtmes.m_rtm.rtm_pid = getpid();
rtmes.m_rtm.rtm_flags = RTF_UP | RTF_GATEWAY | RTF_STATIC;

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
* $Id: bundle.h,v 1.1.2.1 1998/02/02 19:32:02 brian Exp $
*/
struct bundle {
@ -32,6 +32,7 @@ struct bundle {
int tun_fd;
char dev[20];
char *ifname;
int routing_seq;
/* These belong at the NCP level */
int linkup;
@ -47,5 +48,5 @@ extern int bundle_TrySetIPaddress(struct bundle *, struct in_addr,
extern void bundle_Linkup(struct bundle *);
extern int bundle_LinkIsUp(const struct bundle *);
extern void bundle_Linkdown(struct bundle *);
extern void bundle_SetRoute(const struct bundle *, int, struct in_addr,
extern void bundle_SetRoute(struct bundle *, int, struct in_addr,
struct in_addr, struct in_addr, int);

View File

@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: route.c,v 1.42.2.3 1998/01/31 02:48:30 brian Exp $
* $Id: route.c,v 1.42.2.4 1998/02/02 19:32:14 brian Exp $
*
*/
@ -339,7 +339,7 @@ ShowRoute(struct cmdargs const *arg)
* Delete routes associated with our interface
*/
void
DeleteIfRoutes(const struct bundle *bundle, int all)
DeleteIfRoutes(struct bundle *bundle, int all)
{
struct rt_msghdr *rtm;
struct sockaddr *sa;

View File

@ -17,12 +17,12 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: route.h,v 1.10 1998/01/19 02:59:34 brian Exp $
* $Id: route.h,v 1.10.2.1 1998/02/02 19:32:15 brian Exp $
*
*/
extern int GetIfIndex(char *);
extern int ShowRoute(struct cmdargs const *);
extern void DeleteIfRoutes(const struct bundle *, int);
extern void DeleteIfRoutes(struct bundle *, int);
extern struct in_addr ChooseHisAddr(struct bundle *, const struct in_addr);
extern const char *Index2Nam(int);