Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00022
00023
00024
00025
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