1 /* 2 * Copyright (c) 2015 Kazuya GODA <goda@openbsd.org> 3 * 4 * Permission to use, copy, modify, and distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #ifndef _NET_IF_ETHERIP_H_ 18 #define _NET_IF_ETHERIP_H_ 19 20 #if 0 21 /* 22 * TODO: 23 * At this stage, struct etheripstat and struct etherip_header, 24 * and EtherIP sysctl objects are present at netinet/ip_ether.h. 25 * When implementation of etherip is removed from gif(4), there 26 * are moved here. 27 */ 28 29 extern int etherip_allow; 30 extern struct etheripstat etheripstat; 31 32 struct etheripstat { 33 u_int64_t etherips_hdrops; /* packet shorter than header shows */ 34 u_int64_t etherips_qfull; /* bridge queue full, packet dropped */ 35 u_int64_t etherips_noifdrops; /* no interface/bridge information */ 36 u_int64_t etherips_pdrops; /* packet dropped due to policy */ 37 u_int64_t etherips_adrops; /* all other drops */ 38 u_int64_t etherips_ipackets; /* total input packets */ 39 u_int64_t etherips_opackets; /* total output packets */ 40 u_int64_t etherips_ibytes; /* input bytes */ 41 u_int64_t etherips_obytes; /* output bytes */ 42 }; 43 44 struct etherip_header { 45 #if BYTE_ORDER == LITTLE_ENDIAN 46 unsigned int eip_res:4; /* reserved */ 47 unsigned int eip_ver:4; /* version */ 48 #endif 49 #if BYTE_ORDER == BIG_ENDIAN 50 unsigned int eip_ver:4; /* version */ 51 unsigned int eip_res:4; /* reserved */ 52 #endif 53 uint8_t eip_pad; /* required padding byte */ 54 } __packed; 55 56 #define ETHERIP_VERSION 0x03 57 58 /* 59 * Names for Ether-IP sysctl objects 60 */ 61 #define ETHERIPCTL_ALLOW 1 /* accept incoming EtherIP packets */ 62 #define ETHERIPCTL_STATS 2 /* etherip stats */ 63 #define ETHERIPCTL_MAXID 3 64 65 #define ETHERIPCTL_NAMES { \ 66 { 0, 0 }, \ 67 { "allow", CTLTYPE_INT }, \ 68 { "stats", CTLTYPE_STRUCT }, \ 69 } 70 71 72 #endif /* 0 */ 73 74 int ip_etherip_sysctl(int *, uint, void *, size_t *, void *, size_t); 75 int ip_etherip_output(struct ifnet *, struct mbuf *); 76 int ip_etherip_input(struct mbuf **, int *, int, int); 77 78 #ifdef INET6 79 int ip6_etherip_output(struct ifnet *, struct mbuf *); 80 int ip6_etherip_input(struct mbuf **, int *, int, int); 81 #endif /* INET6 */ 82 83 84 #endif /* _NET_IF_ETHERIP_H_ */ 85