source: uKadecot/trunk/uip/task/uip_adpt.c@ 101

Last change on this file since 101 was 101, checked in by coas-nagasima, 8 years ago

TOPPERS/uKadecotのソースコードを追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/plain
File size: 3.5 KB
Line 
1/*
2 * TOPPERS ECHONET Lite Communication Middleware
3 *
4 * Copyright (C) 2014 Cores Co., Ltd. Japan
5 *
6 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
7 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
8 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
9 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
10 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
11 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
12 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
13 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
14ƒƒ“ƒgi—˜—p
15 * ŽÒƒ}ƒjƒ…
16ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
17 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
18 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
19 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
20 * ‚ƁD
21 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
22ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
23ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
24 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
25 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
26 * •ñ‚·‚邱‚ƁD
27 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
28 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
29 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
30 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
31 * –Ɛӂ·‚邱‚ƁD
32 *
33 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
34 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
35 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
36 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
37 * ‚̐ӔC‚𕉂í‚È‚¢D
38 *
39 * @(#) $Id: uip_adpt.c 101 2015-06-02 15:37:23Z coas-nagasima $
40 */
41
42#include <kernel.h>
43#include "uip.h"
44#include "uip_adpt.h"
45#include "t_syslog.h"
46#include "kernel_cfg.h"
47
48/*
49 * uip_task‚ð‹N“®
50 */
51ER uip_start()
52{
53 ER ret;
54
55 /* uip_task—pŽüŠúƒnƒ“ƒhƒ‰‚Ì‹N“® */
56 ret = sta_cyc(UIP_CYCHDR);
57 if (ret != E_OK) {
58 syslog(LOG_DEBUG, "sta_cyc() result = %d", ret);
59 return ret;
60 }
61
62 return E_OK;
63}
64
65/*
66 * convert_hexdigit -- 16i”¨•¶Žš—ñ•ÏŠ·
67 */
68int_t convert_hexdigit (char *buf, uint_t val, int_t radix, int_t width, char padchar)
69{
70 static const char radhex[] = "0123456789abcdef";
71
72 char digits[11], *start;
73 int_t ix, pad;
74
75 ix = 0;
76 start = buf;
77 do {
78 digits[ix ++] = radhex[(val % radix) & 0x0f];
79 val /= radix;
80 } while (val != 0);
81 for (pad = ix; pad < width; pad ++)
82 *buf ++ = padchar;
83 while (ix -- > 0)
84 *buf ++ = digits[ix];
85 *buf = '\0';
86 return (int_t)(buf - start);
87}
88
89/*
90 * ip2str -- IPv4 ƒAƒhƒŒƒX‚𕶎š—ñ‚É•ÏŠ·‚·‚éB
91 */
92char *ip2str(char *buf, const T_IN4_ADDR ipaddr)
93{
94 char *start;
95
96 start = buf;
97 buf += convert_hexdigit(buf, (uint_t)((ipaddr[0] >> 0) & 0xff), 10, 0, ' ');
98 *(buf ++) = '.';
99 buf += convert_hexdigit(buf, (uint_t)((ipaddr[0] >> 8) & 0xff), 10, 0, ' ');
100 *(buf ++) = '.';
101 buf += convert_hexdigit(buf, (uint_t)((ipaddr[1] >> 0) & 0xff), 10, 0, ' ');
102 *(buf ++) = '.';
103 buf += convert_hexdigit(buf, (uint_t)((ipaddr[1] >> 8) & 0xff), 10, 0, ' ');
104 *buf = '\0';
105
106 return start;
107}
108
109ID uip_getid(struct uip_conn *conn)
110{
111 int index;
112
113 index = ((intptr_t)conn - (intptr_t)uip_conns) / sizeof(uip_conns[0]);
114 if ((index < 0) || (index >= sizeof(uip_conns) / sizeof(uip_conns[0])))
115 return -1;
116
117 return index + 1;
118}
119
120struct uip_conn *uip_getconn(ID connid)
121{
122 int index = connid - 1;
123
124 if ((index < 0) || (index >= sizeof(uip_conns) / sizeof(uip_conns[0])))
125 return NULL;
126
127 return &uip_conns[index];
128}
Note: See TracBrowser for help on using the repository browser.