/* * @(#) $Id: rsrr.h,v 4.3 1998/07/23 22:00:15 kann Exp $ */ /*************************** rsrr.h ****************************** * * * RSRR: Routing Support for Resource Reservations * * Define rsvpd:routing IPC formats * * * *****************************************************************/ /**************************************************************************** RSVPD -- ReSerVation Protocol Daemon USC Information Sciences Institute Marina del Rey, California RSRR written by: Daniel Zappala, April 1995 RSRR modified by: Jeff Kann, Oct 1997 Copyright (c) 1996 by the University of Southern California All rights reserved. Permission to use, copy, modify, and distribute this software and its documentation in source and binary forms for any purpose and without fee is hereby granted, provided that both the above copyright notice and this permission notice appear in all copies. and that any documentation, advertising materials, and other materials related to such distribution and use acknowledge that the software was developed in part by the University of Southern California, Information Sciences Institute. The name of the University may not be used to endorse or promote products derived from this software without specific prior written permission. THE UNIVERSITY OF SOUTHERN CALIFORNIA makes no representations about the suitability of this software for any purpose. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Other copyrights might apply to parts of this software and are so noted when applicable. ********************************************************************/ int rsrr_dispatch(); int rsrr_interface_query(); int rsrr_interface_reply(); int rsrr_route_query(); /* * Note this needs to be 14 chars for 4.3 BSD compatibility */ #ifdef ALTQ #if defined(__FreeBSD__) && (__FreeBSD_version > 300000) #define RSRR_SERV_PATH "/var/run/rsrr_svr" #define RSRR_CLI_PATH "/var/run/rsrr_cli" #else #define RSRR_SERV_PATH "/tmp/.rsrr_svr" #define RSRR_CLI_PATH "/tmp/.rsrr_cli" #endif #else /* !ALTQ */ #define RSRR_SERV_PATH "/tmp/.rsrr_svr" #define RSRR_CLI_PATH "/tmp/.rsrr_cli" #endif /* !ALTQ */ #ifdef USE_IPV6 #define RSRR_SRV6_PATH "/tmp/.rsrr_sv6" #define RSRR_CL6_PATH "/tmp/.rsrr_cl6" #endif /* USE_IPV6 */ /* * types of sockets being used by RSRR */ #define RSRR_SOCK_RT 0 #define RSRR_SOCK_V4UX 1 #ifdef USE_IPV6 #define RSRR_SOCK_V6UX 2 #endif /* USE_IPV6 */ #define RSRR_MAX_LEN 2048 #define RSRR_HEADER_LEN (sizeof(struct rsrr_header)) /* * To be able to use RSRR v1 for existing Mrouted */ #define RSRRV1_RQ_LEN (RSRR_HEADER_LEN + sizeof(struct rsrrv1_rq)) #define RSRRV1_RR_LEN (RSRR_HEADER_LEN + sizeof(struct rsrrv1_rr)) #define RSRRV1_VIF_LEN (sizeof(struct rsrrv1_vif)) #define RSRR_RQ_LEN (RSRR_HEADER_LEN + sizeof(struct rsrr_rq)) #define RSRR_RR_LEN (RSRR_HEADER_LEN + sizeof(struct rsrr_rr)) #define RSRR_VIF_LEN (sizeof(struct rsrr_vif)) /* * Current maximum number of vifs. */ #define RSRR_MAX_VIFS_V1 32 #define RSRR_MAX_VIFS_V2 256 /* * This should only be used between RSRR and Mcast routing daemon */ typedef struct rsrr_bmp { unsigned char bm[RSRR_MAX_VIFS_V2/NBBY]; } rsrr_bmp; extern bitmap *bmp_convert(rsrr_bmp *, bitmap *); /* * Maximum acceptable version */ #define RSRR_MAX_VERSION 2 /* * RSRR message types */ #define RSRR_ALL_TYPES 0 #define RSRR_INTERFACE_QUERY 1 #define RSRR_INTERFACE_REPLY 2 #define RSRR_ROUTE_QUERY 3 #define RSRR_ROUTE_REPLY 4 /* * some definitions related to routing sockets */ #define RTM_BUFLEN 2048 #define WORD_BNDARY(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1)) /* * Round up 'a' to next multiple of 'size' */ #define ROUNDUP(a, size) (((a) & ((size)-1)) ? (1 + ((a) | ((size)-1))) : (a)) /* * Step to next socket address structure; * if sa_len is 0, assume it is sizeof(u_long). */ #define NEXT_SA(ap) ap = (struct sockaddr *) \ ((caddr_t) ap + (ap->sa_len ? ROUNDUP(ap->sa_len, sizeof (u_long)) : \ sizeof(u_long))) extern struct rsrr_vif vif_list[]; extern int unicast_result_ready; extern int unicast_query_waiting; extern void SetNotifyBit(); extern char rsrr_recv_buf[]; #if defined(PF_ROUTE) && !defined(sgi_53) extern int seq; extern int rskt; #endif /* PF_ROUTE */ /* * RSRR Interface Query flag bits. * ==================== * * 0 = (N) Interface Change Notification bit, set if the reservation * protocol wishes to receive notification of an interface change. * Notification is in the form of an unsolicitied Interface Reply. */ #define RSRR_NOTIFICATION_BIT 0 #define RSRR_ASK_NOTE(flag) (BIT_TST(flag, RSRR_NOTIFICATION_BIT)); /* * RSRR Interface Reply (Vif) Status bits. * ==================== * * 0 = (M) multicast disabled bit, set if vif is multicast disabled * 1 = (U) unicast disabled bit, set if vif is unicast disabled. * 2 = (P) physical interface bit, set if vif is physical interface * 3 = (N) notification bit, set if notification will be made if vif changes * 4 = (T) RSVP tunnel bit, set if the vif is used by RSVP tunnel. (deleted) */ #define RSRR_M_DISABLED_BIT 0 /* M */ #define RSRR_U_DISABLED_BIT 1 /* U */ #define RSRR_PHYINT_BIT 2 /* P */ #define RSRR_WILL_NOTE_BIT 3 /* N */ #define RSRR_TUN_BIT 4 /* T */ #define RSRR_is_M_disabled(x) (BIT_TST(vif_list[x].status, RSRR_M_DISABLED_BIT)); #define RSRR_is_U_disabled(x) (BIT_TST(vif_list[x].status, RSRR_U_DISABLED_BIT)); #define RSRR_PHYINT(x) (BIT_TST(vif_list[x].status, RSRR_PHYINT_BIT)); #define RSRR_WILLNOTE(x) (BIT_TST(vif_list[x].status, RSRR_WILL_NOTE_BIT)); #define RSRR_TUN(x) (BIT_TST(vif_list[x].status, RSRR_TUN_BIT)); /* * RSRR Route Query flag bits. * ================ * * 0 = (N) Route Change Notification bit, set if the reservation protocol * wishes to receive notification of a route change for the * source-destination pair listed in the query. Notification is in the * form of an unsolicitied Route Reply. */ /* defined in Interface Query */ /* #define RSRR_NOTIFICATION_BIT 0 */ /* * RSRR Route Reply flag bits. * ================ * * 0 = (N) Route Change Notification bit, set if the reservation protocol * wishes to receive notification of a route change for the * source-destination pair listed in the query. Notification is in the * form of an unsolicitied Route Reply. * 1 = (E) Error bit, set if routing doesn't have a routing entry for * the source-destination pair. * 2&3:(S) 01 = if the listed sender is using a shared tree, but other * senders for the same destination use sender trees * 10 = if all senders for the destination use shared trees * 00 = otherwise */ /* defined above */ /* #define RSRR_NOTIFICATION_BIT 0 */ #define RSRR_ERROR_BIT 1 #define RSRR_SHARED_TREE 2 #define RSRR_ALL_SHARED_TREE 3 #define RSRR_USE_SHARED(x) ((BIT_TST(x,RSRR_SHARED_TREE)) && !(BIT_TST(x,RSRR_ALL_SHARED_TREE))) #define RSRR_USE_ALL_SHARED(x) (!(BIT_TST(x,RSRR_SHARED_TREE)) && (BIT_TST(x,RSRR_ALL_SHARED_TREE))) /* * RSRR Service Query/Reply flag bits. * * 0 = Vif bit, set if the service query includes a downstream vif on which * the router should begin service. * 1 = Error bit, same as above. * 2 = Stability bit, set if the reservation protocol wishes to keep the * routing entry for a source-destination pair stable. * 3 = Delegation bit, set if the reservation protocol can wants * stability, but doesn't care how routing provides it. If the * stability bit is set, but the delegation bit is cleared, then the * routing protocol should pin the route. Otherwise it may choose to * use a smooth transition to another route that can provide the same * service. * XXX Currently not implemented. * 4 = Reserved it. XXX currently not implemented. */ /* #define RSRR_VIF_BIT 0 #define RSRR_STABILITY_BIT 2 #define RSRR_DELEGATION_BIT 3 #define RSRR_RESERVED_BIT 4 */ /* * Definition of an RSRR message header. * An Interface Query uses only the header, and an Interface Reply uses * the header and a list of vifs. */ struct rsrr_header { u_char version; /* RSRR Version, currently 2 */ u_char type; /* type of message, as defined above */ u_char flags; /* flags; defined by type */ u_char num; /* number; defined by type */ }; #define GET_LOWER(A) ((u_char)(A & 0x0f)) #define SET_LOWER(A,B) (A |= B) #define GET_HIGHER(A) ((u_char)((A & 0xf0) >> 4)) #define SET_HIGHER(A,B) (A |= (B << 4)) /* * Definition of a vif as seen by the reservation protocol. * * Routing gives the reservation protocol a list of vifs in the * Interface Reply. * * We explicitly list the ID because we can't assume that all routing * protocols will use the same numbering scheme. * * The status is a bitmask of status flags, as defined above. It is the * responsibility of the reservation protocol to perform any status checks * if it uses the MULTICAST_VIF socket option. * * The threshold indicates the ttl an outgoing packet needs in order to * be forwarded. The reservation protocol must perform this check itself if * it uses the MULTICAST_VIF socket option. * * The local address is the address of the physical interface over which * packets are sent. */ /* RSRR v1 */ struct rsrrv1_vif { u_char id; /* vif id */ u_char threshold; /* vif threshold ttl */ u_short status; /* vif status bitmask */ struct in_addr local_addr; /* vif local address */ }; /* RSRR v2 */ struct rsrr_vif { u_char id; /* vif id */ u_char threshold; /* vif threshold ttl */ u_char prefix; /* vif CIDR prefix */ u_char status; /* vif status bitmask */ u_short family; /* vif address family */ u_short length; /* vif address length */ union { struct in_addr local_v4_addr; /* vif local ipv4 address */ #ifdef USE_IPV6 struct in6_addr local_v6_addr; /* vif local ipv6 address */ #endif /* USE_IPv6 */ } addr; }; #define addr_v4 addr.local_v4_addr #ifdef USE_IPV6 #define addr_v6 addr.local_v6_addr #endif /* USE_IPV6 */ /* * Definition of an RSRR Route Query. * * The query asks routing for the forwarding entry for a particular * source and destination. The query ID uniquely identifies the query * for the reservation protocol. Thus, the combination of the client's * address and the query ID forms a unique identifier for routing. * Flags are defined above. */ /* RSRR v1 */ struct rsrrv1_rq { struct in_addr dest_addr; /* destination */ struct in_addr source_addr; /* source */ u_long query_id; /* query ID */ }; /* RSRR v2 */ struct rsrr_rq { u_short family; /* address family */ u_short length; /* address length */ union { /* destionation address */ struct in_addr dst_v4_addr; #ifdef USE_IPV6 struct in6_addr dst_v6_addr; #endif /* USE_IPv6 */ } dst; union { /* source address */ struct in_addr src_v4_addr; #ifdef USE_IPV6 struct in6_addr src_v6_addr; #endif /* USE_IPv6 */ } src; u_long query_id; /* query ID */ }; #define dst_v4 dst.dst_v4_addr #define src_v4 src.src_v4_addr #ifdef USE_IPV6 #define dst_v6 dst.dst_v6_addr #define src_v6 src.src_v6_addr #endif /* USE_IPV6 */ /* * Definition of an RSRR Route Reply. * * Routing uses the reply to give the reservation protocol the * forwarding entry for a source-destination pair. Routing copies the * query ID from the query and fills in the incoming vif and a bitmask * of the outgoing vifs. * Flags are defined above. */ /* RSRR v1 */ struct rsrrv1_rr { struct in_addr dest_addr; /* destination */ struct in_addr source_addr; /* source */ u_long query_id; /* query ID */ u_short in_vif; /* incoming vif */ u_short reserved; /* reserved */ u_long out_vif_bm; /* outgoing vif bitmask */ }; /* RSRR v2 */ struct rsrr_rr { u_short family; /* address family */ u_short length; /* address length */ union { /* destionation address */ struct in_addr dst_v4_addr; #ifdef USE_IPV6 struct in6_addr dst_v6_addr; #endif /* USE_IPV6 */ } dst; union { /* source address */ struct in_addr src_v4_addr; #ifdef USE_IPV6 struct in6_addr src_v6_addr; #endif /* USE_IPV6 */ } src; u_long query_id; /* query ID */ u_char in_vif; /* incoming vif */ u_char reserved; /* reserved */ u_short reserved2; /* reserved2 */ rsrr_bmp out_vif_bm; /* outgoing vif bitmask */ }; /* * Definition of an RSRR Service Query/Reply. * * The query asks routing to perform a service for a particular * source/destination combination. The query also lists the vif * that the service applies to. */ /* struct rsrr_sqr { */ /* struct in_addr dest_addr; */ /* destination */ /* struct in_addr source_addr; */ /* source */ /* u_long query_id; */ /* query ID */ /* u_short vif; */ /* vif */ /* u_short reserved; */ /* reserved */ /* }; */