alias_irc.c (190841) | alias_irc.c (259858) |
---|---|
1/*- 2 * Copyright (c) 2001 Charles Mott <cm@linktel.net> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001 Charles Mott <cm@linktel.net> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/netinet/libalias/alias_irc.c 190841 2009-04-08 11:56:49Z piso $"); | 28__FBSDID("$FreeBSD: head/sys/netinet/libalias/alias_irc.c 259858 2013-12-25 02:06:57Z glebius $"); |
29 30/* Alias_irc.c intercepts packages contain IRC CTCP commands, and 31 changes DCC commands to export a port on the aliasing host instead 32 of an aliased host. 33 34 For this routine to work, the DCC command must fit entirely into a 35 single TCP packet. This will usually happen, but is not 36 guaranteed. --- 50 unchanged lines hidden (view full) --- 87 88/* Local defines */ 89#define DBprintf(a) 90 91static void 92AliasHandleIrcOut(struct libalias *, struct ip *, struct alias_link *, 93 int maxpacketsize); 94 | 29 30/* Alias_irc.c intercepts packages contain IRC CTCP commands, and 31 changes DCC commands to export a port on the aliasing host instead 32 of an aliased host. 33 34 For this routine to work, the DCC command must fit entirely into a 35 single TCP packet. This will usually happen, but is not 36 guaranteed. --- 50 unchanged lines hidden (view full) --- 87 88/* Local defines */ 89#define DBprintf(a) 90 91static void 92AliasHandleIrcOut(struct libalias *, struct ip *, struct alias_link *, 93 int maxpacketsize); 94 |
95static int | 95static int |
96fingerprint(struct libalias *la, struct alias_data *ah) 97{ 98 | 96fingerprint(struct libalias *la, struct alias_data *ah) 97{ 98 |
99 if (ah->dport == NULL || ah->dport == NULL || ah->lnk == NULL || | 99 if (ah->dport == NULL || ah->dport == NULL || ah->lnk == NULL || |
100 ah->maxpktsize == 0) 101 return (-1); 102 if (ntohs(*ah->dport) == IRC_CONTROL_PORT_NUMBER_1 103 || ntohs(*ah->dport) == IRC_CONTROL_PORT_NUMBER_2) 104 return (0); 105 return (-1); 106} 107 | 100 ah->maxpktsize == 0) 101 return (-1); 102 if (ntohs(*ah->dport) == IRC_CONTROL_PORT_NUMBER_1 103 || ntohs(*ah->dport) == IRC_CONTROL_PORT_NUMBER_2) 104 return (0); 105 return (-1); 106} 107 |
108static int | 108static int |
109protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) 110{ 111 112 newpacket = malloc(PKTSIZE); 113 if (newpacket) { 114 AliasHandleIrcOut(la, pip, ah->lnk, ah->maxpktsize); 115 free(newpacket); 116 } 117 return (0); 118} 119 120struct proto_handler handlers[] = { | 109protohandler(struct libalias *la, struct ip *pip, struct alias_data *ah) 110{ 111 112 newpacket = malloc(PKTSIZE); 113 if (newpacket) { 114 AliasHandleIrcOut(la, pip, ah->lnk, ah->maxpktsize); 115 free(newpacket); 116 } 117 return (0); 118} 119 120struct proto_handler handlers[] = { |
121 { 122 .pri = 90, 123 .dir = OUT, 124 .proto = TCP, 125 .fingerprint = &fingerprint, | 121 { 122 .pri = 90, 123 .dir = OUT, 124 .proto = TCP, 125 .fingerprint = &fingerprint, |
126 .protohandler = &protohandler | 126 .protohandler = &protohandler |
127 }, | 127 }, |
128 { EOH } 129}; 130 131static int 132mod_handler(module_t mod, int type, void *data) 133{ 134 int error; 135 --- 8 unchanged lines hidden (view full) --- 144 break; 145 default: 146 error = EINVAL; 147 } 148 return (error); 149} 150 151#ifdef _KERNEL | 128 { EOH } 129}; 130 131static int 132mod_handler(module_t mod, int type, void *data) 133{ 134 int error; 135 --- 8 unchanged lines hidden (view full) --- 144 break; 145 default: 146 error = EINVAL; 147 } 148 return (error); 149} 150 151#ifdef _KERNEL |
152static | 152static |
153#endif 154moduledata_t alias_mod = { 155 "alias_irc", mod_handler, NULL 156}; 157 158/* Kernel module definition. */ 159#ifdef _KERNEL 160DECLARE_MODULE(alias_irc, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND); --- 328 unchanged lines hidden --- | 153#endif 154moduledata_t alias_mod = { 155 "alias_irc", mod_handler, NULL 156}; 157 158/* Kernel module definition. */ 159#ifdef _KERNEL 160DECLARE_MODULE(alias_irc, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND); --- 328 unchanged lines hidden --- |