• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • Directories
  • File List
  • Globals

sock_ut.c

Go to the documentation of this file.
00001 /* 
00002  * $Id$
00003  * 
00004  * Copyright (C) 2010 iptelorg GmbH
00005  *
00006  * Permission to use, copy, modify, and distribute this software for any
00007  * purpose with or without fee is hereby granted, provided that the above
00008  * copyright notice and this permission notice appear in all copies.
00009  *
00010  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
00011  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00012  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
00013  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00014  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00015  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
00016  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00017  */
00022 /*
00023  * History:
00024  * --------
00025  *  2010-08-09  initial version (andrei)
00026 */
00027 
00028 #include "sock_ut.h"
00029 
00030 #include <sys/types.h>
00031 #include <sys/socket.h>
00032 #include <netinet/in.h>
00033 #include <netinet/in_systm.h>
00034 #include <netinet/ip.h>
00035 #include <errno.h>
00036 #include <arpa/inet.h>
00037 
00038 
00042 int sock_get_ttl(int sock)
00043 {
00044         int ioptval;
00045         unsigned int ioptvallen;
00046 
00047         ioptvallen=sizeof(ioptval);
00048         if (getsockopt( sock, IPPROTO_IP, IP_TTL, (void*) &ioptval,
00049                     &ioptvallen) == -1 )
00050         {
00051                 return -1;
00052         }
00053         return ioptval;
00054 }
00055 
00056 
00057 
00061 int sock_set_ttl(int sock, int ttl)
00062 {
00063         int ioptval;
00064 
00065         if (setsockopt( sock, IPPROTO_IP, IP_TTL, (void*) &ioptval,
00066                                         sizeof(ioptval)) == -1 )
00067                 return -1;
00068         return ioptval;
00069 }
00070 
00071 /* vi: set ts=4 sw=4 tw=79:ai:cindent: */

Generated on Tue May 22 2012 13:10:15 for SIP Router by  doxygen 1.7.1