16 unsigned char* opt_tmp;
19 eom = (
unsigned char*)dmsg + dmsg_size - 1;
20 opt_tmp = (
unsigned char*)dmsg->
dc_opt;
22 while(opt_tmp < eom) {
26 if((*opt_tmp) == option_key) {
30 return (
char*)(opt_tmp+2);
33 opt_tmp += *(
uint8*)opt_tmp + 1;
80 dmsg->
dc_opt[j++] = 0xff & 53;
81 dmsg->
dc_opt[j++] = 0xff & 1;
82 dmsg->
dc_opt[j++] = 0xff & 1;
83 dmsg->
dc_opt[j++] = 0xff & 0;
85 dmsg->
dc_opt[j++] = 0xff & 55;
86 dmsg->
dc_opt[j++] = 0xff & 2;
87 dmsg->
dc_opt[j++] = 0xff & 1;
88 dmsg->
dc_opt[j++] = 0xff & 3;
91 return (
uint32)((
char *)&dmsg->
dc_opt[j] - (
char *)dmsg + 1);
100 const struct dhcpmsg* dmsg_offer,
110 dmsg->
dc_opt[j++] = 0xff & 53;
111 dmsg->
dc_opt[j++] = 0xff & 1;
112 dmsg->
dc_opt[j++] = 0xff & 3;
113 dmsg->
dc_opt[j++] = 0xff & 0;
115 dmsg->
dc_opt[j++] = 0xff & 50;
116 dmsg->
dc_opt[j++] = 0xff & 4;
125 kprintf(
"Unable to get server IP add. from DHCP Offer\n");
129 dmsg->
dc_opt[j++] = 0xff & 54;
130 dmsg->
dc_opt[j++] = 0xff & 4;
135 return (
uint32)((
char *)&dmsg->
dc_opt[j] - (
char *)dmsg + 1);
163 kprintf(
"getlocalip: cannot register with UDP\n");
169 kprintf(
"getlocalip: Unable to build DHCP discover\n");
175 (
char *)&dmsg_snd, len);
181 for (j=0; j<3; j++) {
182 inlen =
udp_recv(slot, (
char *)&dmsg_rvc,
186 }
else if (inlen ==
SYSERR) {
192 if (dmsg_rvc.dc_xid != dmsg_snd.dc_xid) {
196 eop = (
char *)&dmsg_rvc + inlen - 1;
197 optptr = (
char *)&dmsg_rvc.dc_opt;
198 msgtype = addrmask = routeraddr = dnsaddr = ntpaddr = 0;
200 while (optptr < eop) {
204 msgtype = 0xff & *(optptr+2);
208 memcpy((
void *)&tmp, optptr+2, 4);
209 addrmask =
ntohl(tmp);
213 memcpy((
void *)&tmp, optptr+2, 4);
214 routeraddr =
ntohl(tmp);
218 memcpy((
void *)&tmp, optptr+2, 4);
219 dnsaddr =
ntohl(tmp);
223 memcpy((
void *)&tmp, optptr+2, 4);
224 ntpaddr =
ntohl(tmp);
229 optptr += (0xff & *optptr) + 1;
232 if (msgtype == 0x02) {
236 "Unable to build DHCP request");
240 (
char *)&dmsg_snd, len);
243 }
else if (dmsg_rvc.dc_opt[2] != 0x05) {
250 if (routeraddr != 0) {
267 if (
dot2ip((
char*)dmsg_rvc.sname,
274 memcpy((
char *)&tmp, tmp_server_ip, 4);
278 sizeof(dmsg_rvc.bootfile));
283 kprintf(
"DHCP failed to get a response\n");
syscall kprintf(char *fmt,...)
ポーリングI/Oを使用して、フォーマットされた文字列をコンソールに出力する。
#define NULL
連結リスト用のNULLポインタ
int32 udp_recv(uid32, char *, int32, uint32)
#define IP_BCAST
IPローカルブロードキャストアドレス。
char bootfile[NETBOOTFILE]
unsigned char uint8
符号なし8ビット値(unsigned char)
int32 dhcp_bld_req(struct dhcpmsg *dmsg, const struct dhcpmsg *dmsg_offer, uint32 dsmg_offer_size)
#define TIMEOUT
システムコールがタイムアウトした場合
byte ethucast[ETH_ADDR_LEN]
void dhcp_bld_bootp_msg(struct dhcpmsg *dmsg)
#define TRUE
Boolean True(1)
int int32
符号あり32ビット整数(int)
uid32 udp_register(uint32, uint16, uint16)
void * memset(void *, const int, int32)
指定のByteブロックに対して、同じ値をNバイト分書き込む。
status udp_release(uid32)
int32 dhcp_bld_disc(struct dhcpmsg *dmsg)
status udp_sendto(uid32, uint32, uint16, char *, int32)
char * dhcp_get_opt_val(const struct dhcpmsg *dmsg, uint32 dmsg_size, uint8 option_key)
unsigned int uint32
符号なし32ビット整数(unsigned int)
uint32 dot2ip(char *, uint32 *)
void * memcpy(void *, const void *, int32)
メモリAの領域(source)からメモリBの領域(Destination)にN Byteコピーする。