PageRenderTime 37ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/CUDK/IPC/Linux/cu_ipc.c

http://github.com/CyanogenMod/cm-kernel
C | 98 lines | 51 code | 15 blank | 32 comment | 3 complexity | 137ac92b24d409f2c587387f6ab057f8 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0
  1. /*******************************************************************************
  2. **+--------------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright 1998-2008 Texas Instruments, Inc. - http://www.ti.com/ |**
  5. **| |**
  6. **| Licensed under the Apache License, Version 2.0 (the "License"); |**
  7. **| you may not use this file except in compliance with the License. |**
  8. **| You may obtain a copy of the License at |**
  9. **| |**
  10. **| http://www.apache.org/licenses/LICENSE-2.0 |**
  11. **| |**
  12. **| Unless required by applicable law or agreed to in writing, software |**
  13. **| distributed under the License is distributed on an "AS IS" BASIS, |**
  14. **| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |**
  15. **| See the License for the specific language governing permissions and |**
  16. **| limitations under the License. |**
  17. **| |**
  18. **+--------------------------------------------------------------------------+**
  19. *******************************************************************************/
  20. #include <stdio.h>
  21. #include <string.h>
  22. #include <stdlib.h>
  23. #include <errno.h>
  24. #include <unistd.h>
  25. #include <sys/types.h>
  26. #include <sys/socket.h>
  27. #include <sys/un.h>
  28. #include "osTIType.h"
  29. /*#include "cu_ipc.h"*/
  30. const char* socket_name = "/var/run/echo_server";
  31. struct sockaddr_un serv_addr, clnt_addr;
  32. int clnt_sfd;
  33. /***************************************************************************/
  34. void config_ipc_init(char* device_name)
  35. {
  36. int serv_addr_len, clnt_addr_len;
  37. /* Store the client name in the socket address. */
  38. /*bzero(serv_addr,sizeof(serv_addr));*/
  39. serv_addr.sun_family = AF_LOCAL;
  40. strcpy (serv_addr.sun_path, socket_name);
  41. serv_addr_len = sizeof(serv_addr.sun_family)+strlen(serv_addr.sun_path);
  42. unlink("/var/run/echo_client");
  43. /* Create the socket. */
  44. if((clnt_sfd = socket(AF_LOCAL, SOCK_DGRAM, 0))<0)
  45. {
  46. printf("--config_ipc_init(): error creating socket\n");
  47. exit(1);
  48. }
  49. /* Store the client name in the socket address. */
  50. /*bzero(clnt_addr,sizeof(clnt_addr));*/
  51. clnt_addr.sun_family = AF_LOCAL;
  52. strcpy (clnt_addr.sun_path, "/var/run/echo_client");
  53. clnt_addr_len = sizeof(clnt_addr.sun_family)+strlen(clnt_addr.sun_path);
  54. if ( (bind (clnt_sfd, (struct sockaddr *)&clnt_addr, clnt_addr_len )) < 0)
  55. {
  56. printf("---config_ipc_init(): Error binding \n");
  57. unlink(clnt_addr.sun_path);
  58. }
  59. /*InitTIS_Manager( device_name );*/
  60. return;
  61. }
  62. /***************************************************************************/
  63. int ipc_send_tosuppl(void *pData, tiUINT32 size)
  64. {
  65. int rc;
  66. /*printf("---ipc_send_tosuppl(): %x", size);*/
  67. int serv_addr_len = sizeof(serv_addr.sun_family)+strlen(serv_addr.sun_path);
  68. rc = sendto(clnt_sfd, pData, size, 0,
  69. (struct sockaddr *)&serv_addr, serv_addr_len );
  70. if( rc < 0 )
  71. {
  72. printf("---ipc_send_tosuppl(): Error sending message - %x(%s)\n",errno, strerror(errno));
  73. unlink(clnt_addr.sun_path);
  74. }
  75. /*printf("--ipc_send_tosuppl(): Message has been sent - %x\n",rc); */
  76. return rc;
  77. }
  78. /***************************************************************************/
  79. void config_ipc_terminate(void)
  80. {
  81. unlink("/var/run/echo_client");
  82. /*TerminateTIS_Manager() //TIWLN_SUPPL_TERMINATE*/
  83. }