Blame genhash/include/main.h

Packit c22fc9
/*
Packit c22fc9
 * Soft:        Perform a GET query to a remote HTTP/HTTPS server.
Packit c22fc9
 *              Set a timer to compute global remote server response
Packit c22fc9
 *              time.
Packit c22fc9
 *
Packit c22fc9
 * Part:        main.c include file.
Packit c22fc9
 *
Packit c22fc9
 * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
Packit c22fc9
 *
Packit c22fc9
 *              This program is distributed in the hope that it will be useful,
Packit c22fc9
 *              but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit c22fc9
 *              MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Packit c22fc9
 *              See the GNU General Public License for more details.
Packit c22fc9
 *
Packit c22fc9
 *              This program is free software; you can redistribute it and/or
Packit c22fc9
 *              modify it under the terms of the GNU General Public License
Packit c22fc9
 *              as published by the Free Software Foundation; either version
Packit c22fc9
 *              2 of the License, or (at your option) any later version.
Packit c22fc9
 *
Packit c22fc9
 * Copyright (C) 2001-2017 Alexandre Cassen, <acassen@gmail.com>
Packit c22fc9
 */
Packit c22fc9
Packit c22fc9
#ifndef _MAIN_H
Packit c22fc9
#define _MAIN_H
Packit c22fc9
Packit c22fc9
/* global includes */
Packit c22fc9
#include <stdlib.h>
Packit c22fc9
#include <stdio.h>
Packit c22fc9
#include <stdint.h>
Packit c22fc9
#include <string.h>
Packit c22fc9
#include <errno.h>
Packit c22fc9
#include <getopt.h>
Packit c22fc9
#include <openssl/ssl.h>
Packit c22fc9
#include <sys/types.h>
Packit c22fc9
#include <sys/socket.h>
Packit c22fc9
#include <netdb.h>
Packit c22fc9
Packit c22fc9
/* local includes */
Packit c22fc9
#include "memory.h"
Packit c22fc9
#include "timer.h"
Packit c22fc9
#include "http.h"
Packit c22fc9
#include "ssl.h"
Packit c22fc9
#include "list.h"
Packit c22fc9
#include "sock.h"
Packit c22fc9
Packit c22fc9
/* Build version */
Packit c22fc9
#define PROG    "genhash"
Packit c22fc9
Packit c22fc9
#define VERSION_CODE 0x010000
Packit c22fc9
#define DATE_CODE    0x15070d
Packit c22fc9
Packit c22fc9
#define GETMETER_VERSION(version)	\
Packit c22fc9
	(version >> 16) & 0xFF,		\
Packit c22fc9
	(version >> 8) & 0xFF,		\
Packit c22fc9
	version & 0xFF
Packit c22fc9
Packit c22fc9
#ifdef VERSION_STRING
Packit c22fc9
  #undef VERSION_STRING
Packit c22fc9
#endif
Packit c22fc9
#define VERSION_STRING PROG" v%d.%d.%d (%.2d/%.2d, 20%.2d)\n",	\
Packit c22fc9
		GETMETER_VERSION(VERSION_CODE),			\
Packit c22fc9
		GETMETER_VERSION(DATE_CODE)
Packit c22fc9
Packit c22fc9
/* HTTP/HTTPS request structure */
Packit c22fc9
typedef struct {
Packit c22fc9
	struct		addrinfo *dst;
Packit c22fc9
	char		ipaddress[INET6_ADDRSTRLEN];
Packit c22fc9
	uint16_t	addr_port;
Packit c22fc9
	char		*url;
Packit c22fc9
	char		*vhost;
Packit c22fc9
	int		verbose;
Packit c22fc9
	int		ssl;
Packit c22fc9
#ifdef _HAVE_SSL_SET_TLSEXT_HOST_NAME_
Packit c22fc9
	int		sni;
Packit c22fc9
#endif
Packit c22fc9
	SSL_CTX		*ctx;
Packit c22fc9
	const SSL_METHOD *meth;
Packit c22fc9
	enum		feat_hashes hash;
Packit c22fc9
	unsigned long	ref_time;
Packit c22fc9
	unsigned long	response_time;
Packit c22fc9
#ifdef _WITH_SO_MARK_
Packit c22fc9
	unsigned int	mark;
Packit c22fc9
#endif
Packit c22fc9
} REQ;
Packit c22fc9
Packit c22fc9
/* Global variables */
Packit c22fc9
extern thread_master_t *master;
Packit c22fc9
extern REQ *req;		/* Cmd line arguments */
Packit c22fc9
extern int exit_code;
Packit c22fc9
Packit c22fc9
/* Data buffer length description */
Packit c22fc9
#define BUFSIZE		1024
Packit c22fc9
Packit c22fc9
/* Command line error handling */
Packit c22fc9
#define CMD_LINE_ERROR   0
Packit c22fc9
#define CMD_LINE_SUCCESS 1
Packit c22fc9
Packit c22fc9
#endif