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