proto_impl.h revision 218194
1204076Spjd/*- 2204076Spjd * Copyright (c) 2009-2010 The FreeBSD Foundation 3204076Spjd * All rights reserved. 4204076Spjd * 5204076Spjd * This software was developed by Pawel Jakub Dawidek under sponsorship from 6204076Spjd * the FreeBSD Foundation. 7204076Spjd * 8204076Spjd * Redistribution and use in source and binary forms, with or without 9204076Spjd * modification, are permitted provided that the following conditions 10204076Spjd * are met: 11204076Spjd * 1. Redistributions of source code must retain the above copyright 12204076Spjd * notice, this list of conditions and the following disclaimer. 13204076Spjd * 2. Redistributions in binary form must reproduce the above copyright 14204076Spjd * notice, this list of conditions and the following disclaimer in the 15204076Spjd * documentation and/or other materials provided with the distribution. 16204076Spjd * 17204076Spjd * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 18204076Spjd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19204076Spjd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20204076Spjd * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 21204076Spjd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22204076Spjd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23204076Spjd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24204076Spjd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25204076Spjd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26204076Spjd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27204076Spjd * SUCH DAMAGE. 28204076Spjd * 29204076Spjd * $FreeBSD: head/sbin/hastd/proto_impl.h 218194 2011-02-02 15:53:09Z pjd $ 30204076Spjd */ 31204076Spjd 32204076Spjd#ifndef _PROTO_IMPL_H_ 33204076Spjd#define _PROTO_IMPL_H_ 34204076Spjd 35204076Spjd#include <sys/queue.h> 36204076Spjd 37204076Spjd#include <stdbool.h> /* bool */ 38204076Spjd#include <stdlib.h> /* size_t */ 39204076Spjd 40204076Spjd#define __constructor __attribute__((constructor)) 41204076Spjd 42204076Spjdtypedef int hp_client_t(const char *, void **); 43218192Spjdtypedef int hp_connect_t(void *, int); 44218193Spjdtypedef int hp_connect_wait_t(void *, int); 45204076Spjdtypedef int hp_server_t(const char *, void **); 46204076Spjdtypedef int hp_accept_t(void *, void **); 47218194Spjdtypedef int hp_wrap_t(int, bool, void **); 48218194Spjdtypedef int hp_send_t(void *, const unsigned char *, size_t, int); 49218194Spjdtypedef int hp_recv_t(void *, unsigned char *, size_t, int *); 50204076Spjdtypedef int hp_descriptor_t(const void *); 51204076Spjdtypedef bool hp_address_match_t(const void *, const char *); 52204076Spjdtypedef void hp_local_address_t(const void *, char *, size_t); 53204076Spjdtypedef void hp_remote_address_t(const void *, char *, size_t); 54204076Spjdtypedef void hp_close_t(void *); 55204076Spjd 56204076Spjdstruct hast_proto { 57218194Spjd const char *hp_name; 58218194Spjd hp_client_t *hp_client; 59218194Spjd hp_connect_t *hp_connect; 60218194Spjd hp_connect_wait_t *hp_connect_wait; 61218194Spjd hp_server_t *hp_server; 62218194Spjd hp_accept_t *hp_accept; 63218194Spjd hp_wrap_t *hp_wrap; 64218194Spjd hp_send_t *hp_send; 65218194Spjd hp_recv_t *hp_recv; 66218194Spjd hp_descriptor_t *hp_descriptor; 67218194Spjd hp_address_match_t *hp_address_match; 68218194Spjd hp_local_address_t *hp_local_address; 69218194Spjd hp_remote_address_t *hp_remote_address; 70218194Spjd hp_close_t *hp_close; 71218194Spjd TAILQ_ENTRY(hast_proto) hp_next; 72204076Spjd}; 73204076Spjd 74210869Spjdvoid proto_register(struct hast_proto *proto, bool isdefault); 75204076Spjd 76218194Spjdint proto_common_send(int sock, const unsigned char *data, size_t size, int fd); 77218194Spjdint proto_common_recv(int sock, unsigned char *data, size_t size, int *fdp); 78204076Spjd 79204076Spjd#endif /* !_PROTO_IMPL_H_ */ 80