[syslinux] Sending UDP packets from comboot

Stefan Thomanek stefan at thomanek.eu
Sun May 24 13:59:58 PDT 2009


H. Peter Anvin schrieb:
> Stefan Thomanek wrote:
>   
>> Hi everyone.
>>
>> I've read through the archives and found a few posts about using the PXE
>> stack, but none of these really helped me.
>> What i want to do is: Prompt the user for 2 values, desired hostname and
>> a "pin" (just a number) and send this information
>> over UDP to my server
>> The problem is not the user input but the UDP part.
>>
>> I've tried to change the code from the post of jesse barker (6.1.2007):
>>
>> // code start
>> s_PXENV_UDP_WRITE args;
>>
>> memset(&args, 0, sizeof(args));
>>
>> args.ip = inet_addr("255.255.255.255"); // inet_addr working here?
>>     
>
> Yes, that should be an inet address.
>
>   
>> args.gw = inet_addr("0.0.0.0");
>> args.src_port = 4711;
>>     
>
> For what it's worth, Syslinux itself uses port numbers between 49152 and
> 57343.
>
>   
>> args.dst_port = 4799;
>> args.buffer_size = <some sizeof() code>
>> args.buffer = <some stuff to put my data in>
>>     
>
> For the buffer you have to be a bit careful... the buffer is in 16-bit
> segment-offset format, so you need to copy your data into the bounce
> buffer, and then use SEG() and OFFS() to generate pointers to the data.
>
>   
>> memcpy(__com32.cs_bounce, &args, sizeof(args);
>>
>> inputRegs.es  = SEG(__com32.cs_bounce);
>> inputRegs.edi.w[0] = OFFS(__com32.cs_bounce);
>> inputRegs.eax.w[0] = 0x0009; /* call PXE stack */
>> inputRegs.ebx.w[0] = 0x0033; /* PXENV_UDP_WRITE opcode */
>>
>> __intcall(0x22, &inputRegs, NULL);
>> // code end
>>
>> Could anyone give me a hand on that?
>> Or is there any example already where a UDP write is used?
>>
>>     
>
> What is it you're having problems with?  What you have above seems
> reasonably complete.
>
>   
Well the problem i have is, that i've never done anything assembler-like 
yet.
To be honest, i have *no* idea about it at all. (esx, es, seg, off, huh?)

So my idea was to find a piece of code in the archives where someone 
calls anything in the pxe stack from C,
alter it with the help of the PXE2.1 spec pdf, send it to this mailing 
list and wait for either a positive or negative
comment. Now that this answer is positive, i have a basic piece of code 
to start playing trial and error.

Thanks again for the help, i'll submit the working source code once it 
IS working.

-Stefan




More information about the Syslinux mailing list