\r
#include "LPC17xx_IAP.h"\r
\r
+/**\r
+ * IPAに通知するCPUクロック。\r
+ * ここで指定したクロック以上で動作させないでください。\r
+ */\r
+#define IPA_CPU_FREQ_IN_HZ ( ( unsigned long ) 100000000 )\r
#define LPC17xx_FLASH_SECTOR_ADDR_16 ((void*)0x00010000)\r
\r
//Define data structure or pointers to pass IAP command table and result table to the IAP\r
/**\r
* IAPのcopy ram to flashコマンドを実行。\r
*/\r
-unsigned long LPC17xx_IAP_copyRam2Flash(const void* i_flash_addr,const void* i_src_addr,unsigned long i_size,unsigned long i_clock_in_khz)\r
+unsigned long LPC17xx_IAP_copyRam2Flash(const void* i_flash_addr,const void* i_src_addr,unsigned long i_size)\r
{\r
unsigned long b[8];\r
unsigned long c[5];\r
c[1]=(unsigned long)i_flash_addr;\r
c[2]=(unsigned long)i_src_addr;\r
c[3]=i_size;\r
- c[4]=i_clock_in_khz;\r
+ c[4]=IPA_CPU_FREQ_IN_HZ/1000;\r
memcpy(b,(void*)0x10000000,32);\r
LPCXpresso_iap_entry(c,r);\r
memcpy((void*)0x10000000,b,32);\r
/**\r
* IAPのeraseコマンドを実行\r
*/\r
-unsigned long LPC17xx_IAP_erase(unsigned long i_start,unsigned long i_end,unsigned long i_clock_in_khz)\r
+unsigned long LPC17xx_IAP_erase(unsigned long i_start,unsigned long i_end)\r
{\r
unsigned long b[8];\r
unsigned long c[5];\r
c[0]=52;\r
c[1]=i_start;\r
c[2]=i_end;\r
- c[3]=i_clock_in_khz;\r
+ c[3]=IPA_CPU_FREQ_IN_HZ/1000;\r
memcpy(b,(void*)0x10000000,32);\r
LPCXpresso_iap_entry(c,r);\r
memcpy((void*)0x10000000,b,32);\r
\r
unsigned long LPC17xx_IAP_getSectorSize(unsigned int i_sector);\r
unsigned long LPC17xx_IAP_prepare(unsigned long i_start,unsigned long i_end);\r
-unsigned long LPC17xx_IAP_copyRam2Flash(const void* i_flash_addr,const void* i_src_addr,unsigned long i_size,unsigned long i_clock_in_khz);\r
-unsigned long LPC17xx_IAP_erase(unsigned long i_start,unsigned long i_end,unsigned long i_clock_in_khz);\r
+unsigned long LPC17xx_IAP_copyRam2Flash(const void* i_flash_addr,const void* i_src_addr,unsigned long i_size);\r
+unsigned long LPC17xx_IAP_erase(unsigned long i_start,unsigned long i_end);\r
\r
#ifdef __cplusplus\r
}\r
*/\r
NyLPC_TBool NyLPC_cMiMicConfiglation_updateConfigulation(const struct NyLPC_TMimicConfigulation* i_congfiglation)\r
{\r
- NyLPC_TcOnchipFlashWriter_t s;\r
const NyLPC_TUInt32* volatile fast_boot=&(factory_default.fast_boot);\r
- NyLPC_cOnchipFlashWriter_initialize(&s);\r
//イレース\r
- if(!NyLPC_cOnchipFlashWriter_elase(&s,MIMIC_CONFIGLATION_FLASH_SECTOR,MIMIC_CONFIGLATION_FLASH_SECTOR)){\r
+ if(!NyLPC_cOnchipFlashWriter_elase(MIMIC_CONFIGLATION_FLASH_SECTOR,MIMIC_CONFIGLATION_FLASH_SECTOR)){\r
NyLPC_OnErrorGoto(Error);\r
}\r
//コンフィギュレーションを書き込む。\r
- if(!NyLPC_cOnchipFlashWriter_writeSector(&s,MIMIC_CONFIGLATION_FLASH_SECTOR,0x00000000,i_congfiglation,sizeof(struct NyLPC_TMimicConfigulation))){\r
+ if(!NyLPC_cOnchipFlashWriter_writeSector(MIMIC_CONFIGLATION_FLASH_SECTOR,0x00000000,i_congfiglation,sizeof(struct NyLPC_TMimicConfigulation))){\r
NyLPC_OnErrorGoto(Error);\r
}\r
//プログラム済フラッシュの一部を書き換えてユーザコンフィギュレーションをONにする。\r
//フラグ値のアドレスが4バイトアライメントにあるFlashメモリか確認する。\r
if(((NyLPC_TUInt32)fast_boot)%4==0 && (!NyLPC_cOnchipFlashWriter_isOnchipFlash(fast_boot))){\r
//書き込み\r
- NyLPC_cOnchipFlashWriter_write(&s,fast_boot,&FAST_BOOT_DATA,4);\r
+ NyLPC_cOnchipFlashWriter_write(fast_boot,&FAST_BOOT_DATA,4);\r
}else{\r
NyLPC_OnErrorGoto(Error);\r
}\r
}\r
- NyLPC_cOnchipFlashWriter_finalize(&s);\r
return NyLPC_TBool_TRUE;\r
Error:\r
- NyLPC_cOnchipFlashWriter_finalize(&s);\r
return NyLPC_TBool_FALSE;\r
}\r
/**\r
#include "../driver/flash/LPC17xx_IAP.h"\r
#include "NyLPC_cOnchipFlashWriter.h"\r
\r
-void NyLPC_cOnchipFlashWriter_initialize(NyLPC_TcOnchipFlashWriter_t* i_inst)\r
-{\r
- (void)i_inst;\r
-}\r
+\r
/**\r
* 指定したアドレスが、オンチップフラッシュかどうか\r
*/\r
return LPC17xx_IAP_addr2Sector(i_addr,&snum)==LPC17xx_IAP_CMD_SUCCESS;\r
}\r
\r
-/**\r
- * アドレスi_destに、i_srcの内容を書き込みます。\r
- * 書き込みは、FlashROMがイレース済なものとして実行します。書込み範囲以外のデータは、変更されません。\r
- * 既に書込み済みのデータがある場合(0xFFFFFFFF以外)は、期待した結果が得られないので、注意してください。\r
- * この関数は、IAPインタフェイス経由で256バイト単位でデータを書き込みます。\r
- * IAPは0x1000000から32バイトをワークエリアとして使用します。\r
- * 関数はワークエリアの待避と復帰を行いますが、安全の為、使用前にRTOSを一旦停止させてください。\r
- */\r
-NyLPC_TBool NyLPC_cOnchipFlashWriter_write(NyLPC_TcOnchipFlashWriter_t* i_inst,const void* i_dest,const void* i_src,NyLPC_TUInt32 i_size)\r
+NyLPC_TUInt8 _work[256];\r
+\r
+\r
+NyLPC_TBool NyLPC_cOnchipFlashWriter_write(const void* i_dest,const void* i_src,NyLPC_TUInt32 i_size)\r
{\r
NyLPC_TUInt32 size;\r
- const void* src;\r
+ const char* src;\r
NyLPC_TUInt32 snum;\r
- const void* fblock_addr;\r
- const void* dest_addr;\r
+ const char* fblock_addr;\r
+ const char* dest_addr;\r
NyLPC_TUInt32 wsize;\r
NyLPC_TUInt16 s_padding;\r
NyLPC_TUInt16 free_size;\r
NyLPC_OnErrorGoto(Error);\r
}\r
size=i_size;\r
- src=i_src;\r
- dest_addr=i_dest;\r
+ src=(const char*)i_src;\r
+ dest_addr=(const char*)i_dest;\r
for(;size>0;){\r
//開始位置の端数を調べる\r
s_padding=((NyLPC_TUInt32)dest_addr)%256;\r
wsize=free_size>size?size:free_size;\r
//Flashから一時RAMへ前方パディングを読む\r
if(s_padding>0){\r
- memcpy(i_inst->_work,fblock_addr,s_padding);\r
+ memcpy(_work,fblock_addr,s_padding);\r
}\r
//書き込むデータを一時RAMへ書き込む\r
- memcpy(i_inst->_work+s_padding,src,wsize);\r
+ memcpy(_work+s_padding,src,wsize);\r
//後半\r
if(256-(wsize+s_padding)>0){\r
- memcpy(i_inst->_work+s_padding+wsize,fblock_addr+(wsize+s_padding),256-(wsize+s_padding));\r
+ memcpy(_work+s_padding+wsize,fblock_addr+(wsize+s_padding),256-(wsize+s_padding));\r
}\r
\r
//Flashへ書込み\r
NyLPC_OnErrorGoto(Error);\r
}\r
//IAPのwriteコマンド\r
- if(LPC17xx_IAP_CMD_SUCCESS!=LPC17xx_IAP_copyRam2Flash(fblock_addr,i_inst->_work,256,configCPU_CLOCK_HZ/1000)){\r
+ if(LPC17xx_IAP_CMD_SUCCESS!=LPC17xx_IAP_copyRam2Flash(fblock_addr,_work,256)){\r
NyLPC_OnErrorGoto(Error);\r
}\r
dest_addr+=wsize;\r
/**\r
* セクタ+オフセット形式で、データを書き込みます。\r
*/\r
-NyLPC_TBool NyLPC_cOnchipFlashWriter_writeSector(NyLPC_TcOnchipFlashWriter_t* i_inst,NyLPC_TUInt16 i_sector,NyLPC_TUInt32 i_offset,const void* i_src,NyLPC_TUInt32 i_size)\r
+NyLPC_TBool NyLPC_cOnchipFlashWriter_writeSector(NyLPC_TUInt16 i_sector,NyLPC_TUInt32 i_offset,const void* i_src,NyLPC_TUInt32 i_size)\r
{\r
void* addr;\r
if(!LPC17xx_IAP_sector2Addr(i_sector,&addr)){\r
return NyLPC_TBool_FALSE;\r
}\r
addr=(void*)((NyLPC_TUInt32)addr+i_offset);\r
- return NyLPC_cOnchipFlashWriter_write(i_inst,addr,i_src,i_size);\r
+ return NyLPC_cOnchipFlashWriter_write(addr,i_src,i_size);\r
\r
}\r
/**\r
* FlashRomのセクタ番号Nにイレースを実行します。\r
*/\r
-NyLPC_TBool NyLPC_cOnchipFlashWriter_elase(NyLPC_TcOnchipFlashWriter_t* i_inst,NyLPC_TUInt16 i_sector_s,NyLPC_TUInt16 i_sector_e)\r
+NyLPC_TBool NyLPC_cOnchipFlashWriter_elase(NyLPC_TUInt16 i_sector_s,NyLPC_TUInt16 i_sector_e)\r
{\r
- (void)i_inst;\r
if(LPC17xx_IAP_CMD_SUCCESS!=LPC17xx_IAP_prepare(i_sector_s,i_sector_e)){\r
return NyLPC_TBool_FALSE;\r
}\r
- if(LPC17xx_IAP_CMD_SUCCESS!=LPC17xx_IAP_erase(i_sector_s,i_sector_e,configCPU_CLOCK_HZ/1000)){\r
+ if(LPC17xx_IAP_CMD_SUCCESS!=LPC17xx_IAP_erase(i_sector_s,i_sector_e)){\r
return NyLPC_TBool_FALSE;\r
}\r
return NyLPC_TBool_TRUE;\r
extern "C" {\r
#endif /* __cplusplus */\r
\r
-typedef struct NyLPC_TcOnchipFlashWriter NyLPC_TcOnchipFlashWriter_t;\r
\r
-struct NyLPC_TcOnchipFlashWriter\r
-{\r
- NyLPC_TUInt8 _work[256];\r
-};\r
\r
-void NyLPC_cOnchipFlashWriter_initialize(NyLPC_TcOnchipFlashWriter_t* i_inst);\r
-\r
-#define NyLPC_cOnchipFlashWriter_finalize(i)\r
-\r
-NyLPC_TBool NyLPC_cOnchipFlashWriter_write(NyLPC_TcOnchipFlashWriter_t* i_inst,const void* i_dest,const void* i_src,NyLPC_TUInt32 i_size);\r
-NyLPC_TBool NyLPC_cOnchipFlashWriter_writeSector(NyLPC_TcOnchipFlashWriter_t* i_inst,NyLPC_TUInt16 i_sector,NyLPC_TUInt32 i_offset,const void* i_src,NyLPC_TUInt32 i_size);\r
-NyLPC_TBool NyLPC_cOnchipFlashWriter_elase(NyLPC_TcOnchipFlashWriter_t* i_inst,NyLPC_TUInt16 i_sector_s,NyLPC_TUInt16 i_sector_e);\r
+/**\r
+ * アドレスi_destに、i_srcの内容を書き込みます。\r
+ * 書き込みは、FlashROMがイレース済なものとして実行します。書込み範囲以外のデータは、変更されません。\r
+ * 既に書込み済みのデータがある場合(0xFFFFFFFF以外)は、期待した結果が得られないので、注意してください。\r
+ * この関数は、IAPインタフェイス経由で256バイト単位でデータを書き込みます。\r
+ * IAPは0x1000000から32バイトをワークエリアとして使用します。\r
+ * 関数はワークエリアの待避と復帰を行いますが、安全の為、使用前にRTOSを一旦停止させてください。\r
+ * この関数はリエントラントではありません。\r
+ */\r
+NyLPC_TBool NyLPC_cOnchipFlashWriter_write(const void* i_dest,const void* i_src,NyLPC_TUInt32 i_size);\r
+/**\r
+ * この関数はリエントラントではありません。\r
+ */\r
+NyLPC_TBool NyLPC_cOnchipFlashWriter_writeSector(NyLPC_TUInt16 i_sector,NyLPC_TUInt32 i_offset,const void* i_src,NyLPC_TUInt32 i_size);\r
+NyLPC_TBool NyLPC_cOnchipFlashWriter_elase(NyLPC_TUInt16 i_sector_s,NyLPC_TUInt16 i_sector_e);\r
NyLPC_TBool NyLPC_cOnchipFlashWriter_isOnchipFlash(const void* i_addr);\r
\r
\r
+++ /dev/null
-/*********************************************************************************\r
- * PROJECT: MiMic\r
- * --------------------------------------------------------------------------------\r
- *\r
- * This file is part of MiMic\r
- * Copyright (C)2011 Ryo Iizuka\r
- *\r
- * MiMic is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU Lesser General Public License as published\r
- * by the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- *\r
- * For further information please contact.\r
- * http://nyatla.jp/\r
- * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
- *\r
- *********************************************************************************/\r
-#include "NyLPC_cHttpShortRequestHeaderParser.h"\r
-\r
-static NyLPC_TBool message_handler(NyLPC_TcHttpBasicHeaderParser_t* i_inst,const NyLPC_TChar* i_name,NyLPC_TChar i_c,struct NyLPC_THttpBasicHeader* o_out)\r
-{\r
- (void)i_inst;\r
- (void)i_name;\r
- (void)i_c;\r
- return NyLPC_TBool_TRUE;\r
-}\r
-static NyLPC_TBool urlHandler(NyLPC_TcHttpBasicHeaderParser_t* i_inst,NyLPC_TChar i_c,struct NyLPC_THttpBasicHeader* o_out)\r
-{\r
- //32文字までのURL解析\r
- NyLPC_TcHttpShortRequestHeaderParser_t* inst=(NyLPC_TcHttpShortRequestHeaderParser_t*)i_inst;\r
- struct NyLPC_THttpShortRequestHeader* out=(struct NyLPC_THttpShortRequestHeader*)o_out;\r
- out->url[inst->url_len]=i_c;\r
- inst->url_len++;\r
- if(inst->url_len>=32){\r
- out->url[inst->url_len-1]='\0';\r
- return NyLPC_TBool_FALSE;\r
- }\r
- return NyLPC_TBool_TRUE;\r
-}\r
-/**\r
- * デフォルトハンドラ\r
- */\r
-static const struct NyLPC_TcHttpBasicHeaderParser_Handler _handler=\r
-{\r
- message_handler,\r
- urlHandler\r
-};\r
-\r
-\r
-\r
-\r
-void NyLPC_cHttpShortRequestHeaderParser_initialize(NyLPC_TcHttpShortRequestHeaderParser_t* i_inst)\r
-{\r
- NyLPC_cHttpBasicHeaderParser_initialize(&(i_inst->super),&_handler);\r
-}\r
-\r
-void NyLPC_cHttpShortRequestHeaderParser_parseInit(NyLPC_TcHttpShortRequestHeaderParser_t* i_inst,struct NyLPC_THttpShortRequestHeader* o_out)\r
-{\r
- i_inst->url_len=0;\r
- NyLPC_cHttpBasicHeaderParser_parseInit(&((i_inst)->super),&((o_out)->super));\r
-}\r
-\r
-NyLPC_TBool NyLPC_cHttpShortRequestHeaderParser_parse(NyLPC_TcHttpShortRequestHeaderParser_t* i_inst,NyLPC_TcHttpStream_t* i_stream,struct NyLPC_THttpShortRequestHeader* o_out)\r
-{\r
- NyLPC_cHttpShortRequestHeaderParser_parseInit(i_inst,o_out);\r
- if(!NyLPC_cHttpBasicHeaderParser_parseStream(&(i_inst->super),i_stream,&(o_out->super)))\r
- {\r
- return NyLPC_TBool_FALSE;\r
- }\r
- return NyLPC_cHttpBasicHeaderParser_parseFinish(&(i_inst->super),&(o_out->super));\r
-}\r
-\r
-\r
+++ /dev/null
-/*********************************************************************************\r
- * PROJECT: MiMic\r
- * --------------------------------------------------------------------------------\r
- *\r
- * This file is part of MiMic\r
- * Copyright (C)2011 Ryo Iizuka\r
- *\r
- * MiMic is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU Lesser General Public License as published\r
- * by the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- *\r
- * For further information please contact.\r
- * http://nyatla.jp/\r
- * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
- *\r
- *********************************************************************************/\r
-#ifndef NYLPC_CHTTPSHORTHTTPHEADERPARSER_H_\r
-#define NYLPC_CHTTPSHORTHTTPHEADERPARSER_H_\r
-#include "NyLPC_cHttpBasicHeaderParser.h"\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif /* __cplusplus */\r
-\r
-/**\r
- * URLが最大31文字までの、短いHttpリクエストを処理します。\r
- * このクラスは、NyLPC_TBasicHttpHeader_tにキャストできます。\r
- */\r
-typedef struct NyLPC_TcHttpShortReqestHeaderParser NyLPC_TcHttpShortRequestHeaderParser_t;\r
-\r
-\r
-struct NyLPC_THttpShortRequestHeader\r
-{\r
- struct NyLPC_THttpBasicHeader super;\r
- NyLPC_TChar url[32];\r
-};\r
-\r
-struct NyLPC_TcHttpShortReqestHeaderParser{\r
- NyLPC_TcHttpBasicHeaderParser_t super;\r
- NyLPC_TUInt16 url_len;\r
-};\r
-\r
-void NyLPC_cHttpShortRequestHeaderParser_initialize(NyLPC_TcHttpShortRequestHeaderParser_t* i_inst);\r
-\r
-#define NyLPC_cHttpShortRequestHeaderParser_finalize(i_inst) NyLPC_cHttpBasicHeaderParser_finalize(i_inst);\r
-\r
-/**\r
- * parseInit,parseStream,parseFinishを一括で実行します。\r
- */\r
-NyLPC_TBool NyLPC_cHttpShortRequestHeaderParser_parse(NyLPC_TcHttpShortRequestHeaderParser_t* i_inst,NyLPC_TcHttpStream_t* i_stream,struct NyLPC_THttpShortRequestHeader* o_out);\r
-\r
-\r
-/** override\r
- */\r
-void NyLPC_cHttpShortRequestHeaderParser_parseInit(NyLPC_TcHttpShortRequestHeaderParser_t* i_inst,struct NyLPC_THttpShortRequestHeader* o_out);\r
-\r
-\r
-/** override\r
- */\r
-#define NyLPC_cHttpShortRequestHeaderParser_parseFinish(i_inst,o_out) NyLPC_cHttpBasicHeaderParser_parseFinish(&((i_inst)->super),&((o_out)->super))\r
-\r
-/** override\r
- */\r
-#define NyLPC_cHttpShortRequestHeaderParser_parseChar(i_inst,i_c,i_size,o_out) NyLPC_cHttpBasicHeaderParser_parseChar(&((i_inst)->super),i_c,i_size,&((o_out)->super));\r
-\r
-/** override\r
- */\r
-#define NyLPC_cHttpShortRequestHeaderParser_parseStream(i_inst,i_stream,o_out) NyLPC_cHttpBasicHeaderParser_parseStream(&((i_inst)->super),i_stream,&((o_out)->super))\r
-\r
-\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif /* __cplusplus */\r
-\r
-#endif /* NYLPC_CHTTPSHORTHTTPHEADERPARSER_H_ */\r
#include "../http/NyLPC_cHttpdConfig.h"\r
#include "../http/NyLPC_cHttpHeaderWriter.h"\r
#include "../http/NyLPC_cHttpBodyWriter.h"\r
-#include "../http/NyLPC_cHttpShortRequestHeaderParser.h"\r
#include "../http/NyLPC_cHttpBasicHeaderParser.h"\r
#include "../http/NyLPC_cHttpStream.h"\r
-\r
+#include "../http/NyLPC_cHttpNullRequestHeaderParser.h"\r
\r
#ifdef __cplusplus\r
extern "C" {\r
* ネットワークを初期化する。\r
*/\r
void NyLPC_cNet_initialize(NyLPC_TcNet_t* i_inst);\r
+\r
+#define NyLPC_cNet_finalize(inst)\r
/**\r
* 関数は、ネットワークアダプタの値を元にNyLPC_cMiMicEnv_PlatformName変数の値を更新します。\r
* @param i_ref_config\r
*\r
*********************************************************************************/\r
#include "NyLPC_cHttpRequestPrefixParser.h"\r
-#include "../http/NyLPC_cHttpBasicHeaderParser_protected.h"\r
-\r
\r
\r
\r
struct NyLPC_TcHttpd\r
{\r
struct{\r
- NyLPC_TcHttpd_onRequest _handler;\r
+ NyLPC_TcHttpd_onRequest onRequest;\r
}function;\r
NyLPC_TcMutex_t _mutex;\r
NyLPC_TcTcpListener_t _listener;\r
#include "NyLPC_cHttpdConnection_protected.h"\r
-#include "../http/NyLPC_cHttpNullRequestHeaderParser.h"\r
+#include "NyLPC_http.h"\r
#include "./mod/NyLPC_cHttpModUtils_protected.h"\r
#include "./NyLPC_cHttpd_protected.h"\r
\r
\r
#ifndef NYLPC_CHTTPDCONNECTION_PROTECTED_H_\r
#define NYLPC_CHTTPDCONNECTION_PROTECTED_H_\r
-#include "../../uip/NyLPC_cTcpListener.h"\r
+#include "NyLPC_uipService.h"\r
#include "NyLPC_cHttpdConnection.h"\r
#include "NyLPC_stdlib.h"\r
+#include "./mod/NyLPC_cHttpModUtils_protected.h"\r
/**\r
* コネクションモード\r
*/\r
NyLPC_cHttpdConnection_setConnectionMode(inst,NyLPC_TcHttpdConnection_CONNECTION_MODE_CLOSE);\r
\r
{//handler\r
- (inst->_parent_httpd->function._handler)(inst);\r
+ (inst->_parent_httpd->function.onRequest)(inst);\r
}\r
//コネクションが増えすぎたら持続性接続を停止するためにCLOSEDにする。\r
if(NyLPC_cHttpd_getNumOfConnection(inst->_parent_httpd)>LIMIT_OF_PERSISTENT_CONNECTION){\r
* Created on: 2013/03/05\r
* Author: nyatla\r
*/\r
-#include "NyLPC_cHttpmodUtils_protected.h"\r
+#include "NyLPC_cHttpModUtils_protected.h"\r
\r
const char* NyLPC_cHttpdModUtils_getMethodPrefix(NyLPC_THttpMethodType i_method)\r
{\r
*********************************************************************************/\r
#include "NyLPC_cModMiMicSetting.h"\r
#include "NyLPC_stdlib.h"\r
-#include "NyLPC_cHttpmodUtils_protected.h"\r
+#include "NyLPC_cHttpModUtils_protected.h"\r
#include "NyLPC_http.h"\r
-#include "NyLPC_mimicvm.h"\r
+#include "NyLPC_mimicVm.h"\r
#include "NyLPC_flash.h"\r
#include "../NyLPC_cHttpdConnection_protected.h"\r
#include "../../NyLPC_cNet.h"\r
#include "NyLPC_cModRemoteMcu.h"\r
#include "NyLPC_stdlib.h"\r
#include "NyLPC_http.h"\r
-#include "NyLPC_mimicvm.h"\r
+#include "NyLPC_mimicVm.h"\r
#include "../NyLPC_cHttpdConnection_protected.h"\r
#include "NyLPC_cHttpmodUtils_protected.h"\r
#include "NyLPC_net.h"\r
if(!NyLPC_cHttpBasicHeaderParser_parseFinish(&parser,&(header->super))){\r
NyLPC_OnErrorGoto(Error2);\r
}\r
- NyLPC_cHttpShortRequestHeaderParser_finalize(&parser);\r
+ NyLPC_cHttpBasicHeaderParser_finalize(&parser);\r
return 200;\r
Error2:\r
//BadRequest\r
+++ /dev/null
-/*********************************************************************************\r
- * PROJECT: MiMic\r
- * --------------------------------------------------------------------------------\r
- *\r
- * This file is part of MiMic\r
- * Copyright (C)2011 Ryo Iizuka\r
- *\r
- * MiMic is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU Lesser General Public License as published\r
- * by the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- *\r
- * For further information please contact.\r
- * http://nyatla.jp/\r
- * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
- *\r
- *********************************************************************************/\r
-#include "NyLPC_cModShortUrl.h"\r
-#include "NyLPC_stdlib.h"\r
-#include "NyLPC_http.h"\r
-#include "NyLPC_cHttpModUtils_protected.h"\r
-#include "../NyLPC_cHttpdConnection_protected.h"\r
-\r
-void NyLPC_cModShortUrl_initialize(NyLPC_TcModShortUrl_t* i_inst)\r
-{\r
-\r
-}\r
-void NyLPC_cModShortUrl_finalize(NyLPC_TcModShortUrl_t* i_inst)\r
-{\r
-\r
-}\r
-\r
-const struct NyLPC_THttpBasicHeader* NyLPC_cModShortUrl_getHeader(const NyLPC_TcModShortUrl_t* i_inst)\r
-{\r
- return &(i_inst->_header.super);\r
-}\r
-const NyLPC_TChar* NyLPC_cModShortUrl_getPath(const NyLPC_TcModShortUrl_t* i_inst)\r
-{\r
- return i_inst->_header.url;\r
-}\r
-\r
-NyLPC_TBool NyLPC_cModShortUrl_isEqualPath(const NyLPC_TcModShortUrl_t* i_inst,const NyLPC_TChar* i_path)\r
-{\r
- return strcmp(i_inst->_header.url,i_path)==0;\r
-}\r
-/**\r
- * Methodタイプを返します。\r
- */\r
-NyLPC_THttpMethodType NyLPC_cModShortUrl_getMethod(const NyLPC_TcModShortUrl_t* i_inst)\r
-{\r
- return i_inst->_header.super.startline.req.method;\r
-}\r
-\r
-\r
-\r
-\r
-NyLPC_TBool NyLPC_cModShortUrl_execute(NyLPC_TcModShortUrl_t* i_inst,NyLPC_TcHttpdConnection_t* i_connection)\r
-{\r
- NyLPC_TcHttpShortRequestHeaderParser_t parser;\r
- if(!NyLPC_cHttpdConnection_getReqStatus(i_connection)==NyLPC_cHttpdConnection_ReqStatus_REQPARSE)\r
- {\r
- NyLPC_OnErrorGoto(Error1);\r
- }\r
- //リクエストParse済へ遷移\r
- NyLPC_cHttpdConnection_setReqStatusParsed(i_connection);\r
-\r
- NyLPC_cHttpShortRequestHeaderParser_initialize(&parser);\r
- //プリフェッチしたデータを流す\r
- NyLPC_cHttpShortRequestHeaderParser_parseInit(&parser,&(i_inst->_header));\r
- NyLPC_cHttpdConnection_pushPrefetchInfo(i_connection,&parser.super,&(i_inst->_header.super));\r
- //後続をストリームから取り込む\r
- if(!NyLPC_cHttpShortRequestHeaderParser_parseStream(&parser,NyLPC_cHttpdConnection_refStream(i_connection),&(i_inst->_header))){\r
- NyLPC_OnErrorGoto(Error2);\r
- }\r
- if(!NyLPC_cHttpShortRequestHeaderParser_parseFinish(&parser,&(i_inst->_header))){\r
- NyLPC_OnErrorGoto(Error2);\r
- }\r
- //Connection Modeの設定 1.1 && !closeの場合はCONTINUE\r
- if(i_inst->_header.super.connection!=NyLPC_THttpMessgeHeader_Connection_CLOSE && i_inst->_header.super.startline.req.version==NyLPC_THttpVersion_11)\r
- {\r
- NyLPC_cHttpdConnection_setConnectionMode(i_connection,NyLPC_TcHttpdConnection_CONNECTION_MODE_CONTINUE);\r
- }\r
- NyLPC_cHttpShortRequestHeaderParser_finalize(&parser);\r
- return NyLPC_TBool_TRUE;\r
-Error2:\r
- //400Error\r
- NyLPC_cHttpdConnection_sendResponseHeader2(i_connection,400,"text/html",0,NULL);\r
- NyLPC_cHttpShortRequestHeaderParser_finalize(&parser);\r
-Error1:\r
- return NyLPC_TBool_FALSE;\r
-}\r
-\r
-\r
-\r
--- /dev/null
+/*********************************************************************************\r
+ * PROJECT: MiMic\r
+ * --------------------------------------------------------------------------------\r
+ *\r
+ * This file is part of MiMic\r
+ * Copyright (C)2011 Ryo Iizuka\r
+ *\r
+ * MiMic is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU Lesser General Public License as published\r
+ * by the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Lesser General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+ *\r
+ * For further information please contact.\r
+ * http://nyatla.jp/\r
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
+ *\r
+ *********************************************************************************/\r
+#include "NyLPC_cModUrl.h"\r
+#include "NyLPC_stdlib.h"\r
+#include "NyLPC_http.h"\r
+#include "NyLPC_cHttpModUtils_protected.h"\r
+#include "../NyLPC_cHttpdConnection_protected.h"\r
+\r
+typedef struct TcHeaderParser\r
+{\r
+ NyLPC_TcHttpBasicHeaderParser_t super;\r
+ char* url_buf;\r
+ NyLPC_TUInt16 length_of_buf;\r
+ NyLPC_TUInt16 length_of_url;\r
+}TcHeaderParser_t;\r
+\r
+static NyLPC_TBool NyLPC_cModUrl_messageHandler(NyLPC_TcHttpBasicHeaderParser_t* i_inst,const NyLPC_TChar* i_name,NyLPC_TChar i_c,struct NyLPC_THttpBasicHeader* o_out)\r
+{\r
+ (void)i_inst;\r
+ (void)i_name;\r
+ (void)i_c;\r
+ return NyLPC_TBool_TRUE;\r
+}\r
+static NyLPC_TBool NyLPC_cModUrl_urlHandler(NyLPC_TcHttpBasicHeaderParser_t* i_inst,NyLPC_TChar i_c,struct NyLPC_THttpBasicHeader* o_out)\r
+{\r
+ TcHeaderParser_t* inst=(TcHeaderParser_t*)i_inst;\r
+ inst->url_buf[inst->length_of_url]=i_c;\r
+ inst->length_of_url++;\r
+ if(i_c=='\0'){\r
+ return NyLPC_TBool_TRUE;//Terminate\r
+ }\r
+ if(inst->length_of_url==inst->length_of_buf){\r
+ return NyLPC_TBool_FALSE;//長すぎる。\r
+ }\r
+ return NyLPC_TBool_TRUE;\r
+}\r
+/**\r
+ * デフォルトハンドラ\r
+ */\r
+static const struct NyLPC_TcHttpBasicHeaderParser_Handler _handler=\r
+{\r
+ NyLPC_cModUrl_messageHandler,\r
+ NyLPC_cModUrl_urlHandler\r
+};\r
+\r
+\r
+\r
+void NyLPC_cModUrl_initialize(NyLPC_TcModUrl_t* i_inst)\r
+{\r
+\r
+}\r
+void NyLPC_cModUrl_finalize(NyLPC_TcModUrl_t* i_inst)\r
+{\r
+\r
+}\r
+\r
+const struct NyLPC_THttpBasicHeader* NyLPC_cModUrl_getHeader(const NyLPC_TcModUrl_t* i_inst)\r
+{\r
+ return &(i_inst->_header);\r
+}\r
+\r
+/**\r
+ * Methodタイプを返します。\r
+ */\r
+NyLPC_THttpMethodType NyLPC_cModUrl_getMethod(const NyLPC_TcModUrl_t* i_inst)\r
+{\r
+ return i_inst->_header.startline.req.method;\r
+}\r
+\r
+\r
+\r
+\r
+NyLPC_TBool NyLPC_cModUrl_execute(NyLPC_TcModUrl_t* i_inst,NyLPC_TcHttpdConnection_t* i_connection,char* o_url_buf,int i_length_buf)\r
+{\r
+ TcHeaderParser_t parser;\r
+ if(!NyLPC_cHttpdConnection_getReqStatus(i_connection)==NyLPC_cHttpdConnection_ReqStatus_REQPARSE)\r
+ {\r
+ NyLPC_OnErrorGoto(Error1);\r
+ }\r
+ //リクエストParse済へ遷移\r
+ NyLPC_cHttpdConnection_setReqStatusParsed(i_connection);\r
+\r
+ NyLPC_cHttpBasicHeaderParser_initialize(&parser.super,&_handler);\r
+ parser.length_of_buf=i_length_buf;\r
+ parser.length_of_url=0;\r
+ parser.url_buf=o_url_buf;\r
+ //プリフェッチしたデータを流す\r
+ NyLPC_cHttpBasicHeaderParser_parseInit(&parser.super,&(i_inst->_header));\r
+ NyLPC_cHttpdConnection_pushPrefetchInfo(i_connection,&parser.super,&(i_inst->_header));\r
+ //後続をストリームから取り込む\r
+ if(!NyLPC_cHttpBasicHeaderParser_parseStream(&parser.super,NyLPC_cHttpdConnection_refStream(i_connection),&(i_inst->_header))){\r
+ NyLPC_OnErrorGoto(Error2);\r
+ }\r
+ if(!NyLPC_cHttpBasicHeaderParser_parseFinish(&parser.super,&(i_inst->_header))){\r
+ NyLPC_OnErrorGoto(Error2);\r
+ }\r
+ //Connection Modeの設定 1.1 && !closeの場合はCONTINUE\r
+ if(i_inst->_header.connection!=NyLPC_THttpMessgeHeader_Connection_CLOSE && i_inst->_header.startline.req.version==NyLPC_THttpVersion_11)\r
+ {\r
+ NyLPC_cHttpdConnection_setConnectionMode(i_connection,NyLPC_TcHttpdConnection_CONNECTION_MODE_CONTINUE);\r
+ }\r
+ NyLPC_cHttpBasicHeaderParser_finalize(&parser);\r
+ return NyLPC_TBool_TRUE;\r
+Error2:\r
+ //400Error\r
+ NyLPC_cHttpdConnection_sendResponseHeader2(i_connection,400,"text/html",0,NULL);\r
+ NyLPC_cHttpBasicHeaderParser_finalize(&parser);\r
+Error1:\r
+ return NyLPC_TBool_FALSE;\r
+}\r
+\r
+\r
+\r
* <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
*\r
*********************************************************************************/\r
-#ifndef NYLPC_CMODSHORTURL_H_\r
-#define NYLPC_CMODSHORTURL_H_\r
+#ifndef NYLPC_CMODURL_H_\r
+#define NYLPC_CMODURL_H_\r
+\r
#include "NyLPC_http.h"\r
#include "../NyLPC_cHttpdConnection.h"\r
#ifdef __cplusplus\r
#endif /* __cplusplus */\r
\r
/**\r
- * URLã\81\8cæ\9c\80大31æ\96\87å\97ã\81¾ã\81§ã\81®ã\80\81ç\9fã\81\84Httpã\83ªã\82¯ã\82¨ã\82¹ã\83\88ã\82\92å\87¦ç\90\86ã\81\97ã\81¦ã\80\81ã\83ªã\82¯ã\82¨ã\82¹ã\83\88å\86\85容ã\82\92å\8f\96å¾\97ã\81\97ã\81¾ã\81\99ã\80\82\r
+ * URLã\82\92\r
*/\r
-typedef struct NyLPC_TcModShortUrl NyLPC_TcModShortUrl_t;\r
+typedef struct NyLPC_TcModUrl NyLPC_TcModUrl_t;\r
\r
\r
-struct NyLPC_TcModShortUrl\r
+struct NyLPC_TcModUrl\r
{\r
- struct NyLPC_THttpShortRequestHeader _header;\r
+ struct NyLPC_THttpBasicHeader _header;\r
};\r
\r
/**\r
* コンストラクタ。\r
*/\r
-void NyLPC_cModShortUrl_initialize(NyLPC_TcModShortUrl_t* i_inst);\r
-void NyLPC_cModShortUrl_finalize(NyLPC_TcModShortUrl_t* i_inst);\r
+void NyLPC_cModUrl_initialize(NyLPC_TcModUrl_t* i_inst);\r
+void NyLPC_cModUrl_finalize(NyLPC_TcModUrl_t* i_inst);\r
\r
/**\r
- * ShortURLのパースを実行して、コネクションの返却準備をします。\r
+ * 。\r
*/\r
-NyLPC_TBool NyLPC_cModShortUrl_execute(NyLPC_TcModShortUrl_t* i_inst,NyLPC_TcHttpdConnection_t* i_connection);\r
+NyLPC_TBool NyLPC_cModUrl_execute(NyLPC_TcModUrl_t* i_inst,NyLPC_TcHttpdConnection_t* i_connection,char* o_url_buf,int i_length_buf);\r
\r
/**\r
* basicヘッダオブジェクトを返します。\r
*/\r
-const struct NyLPC_THttpBasicHeader* NyLPC_cModShortUrl_getHeader(const NyLPC_TcModShortUrl_t* i_inst);\r
-/**\r
- * URLを返します。URL長は最大32文字です。\r
- */\r
-const NyLPC_TChar* NyLPC_cModShortUrl_getPath(const NyLPC_TcModShortUrl_t* i_inst);\r
-/**\r
- * URLが一致しているかを返します。\r
- */\r
-NyLPC_TBool NyLPC_cModShortUrl_isEqualPath(const NyLPC_TcModShortUrl_t* i_inst,const NyLPC_TChar* i_path);\r
+const struct NyLPC_THttpBasicHeader* NyLPC_cModUrl_getHeader(const NyLPC_TcModUrl_t* i_inst);\r
\r
/**\r
* Methodタイプを返します。\r
*/\r
-NyLPC_THttpMethodType NyLPC_cModShortUrl_getMethod(const NyLPC_TcModShortUrl_t* i_inst);\r
+NyLPC_THttpMethodType NyLPC_cModUrl_getMethod(const NyLPC_TcModUrl_t* i_inst);\r
\r
\r
\r
}\r
#endif /* __cplusplus */\r
\r
-#endif /* NYLPC_CHTTPSHORTHTTPHEADERPARSER_H_ */\r
+\r
+\r
+\r
+#endif /* NYLPC_CMODURL_H_ */\r
i_inst->payload.tcp->tcpchksum=~(NyLPC_TIPv4Header_makeTcpChecksum(i_inst->header));\r
i_inst->header->ipchksum = ~(NyLPC_TIPv4Header_makeIpChecksum(i_inst->header));\r
}\r
-\r
+/* なんだっけっこれ?\r
//1の補数v1にv2を加算する。\r
static NyLPC_TUInt16 add16c(NyLPC_TUInt16 i_v1,NyLPC_TUInt16 i_v2)\r
{\r
t=i_v1-i_v2;\r
return (t<i_v1)?t:t-1;\r
}\r
+*/\r
/**\r
* o_instに、同一なバッファを参照するインスタンスを生成します。\r
*/\r
o_inst->header=i_inst->header;\r
o_inst->payload=i_inst->payload;\r
}\r
-static void* logA;\r
-static void* logB;\r
+\r
/**\r
* ACK番号を更新する。\r
* @param i_ackno\r
NyLPC_TUInt32 i_ackno)\r
{\r
NyLPC_Assert(i_inst->header!=NULL);\r
- logA=i_inst->header;\r
- logB=i_inst->payload.tcp;\r
+\r
\r
/* union{\r
NyLPC_TUInt32 l;\r