alias_db.c (220800) | alias_db.c (223437) |
---|---|
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_db.c 220800 2011-04-18 20:07:08Z glebius $"); | 28__FBSDID("$FreeBSD: head/sys/netinet/libalias/alias_db.c 223437 2011-06-22 20:00:27Z ae $"); |
29 30/* 31 Alias_db.c encapsulates all data structures used for storing 32 packet aliasing data. Other parts of the aliasing software 33 access data through functions provided in this file. 34 35 Data storage is based on the notion of a "link", which is 36 established for ICMP echo/reply packets, UDP datagrams and --- 510 unchanged lines hidden (view full) --- 547#endif 548static void CleanupAliasData(struct libalias *); 549 550static void IncrementalCleanup(struct libalias *); 551 552static void DeleteLink(struct alias_link *); 553 554static struct alias_link * | 29 30/* 31 Alias_db.c encapsulates all data structures used for storing 32 packet aliasing data. Other parts of the aliasing software 33 access data through functions provided in this file. 34 35 Data storage is based on the notion of a "link", which is 36 established for ICMP echo/reply packets, UDP datagrams and --- 510 unchanged lines hidden (view full) --- 547#endif 548static void CleanupAliasData(struct libalias *); 549 550static void IncrementalCleanup(struct libalias *); 551 552static void DeleteLink(struct alias_link *); 553 554static struct alias_link * |
555AddLink(struct libalias *, struct in_addr, struct in_addr, struct in_addr, 556 u_short, u_short, int, int); 557 558static struct alias_link * | |
559ReLink(struct alias_link *, 560 struct in_addr, struct in_addr, struct in_addr, 561 u_short, u_short, int, int); 562 563static struct alias_link * 564 FindLinkOut (struct libalias *, struct in_addr, struct in_addr, u_short, u_short, int, int); 565 566static struct alias_link * 567 FindLinkIn (struct libalias *, struct in_addr, struct in_addr, u_short, u_short, int, int); 568 569 570#define ALIAS_PORT_BASE 0x08000 571#define ALIAS_PORT_MASK 0x07fff 572#define ALIAS_PORT_MASK_EVEN 0x07ffe 573#define GET_NEW_PORT_MAX_ATTEMPTS 20 574 | 555ReLink(struct alias_link *, 556 struct in_addr, struct in_addr, struct in_addr, 557 u_short, u_short, int, int); 558 559static struct alias_link * 560 FindLinkOut (struct libalias *, struct in_addr, struct in_addr, u_short, u_short, int, int); 561 562static struct alias_link * 563 FindLinkIn (struct libalias *, struct in_addr, struct in_addr, u_short, u_short, int, int); 564 565 566#define ALIAS_PORT_BASE 0x08000 567#define ALIAS_PORT_MASK 0x07fff 568#define ALIAS_PORT_MASK_EVEN 0x07ffe 569#define GET_NEW_PORT_MAX_ATTEMPTS 20 570 |
575#define GET_ALIAS_PORT -1 576#define GET_ALIAS_ID GET_ALIAS_PORT 577 | |
578#define FIND_EVEN_ALIAS_BASE 1 579 580/* GetNewPort() allocates port numbers. Note that if a port number 581 is already in use, that does not mean that it cannot be used by 582 another link concurrently. This is because GetNewPort() looks for 583 unused triplets: (dest addr, dest port, alias port). */ 584 585static int --- 346 unchanged lines hidden (view full) --- 932 933/* Write statistics, if logging enabled */ 934 if (la->packetAliasMode & PKT_ALIAS_LOG) { 935 ShowAliasStats(la); 936 } 937} 938 939 | 571#define FIND_EVEN_ALIAS_BASE 1 572 573/* GetNewPort() allocates port numbers. Note that if a port number 574 is already in use, that does not mean that it cannot be used by 575 another link concurrently. This is because GetNewPort() looks for 576 unused triplets: (dest addr, dest port, alias port). */ 577 578static int --- 346 unchanged lines hidden (view full) --- 925 926/* Write statistics, if logging enabled */ 927 if (la->packetAliasMode & PKT_ALIAS_LOG) { 928 ShowAliasStats(la); 929 } 930} 931 932 |
940static struct alias_link * 941AddLink(struct libalias *la, struct in_addr src_addr, 942 struct in_addr dst_addr, 943 struct in_addr alias_addr, 944 u_short src_port, 945 u_short dst_port, 946 int alias_port_param, /* if less than zero, alias */ 947 int link_type) 948{ /* port will be automatically *//* chosen. 949 * If greater than */ 950 u_int start_point; /* zero, equal to alias port */ | 933struct alias_link * 934AddLink(struct libalias *la, struct in_addr src_addr, struct in_addr dst_addr, 935 struct in_addr alias_addr, u_short src_port, u_short dst_port, 936 int alias_port_param, int link_type) 937{ 938 u_int start_point; |
951 struct alias_link *lnk; 952 953 LIBALIAS_LOCK_ASSERT(la); 954 lnk = malloc(sizeof(struct alias_link)); 955 if (lnk != NULL) { 956 /* Basic initialization */ 957 lnk->la = la; 958 lnk->src_addr = src_addr; --- 1983 unchanged lines hidden --- | 939 struct alias_link *lnk; 940 941 LIBALIAS_LOCK_ASSERT(la); 942 lnk = malloc(sizeof(struct alias_link)); 943 if (lnk != NULL) { 944 /* Basic initialization */ 945 lnk->la = la; 946 lnk->src_addr = src_addr; --- 1983 unchanged lines hidden --- |