1 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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
/*
* Copyright (C) 2005 Stig Venaas <venaas@uninett.no>
* $Id: ssmping.h,v 1.3 2005/10/18 14:50:31 sv Exp $
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*/
#include <sys/types.h>
#include <sys/time.h>
#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
#ifdef WIN32
#include <windows.h>
#include <ws2tcpip.h>
#include <winsock.h>
#include <winsock2.h>
#else
#include <sys/uio.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <netdb.h>
#endif
/* Needed for Solaris 9 */
#ifndef CMSG_LEN
#define CMSG_LEN(len) (_CMSG_DATA_ALIGN (sizeof (struct cmsghdr)) + (len))
#endif
#ifndef IPV6_V6ONLY
#ifdef linux
#define IPV6_V6ONLY 26
#endif
#endif
#define SSMMODE 1
#define ASMMODE 2
#define SSMPING_REQUEST 'Q'
#define SSMPING_REPLY 'A'
#define SSMPING_PID 1
#define SSMPING_SEQ 2
#define SSMPING_TIMESTAMP 3
#define SSMPING_GROUP 4
#define SOCKADDR_SIZE(addr) (addr.ss_family == AF_INET ? \
sizeof(struct sockaddr_in) : \
sizeof(struct sockaddr_in6))
struct ssmpingdata {
uint32_t pid;
uint32_t seq;
struct timeval timestamp;
};
void errx(char *, ...);
void err(char *, ...);
void setaddr(struct sockaddr_storage *, struct sockaddr_storage *, const char *, const char *);
char *addr2string(struct sockaddr *, socklen_t);
size_t tlvspace(size_t);
char *tlvadd(char *, uint16_t, uint16_t, void *);
void parseargs(int, char **, int, char **, int *, uint32_t *, int *, char **);
int name2addrsock(const char *, int *, struct sockaddr_storage *);
void prep_sock(int, int);
void findsrc(struct sockaddr *, struct sockaddr *);
void setport(struct sockaddr *, int);
char *addr2string(struct sockaddr *, socklen_t);
int doit(int, int, int, struct sockaddr_storage *, struct sockaddr_storage *, char *);
|