proto_impl.h revision 204076
1251875Speter/*- 2251875Speter * Copyright (c) 2009-2010 The FreeBSD Foundation 3251875Speter * All rights reserved. 4251875Speter * 5251875Speter * This software was developed by Pawel Jakub Dawidek under sponsorship from 6251875Speter * the FreeBSD Foundation. 7251875Speter * 8251875Speter * Redistribution and use in source and binary forms, with or without 9251875Speter * modification, are permitted provided that the following conditions 10251875Speter * are met: 11251875Speter * 1. Redistributions of source code must retain the above copyright 12251875Speter * notice, this list of conditions and the following disclaimer. 13251875Speter * 2. Redistributions in binary form must reproduce the above copyright 14251875Speter * notice, this list of conditions and the following disclaimer in the 15251875Speter * documentation and/or other materials provided with the distribution. 16251875Speter * 17251875Speter * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 18251875Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19251875Speter * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20251875Speter * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 21251875Speter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22251875Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23251875Speter * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24251875Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25251875Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26251875Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27251875Speter * SUCH DAMAGE. 28251875Speter * 29251875Speter * $FreeBSD: head/sbin/hastd/proto_impl.h 204076 2010-02-18 23:16:19Z pjd $ 30251875Speter */ 31251875Speter 32251875Speter#ifndef _PROTO_IMPL_H_ 33251875Speter#define _PROTO_IMPL_H_ 34251875Speter 35251875Speter#include <sys/queue.h> 36251875Speter 37251875Speter#include <stdbool.h> /* bool */ 38251875Speter#include <stdlib.h> /* size_t */ 39251875Speter 40251875Speter#define __constructor __attribute__((constructor)) 41251875Speter 42251875Spetertypedef int hp_client_t(const char *, void **); 43251875Spetertypedef int hp_connect_t(void *); 44251875Spetertypedef int hp_server_t(const char *, void **); 45251875Spetertypedef int hp_accept_t(void *, void **); 46251875Spetertypedef int hp_send_t(void *, const unsigned char *, size_t); 47251875Spetertypedef int hp_recv_t(void *, unsigned char *, size_t); 48251875Spetertypedef int hp_descriptor_t(const void *); 49251875Spetertypedef bool hp_address_match_t(const void *, const char *); 50251875Spetertypedef void hp_local_address_t(const void *, char *, size_t); 51251875Spetertypedef void hp_remote_address_t(const void *, char *, size_t); 52251875Spetertypedef void hp_close_t(void *); 53251875Speter 54251875Speterstruct hast_proto { 55251875Speter const char *hp_name; 56251875Speter hp_client_t *hp_client; 57251875Speter hp_connect_t *hp_connect; 58251875Speter hp_server_t *hp_server; 59251875Speter hp_accept_t *hp_accept; 60251875Speter hp_send_t *hp_send; 61251875Speter hp_recv_t *hp_recv; 62251875Speter hp_descriptor_t *hp_descriptor; 63251875Speter hp_address_match_t *hp_address_match; 64251875Speter hp_local_address_t *hp_local_address; 65251875Speter hp_remote_address_t *hp_remote_address; 66251875Speter hp_close_t *hp_close; 67251875Speter LIST_ENTRY(hast_proto) hp_next; 68251875Speter}; 69251875Speter 70251875Spetervoid proto_register(struct hast_proto *proto); 71251875Speter 72251875Speterint proto_common_send(int fd, const unsigned char *data, size_t size); 73251875Speterint proto_common_recv(int fd, unsigned char *data, size_t size); 74253734Speter 75253734Speter#endif /* !_PROTO_IMPL_H_ */ 76251875Speter