"Fossies" - the Fresh Open Source Software Archive

Member "zorp-7.0.4/lib/kzorp.cc" (28 Oct 2019, 1704 Bytes) of package /linux/privat/zorp-7.0.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "kzorp.cc" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 6.0.11_vs_7.0.1.

    1 /***************************************************************************
    2  *
    3  * Copyright (c) 2000-2015 BalaBit IT Ltd, Budapest, Hungary
    4  * Copyright (c) 2015-2018 BalaSys IT Ltd, Budapest, Hungary
    5  *
    6  * This program is free software; you can redistribute it and/or modify
    7  * it under the terms of the GNU General Public License as published by
    8  * the Free Software Foundation; either version 2 of the License, or
    9  * (at your option) any later version.
   10  *
   11  * This program is distributed in the hope that it will be useful,
   12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  * GNU General Public License for more details.
   15  *
   16  * You should have received a copy of the GNU General Public License along
   17  * with this program; if not, write to the Free Software Foundation, Inc.,
   18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   19  *
   20  ***************************************************************************/
   21 
   22 #include <zorp/zorp.h>
   23 #include <zorp/kzorp-kernel.h>
   24 #include <zorpll/log.h>
   25 
   26 #include <netinet/ip.h>
   27 
   28 gboolean
   29 z_kzorp_get_lookup_result(guint8 family, gint fd, struct z_kzorp_lookup_result *result)
   30 {
   31   socklen_t size = sizeof(*result);
   32   int level;
   33 
   34   z_enter();
   35 
   36   switch (family)
   37     {
   38     case PF_INET:
   39       level = SOL_IP;
   40       break;
   41     case PF_INET6:
   42       level = SOL_IPV6;
   43       break;
   44     default:
   45       g_assert_not_reached();
   46       break;
   47     }
   48 
   49   if (getsockopt(fd, level, SO_KZORP_RESULT, result, &size) < 0)
   50     {
   51       z_log(NULL, CORE_ERROR, 3, "Error querying KZorp lookup result; fd='%d', error='%s'", fd, g_strerror(errno));
   52       z_return(FALSE);
   53     }
   54 
   55   z_return(TRUE);
   56 }