other-licenses/android/resolv_cache.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /*
     2  * Copyright (C) 2008 The Android Open Source Project
     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  *  * Redistributions of source code must retain the above copyright
     9  *    notice, this list of conditions and the following disclaimer.
    10  *  * Redistributions in binary form must reproduce the above copyright
    11  *    notice, this list of conditions and the following disclaimer in
    12  *    the documentation and/or other materials provided with the
    13  *    distribution.
    14  *
    15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
    18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
    22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
    23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    26  * SUCH DAMAGE.
    27  */
    29 /*
    30  * This version of this file is derived from Android 2.3 "Gingerbread",
    31  * which contains uncredited changes by Android/Google developers.  It has
    32  * been modified in 2011 for use in the Android build of Mozilla Firefox by
    33  * Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
    34  * and Steve Workman <sjhworkman@gmail.com>).
    35  * These changes are offered under the same license as the original NetBSD
    36  * file, whose copyright and license are unchanged above.
    37  */
    39 #ifndef _RESOLV_CACHE_H_
    40 #define _RESOLV_CACHE_H_
    42 struct resolv_cache;  /* forward */
    44 /* get cache instance, can be NULL if cache is disabled
    45  * (e.g. through an environment variable) */
    46 extern struct resolv_cache*  __get_res_cache(void);
    48 /* this gets called everytime we detect some changes in the DNS configuration
    49  * and will flush the cache */
    50 extern void   _resolv_cache_reset( unsigned  generation );
    52 typedef enum {
    53     RESOLV_CACHE_UNSUPPORTED,  /* the cache can't handle that kind of queries */
    54                                /* or the answer buffer is too small */
    55     RESOLV_CACHE_NOTFOUND,     /* the cache doesn't know about this query */
    56     RESOLV_CACHE_FOUND         /* the cache found the answer */
    57 } ResolvCacheStatus;
    59 extern ResolvCacheStatus
    60 _resolv_cache_lookup( struct resolv_cache*  cache,
    61                       const void*           query,
    62                       int                   querylen,
    63                       void*                 answer,
    64                       int                   answersize,
    65                       int                  *answerlen );
    67 /* add a (query,answer) to the cache, only call if _resolv_cache_lookup
    68  * did return RESOLV_CACHE_NOTFOUND
    69  */
    70 extern void
    71 _resolv_cache_add( struct resolv_cache*  cache,
    72                    const void*           query,
    73                    int                   querylen,
    74                    const void*           answer,
    75                    int                   answerlen );
    77 #endif /* _RESOLV_CACHE_H_ */

mercurial