[270] | 1 | /*
|
---|
| 2 | * TECS Generator
|
---|
| 3 | * Generator for TOPPERS Embedded Component System
|
---|
| 4 | *
|
---|
| 5 | * Copyright (C) 2008-2013 by TOPPERS Project
|
---|
| 6 | *--
|
---|
| 7 | * ä¸è¨èä½æ¨©è
|
---|
| 8 | ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
| 9 | * ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
| 10 | * å¤ã»åé
|
---|
| 11 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
| 12 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
| 13 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
| 14 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
| 15 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 16 | * ç¨ã§ããå½¢ã§åé
|
---|
| 17 | å¸ããå ´åã«ã¯ï¼åé
|
---|
| 18 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
| 19 | * è
|
---|
| 20 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
| 21 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 22 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 23 | * ç¨ã§ããªãå½¢ã§åé
|
---|
| 24 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
| 25 | * ã¨ï¼
|
---|
| 26 | * (a) åé
|
---|
| 27 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
| 28 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
| 29 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 30 | * (b) åé
|
---|
| 31 | å¸ã®å½¢æ
|
---|
| 32 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
| 33 | * å ±åãããã¨ï¼
|
---|
| 34 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
| 35 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 36 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
| 37 | 責ãããã¨ï¼
|
---|
| 38 | * ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
| 39 | * ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 40 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
| 41 | * å
|
---|
| 42 | 責ãããã¨ï¼
|
---|
| 43 | *
|
---|
| 44 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
| 45 | ã
|
---|
| 46 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
| 47 | * ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
| 48 | * ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
| 49 | * ã®è²¬ä»»ãè² ããªãï¼
|
---|
| 50 | *
|
---|
| 51 | * $Id: tTINETClient.c 270 2017-02-09 04:03:47Z coas-nagasima $
|
---|
| 52 | */
|
---|
| 53 |
|
---|
| 54 | /* #[<PREAMBLE>]#
|
---|
| 55 | * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
|
---|
| 56 | * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
|
---|
| 57 | *
|
---|
| 58 | * å±æ§ã¢ã¯ã»ã¹ãã¯ã #_CAAM_#
|
---|
| 59 | * cep_id ID ATTR_cep_id
|
---|
| 60 | *
|
---|
| 61 | * #[</PREAMBLE>]# */
|
---|
| 62 |
|
---|
| 63 | #include "tTINETClient_tecsgen.h"
|
---|
| 64 | #include "tTINETClient_factory.h"
|
---|
| 65 |
|
---|
| 66 | #include <string.h>
|
---|
| 67 |
|
---|
| 68 | #include <netinet/in.h>
|
---|
| 69 | #include <netinet/in_itron.h>
|
---|
| 70 | #include <netinet/tcp.h>
|
---|
| 71 |
|
---|
| 72 | #ifndef E_OK
|
---|
| 73 | #define E_OK 0 /* æ£å¸¸çµäº */
|
---|
| 74 | #define E_ID (-18) /* ä¸æ£IDçªå· */
|
---|
| 75 | #endif
|
---|
| 76 |
|
---|
| 77 | /* åãå£é¢æ° #_TEPF_# */
|
---|
| 78 | /* #[<ENTRY_PORT>]# eC0
|
---|
| 79 | * entry port: eC0
|
---|
| 80 | * signature: sChannel
|
---|
| 81 | * context: task
|
---|
| 82 | * #[</ENTRY_PORT>]# */
|
---|
| 83 |
|
---|
| 84 | /* #[<ENTRY_FUNC>]# eC0_send
|
---|
| 85 | * name: eC0_send
|
---|
| 86 | * global_name: tTINETClient_eC0_send
|
---|
| 87 | * oneway: false
|
---|
| 88 | * #[</ENTRY_FUNC>]# */
|
---|
| 89 | ER
|
---|
| 90 | eC0_send(CELLIDX idx, const int8_t* buf, int16_t size, TMO tmo)
|
---|
| 91 | {
|
---|
| 92 | ER ercd = E_OK;
|
---|
| 93 | CELLCB *p_cellcb;
|
---|
| 94 | int sz;
|
---|
| 95 |
|
---|
| 96 | if (VALID_IDX(idx)) {
|
---|
| 97 | p_cellcb = GET_CELLCB(idx);
|
---|
| 98 | }
|
---|
| 99 | else {
|
---|
| 100 | return(E_ID);
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | /* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
|
---|
| 104 | #ifdef DEBUG
|
---|
| 105 | syslog( LOG_INFO, "tTINETServer: send" );
|
---|
| 106 | {
|
---|
| 107 | int i;
|
---|
| 108 | for( i = 0; i < size; i++ ){
|
---|
| 109 | printf( "%02X ", (unsigned char)buf[i] );
|
---|
| 110 | if( i % 8 == 7 )
|
---|
| 111 | putchar( '\n' );
|
---|
| 112 | }
|
---|
| 113 | putchar( '\n' );
|
---|
| 114 | }
|
---|
| 115 | #endif
|
---|
| 116 | while(size>0){
|
---|
| 117 | if((sz=tcp_snd_dat( ATTR_cep_id, (intptr_t *)buf, (size_t)size, tmo )) < 0 ){
|
---|
| 118 | ercd = sz;
|
---|
| 119 | break;
|
---|
| 120 | }
|
---|
| 121 | else{
|
---|
| 122 | size -= sz;
|
---|
| 123 | }
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | return(ercd);
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | /* #[<ENTRY_FUNC>]# eC0_flush
|
---|
| 130 | * name: eC0_flush
|
---|
| 131 | * global_name: tTINETClient_eC0_flush
|
---|
| 132 | * oneway: false
|
---|
| 133 | * #[</ENTRY_FUNC>]# */
|
---|
| 134 | ER
|
---|
| 135 | eC0_flush(CELLIDX idx, TMO tmo)
|
---|
| 136 | {
|
---|
| 137 | ER ercd = E_OK;
|
---|
| 138 | CELLCB *p_cellcb;
|
---|
| 139 | if (VALID_IDX(idx)) {
|
---|
| 140 | p_cellcb = GET_CELLCB(idx);
|
---|
| 141 | }
|
---|
| 142 | else {
|
---|
| 143 | return(E_ID);
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 | /* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
|
---|
| 147 | /* write ã¯ãããã¡ãªã³ã°ãªããªã®ã§ flush ããªã */
|
---|
| 148 |
|
---|
| 149 | return(ercd);
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | /* #[<ENTRY_FUNC>]# eC0_receive
|
---|
| 153 | * name: eC0_receive
|
---|
| 154 | * global_name: tTINETClient_eC0_receive
|
---|
| 155 | * oneway: false
|
---|
| 156 | * #[</ENTRY_FUNC>]# */
|
---|
| 157 | ER_UINT
|
---|
| 158 | eC0_receive(CELLIDX idx, int8_t* buf, int16_t size, TMO tmo)
|
---|
| 159 | {
|
---|
| 160 | ER ercd = E_OK;
|
---|
| 161 | CELLCB *p_cellcb;
|
---|
| 162 |
|
---|
| 163 | if (VALID_IDX(idx)) {
|
---|
| 164 | p_cellcb = GET_CELLCB(idx);
|
---|
| 165 | }
|
---|
| 166 | else {
|
---|
| 167 | return(E_ID);
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | /* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
|
---|
| 171 | ercd = tcp_rcv_dat( ATTR_cep_id, buf, (size_t)size, tmo );
|
---|
| 172 |
|
---|
| 173 | return(ercd);
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | /* #[<ENTRY_FUNC>]# eC0_end_receive
|
---|
| 177 | * name: eC0_end_receive
|
---|
| 178 | * global_name: tTINETClient_eC0_end_receive
|
---|
| 179 | * oneway: false
|
---|
| 180 | * #[</ENTRY_FUNC>]# */
|
---|
| 181 | ER
|
---|
| 182 | eC0_end_receive(CELLIDX idx)
|
---|
| 183 | {
|
---|
| 184 | ER ercd = E_OK;
|
---|
| 185 | CELLCB *p_cellcb;
|
---|
| 186 | if (VALID_IDX(idx)) {
|
---|
| 187 | p_cellcb = GET_CELLCB(idx);
|
---|
| 188 | }
|
---|
| 189 | else {
|
---|
| 190 | return(E_ID);
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | /* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
|
---|
| 194 |
|
---|
| 195 | return(ercd);
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | /* #[<ENTRY_FUNC>]# eC0_reset
|
---|
| 199 | * name: eC0_reset
|
---|
| 200 | * global_name: tTINETClient_eC0_reset
|
---|
| 201 | * oneway: false
|
---|
| 202 | * #[</ENTRY_FUNC>]# */
|
---|
| 203 | ER
|
---|
| 204 | eC0_reset(CELLIDX idx)
|
---|
| 205 | {
|
---|
| 206 | ER ercd = E_OK;
|
---|
| 207 | CELLCB *p_cellcb;
|
---|
| 208 | if (VALID_IDX(idx)) {
|
---|
| 209 | p_cellcb = GET_CELLCB(idx);
|
---|
| 210 | }
|
---|
| 211 | else {
|
---|
| 212 | return(E_ID);
|
---|
| 213 | }
|
---|
| 214 |
|
---|
| 215 | /* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
|
---|
| 216 |
|
---|
| 217 | return(ercd);
|
---|
| 218 | }
|
---|
| 219 |
|
---|
| 220 | /* #[<ENTRY_PORT>]# eOpener
|
---|
| 221 | * entry port: eOpener
|
---|
| 222 | * signature: sTINETClientOpenerIPV4
|
---|
| 223 | * context: task
|
---|
| 224 | * #[</ENTRY_PORT>]# */
|
---|
| 225 |
|
---|
| 226 | /* #[<ENTRY_FUNC>]# eOpener_open
|
---|
| 227 | * name: eOpener_open
|
---|
| 228 | * global_name: tTINETClient_eOpener_open
|
---|
| 229 | * oneway: false
|
---|
| 230 | * #[</ENTRY_FUNC>]# */
|
---|
| 231 | ER
|
---|
| 232 | eOpener_open(CELLIDX idx, const T_IPV4EP* clientAddr, TMO tmo)
|
---|
| 233 | {
|
---|
| 234 | ER ercd = E_OK;
|
---|
| 235 | CELLCB *p_cellcb;
|
---|
| 236 | if (VALID_IDX(idx)) {
|
---|
| 237 | p_cellcb = GET_CELLCB(idx);
|
---|
| 238 | }
|
---|
| 239 | else {
|
---|
| 240 | return(E_ID);
|
---|
| 241 | }
|
---|
| 242 |
|
---|
| 243 | /* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
|
---|
| 244 | puts("opening");
|
---|
| 245 | ercd=tcp_con_cep(ATTR_cep_id, NADR, clientAddr, tmo);
|
---|
| 246 | if(ercd<0){
|
---|
| 247 | puts("failed");
|
---|
| 248 | syslog( LOG_INFO, "TINETClient: connect failed");
|
---|
| 249 | }
|
---|
| 250 |
|
---|
| 251 | return(ercd);
|
---|
| 252 | }
|
---|
| 253 |
|
---|
| 254 | /* #[<ENTRY_FUNC>]# eOpener_close
|
---|
| 255 | * name: eOpener_close
|
---|
| 256 | * global_name: tTINETClient_eOpener_close
|
---|
| 257 | * oneway: false
|
---|
| 258 | * #[</ENTRY_FUNC>]# */
|
---|
| 259 | ER
|
---|
| 260 | eOpener_close(CELLIDX idx, TMO tmo)
|
---|
| 261 | {
|
---|
| 262 | ER ercd = E_OK;
|
---|
| 263 | CELLCB *p_cellcb;
|
---|
| 264 | if (VALID_IDX(idx)) {
|
---|
| 265 | p_cellcb = GET_CELLCB(idx);
|
---|
| 266 | }
|
---|
| 267 | else {
|
---|
| 268 | return(E_ID);
|
---|
| 269 | }
|
---|
| 270 |
|
---|
| 271 | /* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
|
---|
| 272 | ercd = tcp_cls_cep( ATTR_cep_id, 0 ); /* mikan ã¨ã©ã¼å¦ç */
|
---|
| 273 |
|
---|
| 274 | return(ercd);
|
---|
| 275 | }
|
---|
| 276 |
|
---|
| 277 | /* #[<POSTAMBLE>]#
|
---|
| 278 | * ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
|
---|
| 279 | * #[</POSTAMBLE>]#*/
|
---|