discvr.h 2.68 KB
Newer Older
1
/*$Id: discvr.h,v 1.4 2001-06-14 23:19:23 ikumar Exp $*/
Kristin Wright's avatar
Kristin Wright committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

#ifndef _TOPD_DISCVR_H_
#define _TOPD_DISCVR_H_

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/time.h>

#include <netinet/in.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/route.h>		
#include <arpa/inet.h>

#define MAX_HOSTNAME       256
#define	INET6_ADDRSTRLEN    46	/* Max size of IPv6 address string: */
#define	SERV_PORT         9788	/* Server port */
#define	IFHADDRSIZ           8	/* UNP recommends allowing for 64-bit EUI-64 in future */
#define ETHADDRSIZ           6  /* Cheat and use for for many MAC address sizes */
#define	MAXLINE	          4096	/* Max text line length; only 
				 * needed until true packets are generated.  -lkw
				 */

#define print_nodeID(x) println_haddr((x), ETHADDRSIZ)

#define INCR_ALIGN(x,y)   ((x) += (y); ALIGN(x);)
                            
#define	socklen_t unsigned int	/* Length of sockaddr address */

/* The structure returned by recvfrom_flags() */
struct in_pktinfo {
  int     ipi_ifindex;          /* received interface index */
  struct in_addr ipi_addr;	/* dst IPv4 address */
};

#define MY_IFF_RECVIF   0x1     /* receiving interface */

struct ifi_info {
  char    ifi_name[IFNAMSIZ];	/* interface name, null terminated */
  u_char  ifi_haddr[IFHADDRSIZ];/* hardware address */
  u_short ifi_hlen;		/* #bytes in hardware address: 0, 6, 8 */
  short   ifi_flags;		/* IFF_xxx constants from <net/if.h> */
  short   ifi_myflags;		/* our own IFI_xxx flags */
  struct sockaddr  *ifi_addr;	/* primary address */
  struct sockaddr  *ifi_brdaddr;/* broadcast address */
  struct sockaddr  *ifi_dstaddr;/* destination address */
  struct ifi_info  *ifi_next;	/* next of these structures */
  struct topd_nborlist *ifi_nbors;/* neighbors */

};

/* Prototypes */

void 
serv_listen(int sockfd, struct sockaddr *pcliaddr, socklen_t clilen);

65
struct ifi_info  *
Kristin Wright's avatar
Kristin Wright committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
forward_request(struct ifi_info *ifi, const struct in_pktinfo *pktinfo,
		     const char *mesg, const int mesglen);
struct ifi_info	*
get_ifi_info(int, int);

void			 
free_ifi_info(struct ifi_info *);

ssize_t	 
recvfrom_flags(int, void *, size_t, int *, struct sockaddr *, socklen_t *,
	       struct in_pktinfo *);

char*
if_indextoname(unsigned int, char *);

char*
sock_ntop(const struct sockaddr *, socklen_t);

char*
net_rt_iflist(int, int, size_t *);

void	 
get_rtaddrs(int, struct sockaddr *, struct sockaddr **);

u_int32_t
91
compose_reply(struct ifi_info *ifi, char *mesg, const int mesglen, int sendnbors);
Kristin Wright's avatar
Kristin Wright committed
92

93 94 95
int
is_my_packet(struct sockaddr *pcliaddr, struct ifi_info *ifihead) ;

Kristin Wright's avatar
Kristin Wright committed
96 97

#endif /* _TOPD_DISCVR_H_ */