1 // (C) Copyright 2015 Intel Corporation
\r
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
\r
4 // of this software and associated documentation files (the "Software"), to deal
\r
5 // in the Software without restriction, including without limitation the rights
\r
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
7 // copies of the Software, and to permit persons to whom the Software is
\r
8 // furnished to do so, subject to the following conditions:
\r
10 // The above copyright notice and this permission notice shall be included in
\r
11 // all copies or substantial portions of the Software.
\r
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
20 #include <sys/socket.h>
\r
22 #include <netinet/in.h>
\r
26 int main(int argc, char* argv[])
\r
28 char* message = "hello";
\r
30 struct sockaddr_in server_addr;
\r
31 struct hostent* host = gethostbyname("localhost");
\r
33 char* attr = "security.SMACK64IPOUT";
\r
37 perror("Client: Argument missing, please provide port and label for SMACK64IPOUT");
\r
41 port = atoi(argv[1]);
\r
43 sock = socket(AF_INET, SOCK_DGRAM,0);
\r
46 perror("Client: Socket failure");
\r
51 if(fsetxattr(sock, attr, label, strlen(label),0) < 0)
\r
53 perror("Client: Unable to set attribute ");
\r
58 server_addr.sin_family = AF_INET;
\r
59 server_addr.sin_port = htons(port);
\r
60 bcopy((char*) host->h_addr, (char*) &server_addr.sin_addr.s_addr,host->h_length);
\r
61 bzero(&(server_addr.sin_zero),8);
\r
63 ret = sendto(sock, message, strlen(message),0,(const struct sockaddr*)&server_addr,
\r
64 sizeof(struct sockaddr_in));
\r
69 perror("Client: Error sending message\n");
\r