5 #include <netinet/in.h>
10 * Definitions for IP type of service
12 #define IPTOS_LOWDELAY 0x10
13 #define IPTOS_THROUGHPUT 0x08
14 #define IPTOS_RELIABILITY 0x04
15 #define IPTOS_MINCOST 0x02
16 #define IPTOS_NORMALSVC 0x00
18 static void receive_argument(int control_fd, int *TOS_value)
20 if (recv(control_fd, TOS_value, sizeof(int), 0) != sizeof(int)) {
21 fprintf(stderr, "receiving the IP_TOS argument failed\n");
26 int main(int argc, char *argv[])
28 int control_channel_fd, magic_socket;
29 int TOS_value = IPTOS_NORMALSVC;
32 printf("This script is called by vsys.\n");
36 control_channel_fd = atoi(argv[2]);
38 /* receive IP_TOS paramater */
39 receive_argument(control_channel_fd, &TOS_value);
45 case IPTOS_RELIABILITY:
46 case IPTOS_THROUGHPUT:
50 fprintf(stderr, "IP_TOS value not known: %d\n", errno);
54 magic_socket = receive_fd(control_channel_fd);
55 if (magic_socket == -1) {
56 fprintf(stderr, "Error creating socket: %d\n", errno);
60 if (setsockopt(magic_socket, IPPROTO_IP, IP_TOS, &TOS_value, sizeof(TOS_value)) < 0 ) {
61 fprintf(stderr, "Error calling setsockopt for IPPROTO_IP: %d\n", errno);
65 send_fd(control_channel_fd, magic_socket);