alias_skinny.c (240725) | alias_skinny.c (259858) |
---|---|
1/*- 2 * alias_skinny.c 3 * 4 * Copyright (c) 2002, 2003 MarcusCom, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * Author: Joe Marcus Clarke <marcus@FreeBSD.org> 29 * | 1/*- 2 * alias_skinny.c 3 * 4 * Copyright (c) 2002, 2003 MarcusCom, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * Author: Joe Marcus Clarke <marcus@FreeBSD.org> 29 * |
30 * $FreeBSD: head/sys/netinet/libalias/alias_skinny.c 240725 2012-09-20 03:29:43Z kevlo $ | 30 * $FreeBSD: head/sys/netinet/libalias/alias_skinny.c 259858 2013-12-25 02:06:57Z glebius $ |
31 */ 32 33#ifdef _KERNEL 34#include <sys/param.h> 35#include <sys/kernel.h> 36#include <sys/module.h> 37#else 38#include <errno.h> --- 12 unchanged lines hidden (view full) --- 51#else 52#include "alias_local.h" 53#include "alias_mod.h" 54#endif 55 56static void 57AliasHandleSkinny(struct libalias *, struct ip *, struct alias_link *); 58 | 31 */ 32 33#ifdef _KERNEL 34#include <sys/param.h> 35#include <sys/kernel.h> 36#include <sys/module.h> 37#else 38#include <errno.h> --- 12 unchanged lines hidden (view full) --- 51#else 52#include "alias_local.h" 53#include "alias_mod.h" 54#endif 55 56static void 57AliasHandleSkinny(struct libalias *, struct ip *, struct alias_link *); 58 |
59static int | 59static int |
60fingerprint(struct libalias *la, struct alias_data *ah) 61{ 62 63 if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL) 64 return (-1); 65 if (la->skinnyPort != 0 && (ntohs(*ah->sport) == la->skinnyPort || 66 ntohs(*ah->dport) == la->skinnyPort)) 67 return (0); 68 return (-1); 69} 70 | 60fingerprint(struct libalias *la, struct alias_data *ah) 61{ 62 63 if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL) 64 return (-1); 65 if (la->skinnyPort != 0 && (ntohs(*ah->sport) == la->skinnyPort || 66 ntohs(*ah->dport) == la->skinnyPort)) 67 return (0); 68 return (-1); 69} 70 |
71static int | 71static int |
72protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) 73{ 74 75 AliasHandleSkinny(la, pip, ah->lnk); 76 return (0); 77} 78 79struct proto_handler handlers[] = { | 72protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) 73{ 74 75 AliasHandleSkinny(la, pip, ah->lnk); 76 return (0); 77} 78 79struct proto_handler handlers[] = { |
80 { 81 .pri = 110, 82 .dir = IN|OUT, 83 .proto = TCP, 84 .fingerprint = &fingerprint, | 80 { 81 .pri = 110, 82 .dir = IN|OUT, 83 .proto = TCP, 84 .fingerprint = &fingerprint, |
85 .protohandler = &protohandler | 85 .protohandler = &protohandler |
86 }, | 86 }, |
87 { EOH } 88}; 89 90static int 91mod_handler(module_t mod, int type, void *data) 92{ 93 int error; 94 --- 8 unchanged lines hidden (view full) --- 103 break; 104 default: 105 error = EINVAL; 106 } 107 return (error); 108} 109 110#ifdef _KERNEL | 87 { EOH } 88}; 89 90static int 91mod_handler(module_t mod, int type, void *data) 92{ 93 int error; 94 --- 8 unchanged lines hidden (view full) --- 103 break; 104 default: 105 error = EINVAL; 106 } 107 return (error); 108} 109 110#ifdef _KERNEL |
111static | 111static |
112#endif 113moduledata_t alias_mod = { 114 "alias_skinny", mod_handler, NULL 115}; 116 117#ifdef _KERNEL 118DECLARE_MODULE(alias_skinny, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND); 119MODULE_VERSION(alias_skinny, 1); --- 328 unchanged lines hidden --- | 112#endif 113moduledata_t alias_mod = { 114 "alias_skinny", mod_handler, NULL 115}; 116 117#ifdef _KERNEL 118DECLARE_MODULE(alias_skinny, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND); 119MODULE_VERSION(alias_skinny, 1); --- 328 unchanged lines hidden --- |