You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2011/06/26 02:05:33 UTC
svn commit: r1139671 - in /trafficserver/plugins/geoip_acl: ./ CHANGES
LICENSE Makefile README STATUS acl.cc acl.h examples geoip_acl.cc lulu.h
Author: zwoop
Date: Sun Jun 26 00:05:32 2011
New Revision: 1139671
URL: http://svn.apache.org/viewvc?rev=1139671&view=rev
Log:
Basic Geo-location ACL implementation in a plugin
Added:
trafficserver/plugins/geoip_acl/
trafficserver/plugins/geoip_acl/CHANGES
trafficserver/plugins/geoip_acl/LICENSE
trafficserver/plugins/geoip_acl/Makefile
trafficserver/plugins/geoip_acl/README
trafficserver/plugins/geoip_acl/STATUS
trafficserver/plugins/geoip_acl/acl.cc
trafficserver/plugins/geoip_acl/acl.h
trafficserver/plugins/geoip_acl/examples
trafficserver/plugins/geoip_acl/geoip_acl.cc
trafficserver/plugins/geoip_acl/lulu.h
Added: trafficserver/plugins/geoip_acl/CHANGES
URL: http://svn.apache.org/viewvc/trafficserver/plugins/geoip_acl/CHANGES?rev=1139671&view=auto
==============================================================================
--- trafficserver/plugins/geoip_acl/CHANGES (added)
+++ trafficserver/plugins/geoip_acl/CHANGES Sun Jun 26 00:05:32 2011
@@ -0,0 +1,11 @@
+ -*- coding: utf-8 -*-
+
+Changes with Apache Traffic Server header_filter 1.0
+
+ *) Added support for the "add" and "set" operators, e.g.
+
+ [SEND_REQUEST_HDR]
+ Host =www.ogre.com=
+ X-Append-Header +Added by ATS+
+
+ *) This is a basic plugin for doing header_filtering.
Added: trafficserver/plugins/geoip_acl/LICENSE
URL: http://svn.apache.org/viewvc/trafficserver/plugins/geoip_acl/LICENSE?rev=1139671&view=auto
==============================================================================
--- trafficserver/plugins/geoip_acl/LICENSE (added)
+++ trafficserver/plugins/geoip_acl/LICENSE Sun Jun 26 00:05:32 2011
@@ -0,0 +1,404 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+~~~
+
+Copyright (C) 2009 Yahoo! Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+~~~
+
+Mersenne Twister License
+
+Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. The names of its contributors may not be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Any feedback is very welcome.
+http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
+email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
+
+~~~
+
+TK 8.3 License
+
+This software is copyrighted by the Regents of the University of
+California, Sun Microsystems, Inc., and other parties. The following
+terms apply to all files associated with the software unless explicitly
+disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
+
+~~~
+
+BIND license
+
+Copyright (c) 1985, 1989, 1993
+ The Regents of the University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+
+
+Portions Copyright (c) 1993 by Digital Equipment Corporation.
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies, and that
+the name of Digital Equipment Corporation not be used in advertising or
+publicity pertaining to distribution of the document or software without
+specific, written prior permission.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
+CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+
+
+Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+Portions Copyright (c) 1996-1999 by Internet Software Consortium.
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+~~~
+
+Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
+Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
+Copyright (C) 2005 Ariya Hidayat (ariya@kde.org)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+
+For the strlcat, strlcpy in inktomi++/ink_string.cc:
+
+Copyright (c) 1998 Todd C. Miller <To...@courtesan.com>
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
Added: trafficserver/plugins/geoip_acl/Makefile
URL: http://svn.apache.org/viewvc/trafficserver/plugins/geoip_acl/Makefile?rev=1139671&view=auto
==============================================================================
--- trafficserver/plugins/geoip_acl/Makefile (added)
+++ trafficserver/plugins/geoip_acl/Makefile Sun Jun 26 00:05:32 2011
@@ -0,0 +1,50 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+TSXS=tsxs
+GEO_LIB=GeoIP # Also check lulu.h for defines ...
+
+all: geoip_acl.cc acl.cc
+ $(TSXS) -v -C $? -l $(GEO_LIB) -o geoip_acl.so
+
+install:
+ tsxs -i -o geoip_acl.so
+
+clean:
+ rm -f *.lo *.so *.bz2 *.asc *.md5 *.sha1
+
+
+# Don't touch
+PACKAGE=geoip_acl
+VERSION=0.9
+distdir = $(PACKAGE)-$(VERSION)
+remove_distdir = \
+ { test ! -d "$(distdir)" \
+ || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+ && rm -fr "$(distdir)"; }; }
+
+asf-distdir:
+ @$(remove_distdir)
+ svn export . $(distdir)
+
+asf-dist: asf-distdir
+ tar chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2
+ @$(remove_distdir)
+
+asf-dist-sign: asf-dist
+ md5sum -b $(distdir).tar.bz2 >$(distdir).tar.bz2.md5
+ sha1sum -b $(distdir).tar.bz2 >$(distdir).tar.bz2.sha1
+ gpg2 --armor --output $(distdir).tar.bz2.asc --detach-sig $(distdir).tar.bz2
Added: trafficserver/plugins/geoip_acl/README
URL: http://svn.apache.org/viewvc/trafficserver/plugins/geoip_acl/README?rev=1139671&view=auto
==============================================================================
--- trafficserver/plugins/geoip_acl/README (added)
+++ trafficserver/plugins/geoip_acl/README Sun Jun 26 00:05:32 2011
@@ -0,0 +1,88 @@
+Apache Traffic Server GeoIP ACLs
+================================
+
+This is a simple ATS plugin for denying (or allowing) requests based on the
+source IP geo-location. Currently only the Maxmind APIs are supported, but
+we'd be happy to other other (open) APIs if you let us know.
+
+
+Building
+========
+
+The build and installation requires a full installation of Apache Traffic
+Server v3.0.0 or later. In particular, the include files must be available,
+and the tsxs build script should be in the path (or modify the Makefile).
+
+ % gmake
+ % sudo gmake install
+
+
+Configuration
+=============
+
+Once installed, there are three primary use cases, which we will discuss in
+details. Note that in all configurations, the first plugin parameter must
+specify what the matches should be applied to. Currently, only one rule set
+is supported, for Country ISO codes. This is specified with a parameter of
+
+ @pparam=country
+
+
+Future additions to this plugin could include other regions, such as city,
+state, continent etc.
+
+The three typical use cases are as follows:
+
+1. Per remap configurations, applicable to the entire remap rule. This is
+useful when you can partition your content so that entire prefix paths
+should be filtered. For example, lets assume that http://example.com/music
+is restricted to US customers only, and everything else is world wide
+accessible. In remap.config, you would have something like
+
+ map http://example.com/music http://music.example.com \
+ @plugin=geoip_acl.so @pparam=country @pparam=allow @pparam=US
+
+ map http://example.com http://other.example.com
+
+2. If you can not partition the data with a path prefix, you can specify a
+separate regex mapping filter. The remap.config file might then look like
+
+ map http://example.com http://music.example.com \
+ @plugin=geoip_acl.so @pparam=country @pparam=regex::/etc/music.regex
+
+
+where music.regex is a format with PCRE (perl compatible) regular
+expressions, and unique rules for match. E.g.
+
+ .*\.mp3 allow US
+ .*\.ogg deny US
+
+
+Note that the default in the case of no matches on the regular expressions
+is to "allow" the request. This can be overriden, see next use case.
+
+
+3. You can also combine 1) and 2), and provide defaults in the remap.config
+configuration, which then applies for the cases where no regular expressions
+matches at all. This would be useful to override the default which is to
+allow all requests that don't match. For example
+
+
+ map http://example.com http://music.example.com \
+ @plugin=geoip_acl.so @pparam=country @pparam=allow @pparam= US \
+ @pparam=regex::/etc/music.regex
+
+
+This tells the plugin that in the situation where there is no matching
+regular expression, only allow requests originating from the US.
+
+
+Finally, there's one additional parameter option that can be used:
+
+ @pparam=html::/some/path.html
+
+
+This will override the default reponse body for the denied responses with a
+custom piece of HTML. This can be useful to explain to your users why they
+are getting denied access to a particular piece of content. This
+configuration can be used with any of the use cases described above.
Added: trafficserver/plugins/geoip_acl/STATUS
URL: http://svn.apache.org/viewvc/trafficserver/plugins/geoip_acl/STATUS?rev=1139671&view=auto
==============================================================================
--- trafficserver/plugins/geoip_acl/STATUS (added)
+++ trafficserver/plugins/geoip_acl/STATUS Sun Jun 26 00:05:32 2011
@@ -0,0 +1,21 @@
+Traffic Server Header Filter 1.0 STATUS: -*-text-*-
+Last modified at [$Date: 2010-09-23 10:18:00 -0600 (Thu, 23 Sep 2010) $]
+
+The current version of this file can be found at:
+
+ * https://svn.apache.org/repos/asf/incubator/trafficserver/plugins/header_filter/STATUS
+
+
+Release history:
+ 1.0.0 : Released June 27th, 2011
+
+
+Contributors looking for a mission:
+
+ * Just do an egrep on "TODO" or "XXX" in the source.
+
+ * Review the bug database at: https://issues.apache.org/jira/browse/TS
+
+ - Download, test and review patches attached to open bugs
+
+ * Open bugs in the bug database.
Added: trafficserver/plugins/geoip_acl/acl.cc
URL: http://svn.apache.org/viewvc/trafficserver/plugins/geoip_acl/acl.cc?rev=1139671&view=auto
==============================================================================
--- trafficserver/plugins/geoip_acl/acl.cc (added)
+++ trafficserver/plugins/geoip_acl/acl.cc Sun Jun 26 00:05:32 2011
@@ -0,0 +1,255 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+#include <arpa/inet.h>
+
+#include <string>
+#include <iostream>
+#include <fstream>
+
+#include "acl.h"
+#include "lulu.h"
+
+
+// Global GeoIP object.
+#if MAXMIND_GEOIP
+#include <GeoIP.h>
+GeoIP* gGI;
+TSMutex gGeoIpMutex;
+#endif
+
+// Implementation of the ACL base class.
+void
+Acl::read_html(const char* fn)
+{
+ std::ifstream f;
+
+ f.open(fn, std::ios::in);
+ if (f.is_open()) {
+ _html.append(std::istreambuf_iterator<char>(f), std::istreambuf_iterator<char>());
+ f.close();
+ TSDebug(PLUGIN_NAME, "Loaded HTML from %s", fn);
+ } else {
+ TSError("Unable to open HTML file %s", fn);
+ }
+}
+
+
+// Implementations for the RegexAcl class
+bool
+RegexAcl::parse_line(const char* filename, const std::string& line, int lineno)
+{
+ static const char _SEPARATOR[] = " \t\n";
+ std::string regex, tmp;
+ std::string::size_type pos1, pos2;
+
+ if (line.empty())
+ return false;
+ pos1 = line.find_first_not_of(_SEPARATOR);
+ if (line[pos1] == '#' || pos1 == std::string::npos)
+ return false;
+
+ pos2 = line.find_first_of(_SEPARATOR, pos1);
+ if (pos2 != std::string::npos) {
+ regex = line.substr(pos1, pos2-pos1);
+ pos1 = line.find_first_not_of(_SEPARATOR, pos2);
+ if (pos1 != std::string::npos) {
+ pos2 = line.find_first_of(_SEPARATOR, pos1);
+ if (pos2 != std::string::npos) {
+ tmp = line.substr(pos1, pos2-pos1);
+ if (tmp == "allow")
+ _acl->set_allow(true);
+ else if (tmp == "deny")
+ _acl->set_allow(false);
+ else {
+ TSError("Bad action on in %s:line %d: %s", filename, lineno, tmp.c_str());
+ return false;
+ }
+ // The rest are "tokens"
+ while ((pos1 = line.find_first_not_of(_SEPARATOR, pos2)) != std::string::npos) {
+ pos2 = line.find_first_of(_SEPARATOR, pos1);
+ tmp = line.substr(pos1, pos2-pos1);
+ _acl->add_token(tmp);
+ }
+ compile(regex, filename, lineno);
+ TSDebug(PLUGIN_NAME, "Added regex rule for /%s/", regex.c_str());
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool
+RegexAcl::compile(const std::string& str, const char* filename, int lineno)
+{
+ const char* error;
+ int erroffset;
+
+ _regex_s = str;
+ _rex = pcre_compile(_regex_s.c_str(), 0, &error, &erroffset, NULL);
+
+ if (NULL != _rex) {
+ _extra = pcre_study(_rex, 0, &error);
+ if ((_extra == NULL) && (*error != 0)) {
+ TSError("Failed to study regular expression in %s:line %d at offset %d: %s\n", filename, lineno, erroffset, error);
+ return false;
+ }
+ } else {
+ TSError("Failed to compile regular expression in %s:line %d: %s\n", filename, lineno, error);
+ return false;
+ }
+
+ return true;
+}
+
+void
+RegexAcl::append(RegexAcl* ra)
+{
+ if (NULL == _next) {
+ _next = ra;
+ } else {
+ RegexAcl* cur = _next;
+
+ while (cur->_next)
+ cur = cur->_next;
+ cur->_next = ra;
+ }
+}
+
+
+
+// Implementation of the Country ACL class.
+void
+CountryAcl::add_token(const std::string& str)
+{
+ int iso = -1;
+
+#if MAXMIND_GEOIP
+ iso = GeoIP_id_by_code(str.c_str());
+#endif
+
+ if (iso > 0 && iso < NUM_ISO_CODES) {
+ _iso_country_codes[iso] = true;
+ TSDebug(PLUGIN_NAME, "Added %s(%d) to remap rule, ACL=%d", str.c_str(), iso, _allow);
+ } else {
+ TSError("Tried setting an ISO code (%d) outside the supported range", iso);
+ }
+}
+
+void
+CountryAcl::read_regex(const char* fn)
+{
+ std::ifstream f;
+ int lineno = 0;
+
+ f.open(fn, std::ios::in);
+ if (f.is_open()) {
+ std::string line;
+ RegexAcl* acl = NULL;
+
+ while (!f.eof()) {
+ getline(f, line);
+ ++lineno;
+ if (!acl)
+ acl = new RegexAcl(new CountryAcl());
+ if (acl->parse_line(fn, line, lineno)) {
+ if (NULL == _regexes)
+ _regexes = acl;
+ else
+ _regexes->append(acl);
+ acl = NULL;
+ }
+ }
+ f.close();
+ TSDebug(PLUGIN_NAME, "Loaded regex rules from %s", fn);
+ } else {
+ TSError("Unable to open regex file %s", fn);
+ }
+}
+
+bool
+CountryAcl::eval(TSRemapRequestInfo *rri, TSHttpTxn txnp) const
+{
+ // If there are regex rules, they take priority first. If a regex matches, we will
+ // honor it's eval() rule. If no regexes matches, fall back on the default (which is
+ // "allow" if nothing else is specified).
+ if (NULL != _regexes) {
+ RegexAcl* acl = _regexes;
+ int path_len;
+ const char* path = TSUrlPathGet(rri->requestBufp, rri->requestUrl, &path_len);
+
+ do {
+ if (acl->match(path, path_len)) {
+ TSDebug(PLUGIN_NAME, "Path = %.*s matched /%s/", path_len, path, acl->get_regex().c_str());
+ return acl->eval(rri, txnp);
+ }
+ } while ((acl = acl->next()));
+ }
+
+ // None of the regexes (if any) matched, so fallback to the remap defaults.
+ int iso = -1;
+ const sockaddr* addr = TSHttpTxnClientAddrGet(txnp);
+
+ switch (addr->sa_family) {
+ case AF_INET:
+ {
+ unsigned long ip = ntohl(reinterpret_cast<const struct sockaddr_in *>(addr)->sin_addr.s_addr);
+
+#if MAXMIND_GEOIP
+ TSMutexLock(gGeoIpMutex);
+ iso = GeoIP_id_by_ipnum(gGI, ip);
+ // Sigh, the GeoIP isn't reentrant / thread safe??
+ TSMutexUnlock(gGeoIpMutex);
+ if (TSIsDebugTagSet(PLUGIN_NAME)) {
+ const char* c = GeoIP_country_code_by_ipnum(gGI, ip);
+ TSDebug(PLUGIN_NAME, "eval(): IP=%u seems to come from ISO=%d / %s", ip, iso, c);
+ }
+ }
+#endif
+ break;
+ case AF_INET6:
+ return true;
+ default:
+ break;
+ }
+
+ if ((iso <= 0) || (!_iso_country_codes[iso]))
+ return !_allow;
+
+ return _allow;
+}
+
+
+void
+CountryAcl::process_args(int argc, char* argv[])
+{
+ for(int i=3; i < argc; ++i) {
+ if (!strncmp(argv[i], "allow", 5)) {
+ _allow = true;
+ } else if (!strncmp(argv[i], "deny", 4)) {
+ _allow = false;
+ } else if (!strncmp(argv[i], "regex::", 7)) {
+ read_regex(argv[i] + 7);
+ } else if (!strncmp(argv[i], "html::", 6)) {
+ read_html(argv[i]+ 6);
+ } else { // ISO codes assumed for the rest
+ add_token(argv[i]);
+ }
+ }
+}
Added: trafficserver/plugins/geoip_acl/acl.h
URL: http://svn.apache.org/viewvc/trafficserver/plugins/geoip_acl/acl.h?rev=1139671&view=auto
==============================================================================
--- trafficserver/plugins/geoip_acl/acl.h (added)
+++ trafficserver/plugins/geoip_acl/acl.h Sun Jun 26 00:05:32 2011
@@ -0,0 +1,122 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+#include <stdio.h>
+#include <string.h>
+#include <arpa/inet.h>
+
+#include <ts/ts.h>
+#include <ts/remap.h>
+#include <pcre.h>
+
+#include <string>
+
+#include "lulu.h"
+
+#if MAXMIND_GEOIP
+#include <GeoIP.h>
+extern GeoIP* gGI;
+extern TSMutex gGeoIpMutex;
+#endif
+
+
+// See http://www.iso.org/iso/english_country_names_and_code_elements
+// Maxmind allocates 253 country codes,even though there are only 248 according to the above
+static const int NUM_ISO_CODES = 253;
+
+
+// Base class for all ACLs
+class Acl
+{
+public:
+ Acl()
+ : _html(""), _allow(true)
+ { }
+
+public:
+ // These have to be implemented for each ACL type
+ virtual void read_regex(const char* fn) = 0;
+ virtual void process_args(int argc, char* argv[]) = 0;
+ virtual bool eval(TSRemapRequestInfo *rri, TSHttpTxn txnp) const = 0;
+ virtual void add_token(const std::string& str) = 0;
+
+ void set_allow(bool allow) { _allow = allow; }
+ const char* get_html() const { return _html.c_str(); }
+
+ void send_html(TSHttpTxn txnp) const
+ {
+ if (_html.size() > 0)
+ TSHttpTxnSetHttpRetBody(txnp, _html.c_str(), true);
+ }
+
+ void read_html(const char* fn);
+
+protected:
+ std::string _html;
+ bool _allow;
+};
+
+
+// Base class for all Regex ACLs (which contain Acl() subclassed instances)
+class RegexAcl
+{
+public:
+ RegexAcl(Acl* acl)
+ : _next(NULL), _acl(acl)
+ { }
+
+ const std::string& get_regex() const { return _regex_s; };
+ bool eval(TSRemapRequestInfo *rri, TSHttpTxn txnp) const { return _acl->eval(rri, txnp); }
+ RegexAcl* next() const { return _next; }
+
+ bool match(const char* str, int len) const
+ {
+ return (pcre_exec(_rex, _extra, str, len, 0, 0, NULL, 0) != -1);
+ }
+
+ void append(RegexAcl* ra);
+ bool parse_line(const char* filename, const std::string& line, int lineno);
+
+private:
+ bool compile(const std::string& str, const char* filename, int lineno);
+ std::string _regex_s;
+ pcre* _rex;
+ pcre_extra* _extra;
+ RegexAcl *_next;
+ Acl* _acl;
+};
+
+
+// ACLs based on ISO country codes.
+class CountryAcl : public Acl
+{
+public:
+ CountryAcl()
+ : _regexes(NULL)
+ {
+ memset(_iso_country_codes, 0, sizeof(_iso_country_codes));
+ }
+
+ void read_regex(const char* fn);
+ void process_args(int argc, char* argv[]);
+ bool eval(TSRemapRequestInfo *rri, TSHttpTxn txnp) const;
+ void add_token(const std::string& str);
+
+private:
+ bool _iso_country_codes[NUM_ISO_CODES];
+ RegexAcl* _regexes;
+};
Added: trafficserver/plugins/geoip_acl/examples
URL: http://svn.apache.org/viewvc/trafficserver/plugins/geoip_acl/examples?rev=1139671&view=auto
==============================================================================
--- trafficserver/plugins/geoip_acl/examples (added)
+++ trafficserver/plugins/geoip_acl/examples Sun Jun 26 00:05:32 2011
@@ -0,0 +1,22 @@
+@plugin=geoip_acl.so @pparam=country @pparam=deny @pparam=US @pparam=SE
+
+-- or --
+
+@plugin=geoip_acl.so @pparam=country @pparam=regex::/tmp/foo.conf @pparam=html::/tmp/foo.html
+
+foo.conf:
+
+.*\.exe deny SE
+[a-z]/foo allow US UK SE
+. deny SE
+
+
+-- or --
+
+@plugin=geoip_acl.so @pparam=country @pparam=deny @pparam=SE @pparam=regex::/tmp/foo.conf
+
+foo.conf:
+
+.*\.exe deny SE
+[a-z]/foo allow US UK SE
+. deny SE
Added: trafficserver/plugins/geoip_acl/geoip_acl.cc
URL: http://svn.apache.org/viewvc/trafficserver/plugins/geoip_acl/geoip_acl.cc?rev=1139671&view=auto
==============================================================================
--- trafficserver/plugins/geoip_acl/geoip_acl.cc (added)
+++ trafficserver/plugins/geoip_acl/geoip_acl.cc Sun Jun 26 00:05:32 2011
@@ -0,0 +1,129 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Main entry points for the plugin hooks etc.
+//
+#include <ts/ts.h>
+#include <ts/remap.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "lulu.h"
+#include "acl.h"
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Initialize the plugin as a remap plugin.
+//
+TSReturnCode
+TSRemapInit(TSRemapInterface* api_info, char *errbuf, int errbuf_size)
+{
+ if (api_info->size < sizeof(TSRemapInterface)) {
+ strncpy(errbuf, "[tsremap_init] - Incorrect size of TSRemapInterface structure", errbuf_size - 1);
+ return TS_ERROR;
+ }
+
+ if (api_info->tsremap_version < TSREMAP_VERSION) {
+ snprintf(errbuf, errbuf_size - 1, "[tsremap_init] - Incorrect API version %ld.%ld",
+ api_info->tsremap_version >> 16, (api_info->tsremap_version & 0xffff));
+ return TS_ERROR;
+ }
+
+#if MAXMIND_GEOIP
+ gGI = GeoIP_new(GEOIP_STANDARD);
+ gGeoIpMutex = TSMutexCreate();
+#endif
+
+ TSDebug(PLUGIN_NAME, "remap plugin is succesfully initialized");
+ return TS_SUCCESS; /* success */
+}
+
+
+TSReturnCode
+TSRemapNewInstance(int argc, char* argv[], void** ih, char* errbuf, int errbuf_size)
+{
+ if (argc < 3) {
+ TSError("Unable to create remap instance, need more parameters");
+ return TS_ERROR;
+ } else {
+ Acl* a = NULL;
+
+ if (!strncmp(argv[2], "country", 11)) {
+ TSDebug(PLUGIN_NAME, "creating an ACL rule with ISO country codes");
+ a = new CountryAcl();
+ }
+
+ if (a) {
+ a->process_args(argc, argv);
+ *ih = static_cast<void*>(a);
+ } else {
+ TSError("Unable to create remap instance, no supported ACL specified as first parameter");
+ return TS_ERROR;
+ }
+ }
+
+ return TS_SUCCESS;
+}
+
+void
+TSRemapDeleteInstance(void* ih)
+{
+ Acl* a = static_cast<Acl*>(ih);
+
+ delete a;
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+// Main entry point when used as a remap plugin.
+//
+TSRemapStatus
+TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
+{
+ if (NULL == ih) {
+ TSDebug(PLUGIN_NAME, "No ACLs configured, this is probably a plugin bug");
+ } else {
+ Acl* a = static_cast<Acl*>(ih);
+
+ if (!a->eval(rri, rh)) {
+ TSHttpTxnSetHttpRetStatus((TSHttpTxn)rh, (TSHttpStatus)403);
+ a->send_html((TSHttpTxn)rh);
+ }
+ }
+
+ return TSREMAP_NO_REMAP;
+}
+
+
+/*
+ local variables:
+ mode: C++
+ indent-tabs-mode: nil
+ c-basic-offset: 2
+ c-comment-only-line-offset: 0
+ c-file-offsets: ((statement-block-intro . +)
+ (label . 0)
+ (statement-cont . +)
+ (innamespace . 0))
+ end:
+
+ Indent with: /usr/bin/indent -ncs -nut -npcs -l 120 logstats.cc
+*/
Added: trafficserver/plugins/geoip_acl/lulu.h
URL: http://svn.apache.org/viewvc/trafficserver/plugins/geoip_acl/lulu.h?rev=1139671&view=auto
==============================================================================
--- trafficserver/plugins/geoip_acl/lulu.h (added)
+++ trafficserver/plugins/geoip_acl/lulu.h Sun Jun 26 00:05:32 2011
@@ -0,0 +1,111 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Implement the classes for the various types of hash keys we support.
+//
+#ifndef __LULU_H__
+#define __LULU_H__ 1
+
+// Pick the Geo implementation to use
+#define MAXMIND_GEOIP 1
+
+
+// Define UNUSED properly.
+#if ((__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
+#define UNUSED __attribute__ ((unused))
+#else
+#define UNUSED
+#endif /* #if ((__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7))) */
+
+#include <sys/types.h>
+
+// Memory barriers on i386 / linux / gcc
+#if defined(__i386__)
+#define mb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
+#define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
+#define wmb() __asm__ __volatile__ ( "" : : : "memory")
+#elif defined(__x86_64__)
+#define mb() __asm__ __volatile__ ( "mfence" : : : "memory")
+#define rmb() __asm__ __volatile__ ( "lfence" : : : "memory")
+#define wmb() __asm__ __volatile__ ( "" : : : "memory")
+#else
+#error "Define barriers"
+#endif
+
+// Used for Debug etc.
+static const char* PLUGIN_NAME = "geoip_acl";
+
+
+// From the atomic portions of ATS
+typedef int int32;
+typedef unsigned int intu32;
+typedef long long int64;
+typedef unsigned long long intu64;
+
+typedef volatile int32 vint32;
+typedef volatile int64 vint64;
+typedef volatile void *vvoidp;
+typedef vint32 *pvint32;
+typedef vint64 *pvint64;
+typedef vvoidp *pvvoidp;
+
+#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 1)
+
+/* see http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html */
+static inline int32 ink_atomic_swap(pvint32 mem, int32 value) { return __sync_lock_test_and_set(mem, value); }
+static inline int64 ink_atomic_swap64(pvint64 mem, int64 value) { return __sync_lock_test_and_set(mem, value); }
+static inline void *ink_atomic_swap_ptr(vvoidp mem, void *value) { return __sync_lock_test_and_set((void**)mem, value); }
+static inline int ink_atomic_cas(pvint32 mem, int old, int new_value) { return __sync_bool_compare_and_swap(mem, old, new_value); }
+static inline int64 ink_atomic_cas64(pvint64 mem, int64 old, int64 new_value) { return __sync_bool_compare_and_swap(mem, old, new_value); }
+static inline int ink_atomic_cas_ptr(pvvoidp mem, void* old, void* new_value) { return __sync_bool_compare_and_swap(mem, old, new_value); }
+static inline int ink_atomic_increment(pvint32 mem, int value) { return __sync_fetch_and_add(mem, value); }
+static inline int64 ink_atomic_increment64(pvint64 mem, int64 value) { return __sync_fetch_and_add(mem, value); }
+static inline void *ink_atomic_increment_ptr(pvvoidp mem, intptr_t value) { return __sync_fetch_and_add((void**)mem, value); }
+#else
+// TODO: Deal with this case?
+#failure
+#endif
+
+
+// From google styleguide: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
+#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
+ TypeName(const TypeName&); \
+ void operator=(const TypeName&)
+
+
+#endif // __LULU_H__
+
+
+
+/*
+ local variables:
+ mode: C++
+ indent-tabs-mode: nil
+ c-basic-offset: 2
+ c-comment-only-line-offset: 0
+ c-file-offsets: ((statement-block-intro . +)
+ (label . 0)
+ (statement-cont . +)
+ (innamespace . 0))
+ end:
+
+ Indent with: /usr/bin/indent -ncs -nut -npcs -l 120 logstats.cc
+*/