/* * Copyright (c) 1995, 1996, 1998 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. 2. * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. 3. All advertising * materials mentioning features or use of this software must display the * following acknowledgement: This product includes software developed by the * University of California, Berkeley and its contributors. 4. Neither the * name of the University nor the names of its contributors may be used to * endorse or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * * Contains declarations and data structures used by our version of Mobile IP. */ #ifndef IP_MOBILE_H #define IP_MOBILE_H #define IP_MOBILE #ifdef BASESTATION #define MIPSNOOP #endif #ifdef MOBILE_HOST #define MOBILE_MH #endif #define MAX_MOBILE_HOSTS 20 typedef enum {MIP_UNUSED = 0, MIP_UNENCAP_FWD, MIP_UNENCAP_BUF, MIP_ENCAP, MIP_CHSRC} MIP_STATES; #define MIP_NUM_IDS 3 typedef struct mobileip_ids { short lst_pkt; u_short ip_id[MIP_NUM_IDS]; } mobileip_ids; struct ip_mobreq { int type; struct in_addr imr_ifaddr; struct in_multi imr_multi_addr; u_char imr_multicast_ttl; /* TTL for outgoing multicasts */ struct in_addr imr_ins_addr; struct in_addr imr_ins_addr_new; struct mobileip_ids ids; int handoffCtlrPid; char blockedIf[10]; int burstThreshold; int hdrOnly; }; #define MIP_MAX_LOST 12 struct mip_mhdr { short flags; /* mbuf header flags */ int len; /* length of mbuf */ caddr_t data; /* pointer to data */ int pkthdrlen; /* length of packet header in mbuf */ }; struct mip_iphdr { short len; /* ip header length */ u_short id; /* ip id */ short off; /* ip header offset */ u_char ttl; /* ttl of datagram */ char padding; /* to make it word aligned */ }; typedef struct mip_packet { struct mbuf *mb; /* mbuf chain of data */ struct mip_mhdr mh; /* mbuf header fields that need to be saved */ struct mip_iphdr iph; /* some fields of IP header */ } mip_packet_t; typedef char mipInterface[10]; #define MIP_DT_USED 0 #define MIP_DT_UNUSED 1 #define MAX_DT_ENTRIES 40 typedef struct _mobilemh_dt { int state; struct in_addr addr; } mobilemh_dt; struct mobilemh_state { /* The list of blocked interfaces (That is, interfaces that shouldn't have packets passed up from lower layers) */ #define MAX_BLOCKED_IFS 1 mipInterface mipBlockedIfs[MAX_BLOCKED_IFS]; /* The process ID of the handoff controller. It will be notified when too many packets come in via a single interface */ int mipHandoffCtlrPid; /* The number of consecutive packets that must come in before notifying the handoff controller */ int mipBurstThreshold; /* The number of consecutive packets from an interface */ int mipBurstCount; /* The interface that has been receiving the consecutive packets */ char mipBurstIf[10]; /* The last few packets received on the blocked interface */ mip_packet_t *pkts[MIP_MAX_LOST]; /* Where we are in the list of packets that have been buffered */ short lst_pkt; /* The home address of the mobile. It will be inserted in all outgoing packets if sent */ struct in_addr mip_mh_addr; /* Address to tunnel to--if 0, don't tunnel */ struct in_addr tunnel_addr; /* List of destinations to not touch (i.e. don't change source addr or tunnel) */ mobilemh_dt dt[MAX_DT_ENTRIES]; int num_dt; }; struct mobileip_trans { MIP_STATES state; struct in_multi *multi_addr; struct ifnet *ifp; /* ifp for outgoing data */ u_char multicast_ttl; /* TTL of output multicasts */ struct in_addr ins_addr; struct in_addr ins_addr_new; short lst_pkt; mip_packet_t *pkts[MIP_MAX_LOST]; int hdrOnly; /* If 1, then only send/buffer headers */ }; typedef struct mobileip_state { int num_mobile; struct mobileip_trans trans[MAX_MOBILE_HOSTS]; } mobileip_state_t; #ifdef KERNEL extern struct mobileip_ids mip_ids; extern void * mip_malloc(int size); extern void mip_init(); extern struct mobileip_trans *mip_find_entry(struct in_addr addr); extern int ip_setmipoptions(int optname, struct ip_mobreq *req); extern int ip_getmipoptions(int optname, register struct mbuf **mp); #ifdef BASESTATION extern int mip_ctrl(struct mbuf *m); extern struct mobileip_state mip_state; #endif #ifdef MOBILE_HOST extern struct mobilemh_state mip_state; #endif #endif #endif