app-misc/irtrans-irclient: add ip_assign

git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/linamh@445 6952d904-891a-0410-993b-d76249ca496b
This commit is contained in:
geos_one 2008-08-06 20:47:08 +00:00
parent 1a05fae75f
commit 7daf23b5a4
4 changed files with 688 additions and 6 deletions

View File

@ -2,6 +2,11 @@
# Copyright 1999-2008 Gentoo Foundation; Distributed under the GPL v2 # Copyright 1999-2008 Gentoo Foundation; Distributed under the GPL v2
# $Header: $ # $Header: $
06 Aug 2008; Mario Fetka <mario.fetka@gmail.com>
+files/irclient-5.11.04-ip_assign-1.patch,
irtrans-irclient-5.11.04.ebuild:
add ip_assign
02 Aug 2008; Mario Fetka <mario.fetka@gmail.com> ++, 02 Aug 2008; Mario Fetka <mario.fetka@gmail.com> ++,
-irtrans-irclient-5.11.08.ebuild, -irtrans-irclient-5.11.10.ebuild: -irtrans-irclient-5.11.08.ebuild, -irtrans-irclient-5.11.10.ebuild:
Drop old Drop old

View File

@ -1,11 +1,12 @@
AUX irclient-5.11.04-ip_assign-1.patch 16659 RMD160 966bb00cb17ab61156509848d6ab22735a083def SHA1 43097f77796360d3c3a459df1ac93a4f7026e17e SHA256 a2042618e026f1f5dff8ab0566d2dc1e0f8626e9ba7ff26afc56b358b317dbd9
AUX irtrans-irclient-5.9.01-missing-include.diff 363 RMD160 fff180d91331e6a0b1939e320a5ee7854bae2de6 SHA1 6a0b103619a802ceb541cee15d8436ac32e995b0 SHA256 48753faa1661c2519dc55fcb95da93319e36cebdc5ea48ece4f633b36fdcc288 AUX irtrans-irclient-5.9.01-missing-include.diff 363 RMD160 fff180d91331e6a0b1939e320a5ee7854bae2de6 SHA1 6a0b103619a802ceb541cee15d8436ac32e995b0 SHA256 48753faa1661c2519dc55fcb95da93319e36cebdc5ea48ece4f633b36fdcc288
AUX irtrans-irclient-5.9.04-missing-include.diff 363 RMD160 6cd48a93958f35454d17aaedce43bc1d95ad2cb6 SHA1 2a6a4230c1a2c754c0ffc29c4aabe727897cc054 SHA256 e74521300f5a6795232fa6465226cc0c261305eb2ea55f944f3911dd1e958d4d AUX irtrans-irclient-5.9.04-missing-include.diff 363 RMD160 6cd48a93958f35454d17aaedce43bc1d95ad2cb6 SHA1 2a6a4230c1a2c754c0ffc29c4aabe727897cc054 SHA256 e74521300f5a6795232fa6465226cc0c261305eb2ea55f944f3911dd1e958d4d
DIST irclient-src-5.11.04.tar.gz 44123 RMD160 d756a3655b82085430e26e194271ddc1504e2844 SHA1 e8b9bcaa74bcbc01ed92552d77e9902c01b7ff16 SHA256 9e31bbdfdfd883e91c15b50c1916b93c8db680ad07a4e48006afe8e2ad8de4f9 DIST irclient-src-5.11.04.tar.gz 44123 RMD160 d756a3655b82085430e26e194271ddc1504e2844 SHA1 e8b9bcaa74bcbc01ed92552d77e9902c01b7ff16 SHA256 9e31bbdfdfd883e91c15b50c1916b93c8db680ad07a4e48006afe8e2ad8de4f9
DIST irserver-src-5.9.04.tar.gz 143574 RMD160 acea7223dea66d8be97e716d0a1aa2f128f98176 SHA1 d3f6687785bab24abb5cd5019ef5d6892ced7b1f SHA256 9f3877d6c8fcc67b5198bb05c2ffab24116121c09124f744eb9d795e925485a9 DIST irserver-src-5.9.04.tar.gz 143574 RMD160 acea7223dea66d8be97e716d0a1aa2f128f98176 SHA1 d3f6687785bab24abb5cd5019ef5d6892ced7b1f SHA256 9f3877d6c8fcc67b5198bb05c2ffab24116121c09124f744eb9d795e925485a9
DIST irserver-src-5.9.07.tar.gz 143809 RMD160 747eeb70f5f869f689517250bcfd75fe0af1d924 SHA1 49210d5adebba6852439cfb4e640434303b0a83f SHA256 2416be01cc7f2bc32fc71407d503c1c285987d32e0dab905921c639d2fd79702 DIST irserver-src-5.9.07.tar.gz 143809 RMD160 747eeb70f5f869f689517250bcfd75fe0af1d924 SHA1 49210d5adebba6852439cfb4e640434303b0a83f SHA256 2416be01cc7f2bc32fc71407d503c1c285987d32e0dab905921c639d2fd79702
EBUILD irtrans-irclient-5.11.04.ebuild 1053 RMD160 081f12efa0ee1eb9ee64ed61fe098952456174ac SHA1 afeb292e32d3ac6cb2d363d6aab2269dbfa4cfd6 SHA256 6601872b750e8915c070610733bb3c2fb246d26d6455f22307bbe5471d8ef030 EBUILD irtrans-irclient-5.11.04.ebuild 1527 RMD160 3736455a857915d833fc327078408fc83960d324 SHA1 36b73282b8a2aea36a766f490a3a49b85ddef5db SHA256 2a80964493da1e447f8ad37d37ecdd1f80890a9d592030607f5bef4586ca08d1
EBUILD irtrans-irclient-5.9.04.ebuild 853 RMD160 21e44943249aa1ae36822b10b2f174ecd7db4105 SHA1 1d5663b011858016945b2d30f4848c6707f16cea SHA256 0f6a4cad7da18eb91fffbff0435e6498b6c4cafbb2fe75c0e816662724c1dd92 EBUILD irtrans-irclient-5.9.04.ebuild 853 RMD160 21e44943249aa1ae36822b10b2f174ecd7db4105 SHA1 1d5663b011858016945b2d30f4848c6707f16cea SHA256 0f6a4cad7da18eb91fffbff0435e6498b6c4cafbb2fe75c0e816662724c1dd92
EBUILD irtrans-irclient-5.9.07-r1.ebuild 967 RMD160 dea515aae740779ae462880430e629eaf08224a4 SHA1 0dd219b329773c0fe49d5708f00f2c19cbf9fccb SHA256 c483c1644d2b6882114b15173ee4f93b3273c48418f3be5ff1fc013add49e791 EBUILD irtrans-irclient-5.9.07-r1.ebuild 967 RMD160 dea515aae740779ae462880430e629eaf08224a4 SHA1 0dd219b329773c0fe49d5708f00f2c19cbf9fccb SHA256 c483c1644d2b6882114b15173ee4f93b3273c48418f3be5ff1fc013add49e791
EBUILD irtrans-irclient-5.9.07.ebuild 836 RMD160 e8f9affd0ffbbc19aa15e921058a08d33035d8cc SHA1 e44e487e62c2e9ec8d1c22542034fd491967fa1c SHA256 623be9defbe24609c81d60b71699fdf3e95bf5af3ae233997339ce1b73bbe64c EBUILD irtrans-irclient-5.9.07.ebuild 836 RMD160 e8f9affd0ffbbc19aa15e921058a08d33035d8cc SHA1 e44e487e62c2e9ec8d1c22542034fd491967fa1c SHA256 623be9defbe24609c81d60b71699fdf3e95bf5af3ae233997339ce1b73bbe64c
MISC ChangeLog 1379 RMD160 d24b7fa0c11f7a28d1588237baa9309203870551 SHA1 10a3c1110559aedb636bc565258555e628b4f945 SHA256 1d3944d78e4d32891b6ce139a04ad35a127e2c6a67d72520ed6b891ad274a9b8 MISC ChangeLog 1527 RMD160 d10541f0e0a5aa126c66a580aef527e560be3b9d SHA1 d1e4e39aa61c126e2484e07b6b057a4b69822189 SHA256 e48769b3308741bdec560742350759430da48c913475931b07f3bc067e8db039
MISC metadata.xml 170 RMD160 645927a396fdc21cdeb089fe42c5397332420ea6 SHA1 ac7f48a14fec325926f9ce1be8fbf1f311b4f2e4 SHA256 d797a2ec6f9dc516c9f9c1a758ee87ad3e8c43101b5dc76c2f872d5bd4639b42 MISC metadata.xml 170 RMD160 645927a396fdc21cdeb089fe42c5397332420ea6 SHA1 ac7f48a14fec325926f9ce1be8fbf1f311b4f2e4 SHA256 d797a2ec6f9dc516c9f9c1a758ee87ad3e8c43101b5dc76c2f872d5bd4639b42

View File

@ -0,0 +1,662 @@
Submitted By: Mario Fetka (mario dot fetka at gmail dot com)
Date: 2008-08-06
Initial Package Version: 5.11.04
Origin: http://irtrans.de irserver package 5.09.07
Upstream Status: unknown
Description: readd ip_assign to the irclient package
diff -Naur irclient-5.11.04.orig/ip_assign.c irclient-5.11.04/ip_assign.c
--- irclient-5.11.04.orig/ip_assign.c 1970-01-01 00:00:00.000000000 +0000
+++ irclient-5.11.04/ip_assign.c 2007-08-19 21:03:25.000000000 +0000
@@ -0,0 +1,601 @@
+/*
+ * Copyright (c) 2007, IRTrans GmbH
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of IRTrans GmbH nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY IRTrans GmbH ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL IRTrans GmbH BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+#ifdef WIN32
+
+#include <winsock2.h>
+#include <windows.h>
+
+#else
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/un.h>
+#include <arpa/inet.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <netdb.h>
+#include <signal.h>
+#include <stdio.h>
+#include <net/if.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+
+
+typedef int SOCKET;
+typedef void* WSAEVENT;
+#define closesocket close
+#endif
+
+#include <stdio.h>
+
+typedef unsigned char byte;
+
+#ifdef WIN32
+typedef unsigned int uint;
+typedef unsigned short ushort;
+#endif
+
+typedef struct {
+ byte op;
+ byte htype;
+ byte hlen;
+ byte hops;
+ uint xid;
+ ushort secs;
+ ushort flags;
+ uint client_ip;
+ uint own_ip;
+ uint server_ip;
+ uint relay_ip;
+ byte client_mac[16];
+ byte server_name[64];
+ byte file[128];
+ byte opt_header[13];
+ byte options[299];
+} DHCP_REQUEST;
+
+
+typedef struct {
+ uint ip;
+ uint netmask;
+ uint gateway;
+ char password[30];
+ byte dhcp_flag;
+} IP_PARAM;
+
+typedef struct {
+ uint ip;
+ byte mac[6];
+ char firmware[10];
+ char ir_firmware[10];
+ byte dhcp_flag;
+} DEVICE_ENTRY;
+
+
+
+#ifdef WIN32
+WSAEVENT IrtLanEvent;
+#endif
+
+
+SOCKET snd_socket[32],rcv_socket;
+
+int open_sockets (uint ip[],int cnt);
+void new_devicequery (byte msg,uint srvadr,DHCP_REQUEST *req);
+void new_dhcpset (byte msg,uint srvadr,byte mac[],char password[],DHCP_REQUEST *req);
+void new_ipset (byte msg,uint srvadr,byte mac[],uint ip,uint nm,uint gw,char password[],DHCP_REQUEST *req);
+void SendQuery (uint ips[],int cnt);
+int ReadDevices (DEVICE_ENTRY *dev,int cnt);
+int StoreDevice (DEVICE_ENTRY *dev,DHCP_REQUEST *req);
+void read_ip_parameter (IP_PARAM *ip);
+void SetIP (uint ips[],int cnt,DEVICE_ENTRY *dev,IP_PARAM *ip);
+int GetOwnIP (uint ips[]);
+int GetInterfaces (uint ips[]);
+
+
+int main (int argc,char *argv[])
+
+{
+ int res,i,choice;
+ char nm[100];
+ struct in_addr iadr;
+ IP_PARAM ip;
+ DEVICE_ENTRY irtrans[256];
+ int device_count;
+ uint ip_adr[32];
+ int ip_count = 0;
+
+
+#ifdef WIN32
+ int err;
+ WORD wVersionRequired;
+ WSADATA wsaData;
+ wVersionRequired = MAKEWORD(2,2);
+ err = WSAStartup(wVersionRequired, &wsaData);
+ if (err != 0) return (1);
+#endif
+
+ argc++;
+ for (;--argc > 2;argv++) { // Process all Command Line Arguments
+ if (!strcmp (argv[1],"-interface")) {
+ argc--;
+ argv++;
+ ip_adr[0] = inet_addr (argv[1]);
+ ip_count = 1;
+ continue;
+ }
+
+ }
+
+
+ if (!ip_count) {
+ ip_count = GetOwnIP (ip_adr);
+ }
+
+ for (i=0;i < ip_count;i++) {
+ iadr.s_addr = ip_adr[i];
+ if (!i) printf ("\nOwn Interfaces / IPs: %s\n",inet_ntoa(iadr));
+ else printf (" %s\n",inet_ntoa(iadr));
+ }
+
+ printf ("\n");
+ res = open_sockets (ip_adr,ip_count);
+
+
+ if (res) {
+ printf ("Open socket error: %d [%d]\n",res,errno);
+ perror (NULL);
+ exit (-1);
+ }
+
+ while (1) {
+ SendQuery (ip_adr,ip_count);
+
+ memset (irtrans,0,sizeof (irtrans));
+ device_count = ReadDevices (irtrans,ip_count);
+
+ if (!device_count) {
+ printf ("No IRTrans Ethernet device(s) found\n");
+ exit (0);
+ }
+
+
+ printf ("\n%2d IRTrans Ethernet device(s) found:\n",device_count);
+ printf ("----------------------------------------------------------------\n");
+
+ for (i=0;i < device_count;i++) {
+ iadr.s_addr = irtrans[i].ip;
+
+ if (irtrans[i].dhcp_flag == 1) strcpy (nm,"DHCP");
+ else nm[0] = 0;
+ printf ("%2d %02x-%02x-%02x-%02x-%02x-%02x %-15s %s %8s %s\n",i+1,irtrans[i].mac[0],irtrans[i].mac[1],irtrans[i].mac[2],
+ irtrans[i].mac[3],irtrans[i].mac[4],irtrans[i].mac[5],inet_ntoa(iadr),irtrans[i].firmware,irtrans[i].ir_firmware,nm);
+ }
+ printf ("----------------------------------------------------------------\n");
+
+
+ printf ("Please select device to use (0 = Exit) ");
+ fflush (stdout);
+ do {
+ fgets (nm,sizeof (nm),stdin);
+ choice = atoi (nm);
+ } while (nm[0] < '0');
+
+ if (!choice) exit (0);
+
+ read_ip_parameter (&ip);
+
+ SetIP (ip_adr,ip_count,irtrans + choice-1,&ip);
+ }
+
+
+ return (0);
+}
+
+
+int GetOwnIP (uint ips[])
+{
+ char nm[100];
+ int count = 0;
+
+#ifdef WIN32
+ struct hostent *host;
+
+ gethostname (nm,100);
+
+ host = gethostbyname (nm);
+
+ while (host->h_addr_list[count]) {
+ if (host->h_addr_list[count][0] != 127) break;
+ }
+ ips[0] = *((uint *)host->h_addr_list[count]);
+ count = 1;
+#else
+ count = GetInterfaces (ips);
+#endif
+ return (count);
+}
+
+
+#ifndef WIN32
+int GetInterfaces (uint ips[])
+{
+ int i,j,cnt;
+ FILE *fp;
+ char *pnt,ln[256];
+ struct sockaddr_in *sinp;
+ struct ifreq ifr;
+ int s; /* Socket */
+ char local_ip_addr[16];
+
+ fp = fopen ("/proc/net/dev","r");
+ if (!fp) return (0);
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+
+ cnt = 0;
+ pnt = fgets (ln,sizeof (ln),fp);
+ while (pnt) {
+ i = 0;
+ while (ln[i] == ' ') i++;
+ if (!memcmp (ln+i,"eth",3)) {
+ j = i;
+ while ((ln[j] >= '0' && ln[j] <= '9') || (ln[j] >= 'a' && ln[j] <= 'z') || (ln[j] >= 'A' && ln[j] <= 'Z')) j++;
+ ln[j] = 0;
+ memset (&ifr,0,sizeof (ifr));
+ strcpy(ifr.ifr_name, ln+i);
+ ioctl(s, SIOCGIFADDR, &ifr);
+ sinp = (struct sockaddr_in*)&ifr.ifr_addr;
+ ips[cnt++] = sinp->sin_addr.s_addr;
+ }
+ pnt = fgets (ln,sizeof (ln),fp);
+ }
+
+ close (s);
+ fclose (fp);
+
+ return (cnt);
+}
+#endif
+
+
+void SetIP (uint server_ip[],int cnt,DEVICE_ENTRY *dev,IP_PARAM *ip)
+{
+ int i;
+ DHCP_REQUEST req;
+
+ for (i=0;i < cnt;i++) {
+ if (ip->dhcp_flag) new_dhcpset (190,server_ip[i],dev->mac,ip->password,&req);
+
+ else new_ipset (189,server_ip[i],dev->mac,ip->ip,ip->netmask,ip->gateway,ip->password,&req);
+
+ send (snd_socket[i],(char *)&req,sizeof (DHCP_REQUEST),0);
+ }
+}
+
+void read_ip_parameter (IP_PARAM *ip)
+{
+ char nm[100];
+
+ memset (ip,0,sizeof (IP_PARAM));
+
+ printf ("\n\nConfigure device for DHCP (Y/N) ? ");
+ fflush (stdout);
+ fgets (nm,sizeof (nm),stdin);
+ printf ("\n");
+
+ if (*nm == 'Y' || *nm == 'y') ip->dhcp_flag = 1;
+ else {
+ do {
+ printf ("\nEnter IP Address: ");
+ fflush (stdout);
+ fgets (nm,sizeof (nm),stdin);
+ ip->ip = inet_addr (nm);
+ } while (ip->ip == INADDR_NONE);
+ do {
+ printf ("\nEnter Netmask : ");
+ fflush (stdout);
+ fgets (nm,sizeof (nm),stdin);
+ ip->netmask = inet_addr (nm);
+ } while (ip->netmask == INADDR_NONE);
+ do {
+ printf ("\nDefault Gateway : ");
+ fflush (stdout);
+ fgets (nm,sizeof (nm),stdin);
+ ip->gateway = inet_addr (nm);
+ } while (ip->gateway == INADDR_NONE);
+ }
+
+ printf ("\n\nEnter device password: ");
+ fflush (stdout);
+ fgets (ip->password,8,stdin);
+
+ printf ("\n");
+}
+
+void SendQuery (uint ip_adr[],int cnt)
+{
+ int i;
+ DHCP_REQUEST req;
+
+ for (i=0;i < cnt;i++) {
+ new_devicequery (187,ip_adr[i],&req);
+ send (snd_socket[i],(char *)&req,sizeof (DHCP_REQUEST),0);
+ }
+}
+
+
+int ReadDevices (DEVICE_ENTRY *dev,int ipcnt)
+{
+ int i;
+ DHCP_REQUEST req;
+ int res,cnt = 0;
+
+#ifndef WIN32
+ fd_set events;
+ int maxfd,wait;
+ struct timeval tv;
+#endif
+
+#ifdef WIN32
+ IrtLanEvent = WSACreateEvent ();
+ WSAEventSelect (rcv_socket, IrtLanEvent,FD_READ);
+#endif
+
+ while (1) {
+
+#ifdef WIN32
+ res = WaitForSingleObject (IrtLanEvent,5000);
+ if (res == WAIT_TIMEOUT) break;
+ ResetEvent (IrtLanEvent);
+
+#else
+
+ FD_ZERO (&events);
+
+ FD_SET (rcv_socket,&events);
+ maxfd = rcv_socket + 1;
+
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+
+ wait = select (maxfd,&events,NULL,NULL,&tv);
+ if (!wait) break;
+#endif
+ res = recv (rcv_socket,(char *)&req,sizeof (req),0);
+ cnt += StoreDevice (dev + cnt,&req);
+ i = 0;
+ while (i < (cnt - 1)) {
+ if (!memcmp (dev[i].mac,dev[cnt-1].mac,6)) break;
+ i++;
+ }
+ if (i < (cnt - 1)) cnt--;
+
+ }
+ return (cnt);
+}
+
+
+int StoreDevice (DEVICE_ENTRY *dev,DHCP_REQUEST *req)
+{
+ if (req -> op != 1) return (0);
+
+ if (req -> opt_header[0] != 99 || req -> opt_header[1] != 130 || req -> opt_header[2] != 83 || req -> opt_header[3] != 99) return (0);
+ if (req -> opt_header[4] != 53 || req -> opt_header[5] != 1 || req -> opt_header[6] != 188 || req -> opt_header[7] != 0xe9) return (0);
+
+ if (req -> opt_header[9] != 0x78 || req -> opt_header[10] != 0xa3 || req -> opt_header[11] != 0x8b || req -> opt_header[12] != 0x84) return (0);
+
+
+ if (req -> client_mac[0] != 0 || req -> client_mac[1] != 0x50 || req -> client_mac[2] != 0xC2 ||
+ req -> client_mac[3] != 0x52 || (req -> client_mac[4] & 0xf0) != 0x70) return (0);
+
+
+ dev->ip = req -> client_ip;
+ memcpy (dev->mac,req -> client_mac,6);
+ dev->dhcp_flag = req->options[0];
+ memcpy (dev->firmware,req->options+1,8);
+ if (req -> opt_header[8] == 23) memcpy (dev->ir_firmware,req->options+9,8);
+
+ return (1);
+}
+
+
+void new_dhcpset (byte msg,uint srvadr,byte mac[],char password[],DHCP_REQUEST *req)
+{
+ int i,pos;
+
+ memset (req,0,sizeof (DHCP_REQUEST));
+
+ req->op = 2;
+ req->htype = 1;
+ req->hlen = 6;
+ req->hops = 0;
+ req->xid = htonl(0xaabbccdd);
+ req->secs = 0;
+ req->flags = htons (0x8000);
+ req->server_ip = srvadr;
+ memcpy (req->client_mac,mac,6);
+
+ req->opt_header[0] = 99;
+ req->opt_header[1] = 130;
+ req->opt_header[2] = 83;
+ req->opt_header[3] = 99;
+ req->opt_header[4] = 53;
+ req->opt_header[5] = 1;
+ req->opt_header[6] = msg;
+ req->opt_header[7] = 233;
+ req->opt_header[8] = 4;
+ req->opt_header[9] = 0xac;
+ req->opt_header[10] = 0x75;
+ req->opt_header[11] = 0x20;
+ req->opt_header[12] = 0xbf;
+
+ pos = 0;
+ req->options[pos++] = 234;
+ req->options[pos++] = strlen (password) + 1;
+
+ for (i=0;i < (int)strlen (password);i++) req->options[pos++] = password[i];
+ req->options[pos++] = 0;
+ req->options[pos++] = 255;
+}
+
+void new_ipset (byte msg,uint srvadr,byte mac[],uint ip,uint nm,uint gw,char password[],DHCP_REQUEST *req)
+{
+ int i,pos;
+
+ memset (req,0,sizeof (DHCP_REQUEST));
+
+ req->op = 2;
+ req->htype = 1;
+ req->hlen = 6;
+ req->hops = 0;
+ req->xid = htonl(0xaabbccdd);
+ req->secs = 0;
+ req->flags = htons (0x8000);
+ req->server_ip = srvadr;
+ req->own_ip = ip;
+ memcpy (req->client_mac,mac,6);
+
+ req->opt_header[0] = 99;
+ req->opt_header[1] = 130;
+ req->opt_header[2] = 83;
+ req->opt_header[3] = 99;
+ req->opt_header[4] = 53;
+ req->opt_header[5] = 1;
+ req->opt_header[6] = msg;
+ req->opt_header[7] = 233;
+ req->opt_header[8] = 4;
+ req->opt_header[9] = 0xac;
+ req->opt_header[10] = 0x75;
+ req->opt_header[11] = 0x20;
+ req->opt_header[12] = 0xbf;
+
+ pos = 0;
+ req->options[pos++] = 1; // Subnetmask
+ req->options[pos++] = 4;
+ memcpy (req->options+pos,&nm,4);
+ pos += 4;
+
+ req->options[pos++] = 3; // Default Gateway
+ req->options[pos++] = 4;
+ memcpy (req->options+pos,&gw,4);
+ pos += 4;
+
+ req->options[pos++] = 234;
+ req->options[pos++] = strlen (password) + 1;
+
+ for (i=0;i < (int)strlen (password);i++) req->options[pos++] = password[i];
+ req->options[pos++] = 0;
+ req->options[pos++] = 255;
+
+}
+
+void new_devicequery (byte msg,uint srvadr,DHCP_REQUEST *req)
+{
+ memset (req,0,sizeof (DHCP_REQUEST));
+
+ req->op = 2;
+ req->htype = 1;
+ req->hlen = 6;
+ req->hops = 0;
+ req->xid = htonl(0xaabbccdd);
+ req->secs = 0;
+ req->flags = htons (0x8000);
+ req->server_ip = srvadr;
+ req->client_mac[0] = 0xff;
+ req->client_mac[1] = 0xff;
+ req->client_mac[2] = 0xff;
+ req->client_mac[3] = 0xff;
+ req->client_mac[4] = 0xff;
+ req->client_mac[5] = 0xff;
+
+ req->opt_header[0] = 99;
+ req->opt_header[1] = 130;
+ req->opt_header[2] = 83;
+ req->opt_header[3] = 99;
+ req->opt_header[4] = 53;
+ req->opt_header[5] = 1;
+ req->opt_header[6] = msg;
+ req->opt_header[7] = 233;
+ req->opt_header[8] = 4;
+ req->opt_header[9] = 0x78;
+ req->opt_header[10] = 0xa3;
+ req->opt_header[11] = 0x8b;
+ req->opt_header[12] = 0x84;
+
+ req->options[0] = 255;
+}
+
+int open_sockets (uint ip[],int cnt)
+{
+ int res,i;
+ struct sockaddr_in iadr;
+ struct sockaddr_in serv_addr;
+
+ rcv_socket = socket (PF_INET,SOCK_DGRAM,0);
+ if (rcv_socket < 0) return (2);
+
+ memset (&serv_addr,0,sizeof (serv_addr));
+ serv_addr.sin_family = AF_INET;
+ serv_addr.sin_addr.s_addr = INADDR_ANY;
+ serv_addr.sin_port = htons (67);
+
+ res = bind (rcv_socket,(struct sockaddr *)&serv_addr,sizeof (serv_addr));
+ if (res) return (3);
+
+
+ for (i=0;i < cnt;i++) {
+ snd_socket[i] = socket (PF_INET,SOCK_DGRAM,0);
+ if (snd_socket[i] < 0) return (4);
+ res = 1;
+ setsockopt (snd_socket[i],SOL_SOCKET,SO_BROADCAST,(char *)&res,sizeof (int));
+
+
+#ifndef WIN32
+ memset (&serv_addr,0,sizeof (serv_addr));
+ serv_addr.sin_family = AF_INET;
+ serv_addr.sin_addr.s_addr = ip[i];
+ serv_addr.sin_port = 0;
+
+ res = bind (snd_socket[i],(struct sockaddr *)&serv_addr,sizeof (serv_addr));
+ if (res) return (6);
+#endif
+
+ memset (&iadr,0,sizeof (struct sockaddr));
+ iadr.sin_family = AF_INET;
+ iadr.sin_addr.s_addr = INADDR_BROADCAST;
+ iadr.sin_port = htons (68);
+
+ if (connect (snd_socket[i],(struct sockaddr *)&iadr,sizeof (struct sockaddr_in)) < 0) return (5);
+ }
+
+ return (0);
+}
+
diff -Naur irclient-5.11.04.orig/makefile irclient-5.11.04/makefile
--- irclient-5.11.04.orig/makefile 2008-08-06 20:11:16.000000000 +0000
+++ irclient-5.11.04/makefile 2008-08-06 20:27:31.000000000 +0000
@@ -15,6 +15,11 @@
OBJS64 = $(patsubst %,$(ODIR64)/%,$(_OBJS))
OBJSARM = $(patsubst %,$(ODIRARM)/%,$(_OBJS))
+_OBJS_IP = ip_assign.o
+OBJS_IP = $(patsubst %,$(ODIR)/%,$(_OBJS_IP))
+OBJS64_IP = $(patsubst %,$(ODIR64)/%,$(_OBJS_IP))
+OBJSARM_IP = $(patsubst %,$(ODIRARM)/%,$(_OBJS_IP))
+
irclient: $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -m32 -o irclient $(LDFLAGS)
@@ -26,15 +31,29 @@
$(CC) $(CFLAGS) $(OBJSARM) -o irclient $(LDFLAGS)
-all: irclient irclient64
+ip_assign: $(OBJS_IP)
+ $(CC) $(CFLAGS) $(OBJS_IP) -m32 -o ip_assign $(LDFLAGS)
+
+ip_assign64: $(OBJS64_IP)
+ $(CC) $(CFLAGS) -DX64 $(OBJS64_IP) -m64 -o ip_assign64 $(LDFLAGS)
+
+ip_assign_arm: $(OBJSARM_IP)
+ $(CC) $(CFLAGS) $(OBJSARM_IP) -o ip_assign $(LDFLAGS)
-arm: irclient_arm
+
+all: irclient irclient64 ip_assign ip_assign64
+
+arm: irclient_arm ip_assign_arm
clean:
- -rm $(OBJS)
- -rm $(OBJS64)
- -rm $(OBJSARM)
+ -rm -f $(OBJS)
+ -rm -f $(OBJS64)
+ -rm -f $(OBJSARM)
+
+ -rm -f $(OBJS_IP)
+ -rm -f $(OBJS64_IP)
+ -rm -f $(OBJSARM_IP)
$(ODIR)/%.o: %.c flash.h errcode.h network.h remote.h makefile

View File

@ -17,6 +17,13 @@ IUSE=""
DEPEND="virtual/libc" DEPEND="virtual/libc"
src_unpack() {
unpack ${A}
cd "${WORKDIR}"
epatch "${FILESDIR}/${PN}"-5.11.04-ip_assign-1.patch
}
src_compile() { src_compile() {
append-flags -DLINUX append-flags -DLINUX
@ -24,27 +31,34 @@ src_compile() {
# Set sane defaults (arm target has no -D flags added) # Set sane defaults (arm target has no -D flags added)
irbuild=irclient_arm irbuild=irclient_arm
irclient=irclient irclient=irclient
ipbuild=ip_assign_arm
ip_assign=ip_assign
# change variable by need # change variable by need
if use x86 ; then if use x86 ; then
irbuild=irclient irbuild=irclient
ipbuild=ip_assign
elif use amd64 ; then elif use amd64 ; then
irbuild=irclient64 irbuild=irclient64
irclient=irclient64 irclient=irclient64
elif use arm ; then ipbuild=ip_assign64
irbuild=irclient_arm ip_assign=ip_assign64
fi fi
# Some output for bugreport # Some output for bugreport
einfo "CFLAGS=\"${CFLAGS}\"" einfo "CFLAGS=\"${CFLAGS}\""
einfo "Build Target=\"${irbuild}\"" einfo "Build client Target=\"${irbuild}\""
einfo "Build Binary=\"${irclient}\"" einfo "Build cleint Binary=\"${irclient}\""
einfo "Build ip_assign Target=\"${ipbuild}\""
einfo "Build ip_assign Binary=\"${ip_assign}\""
# Build # Build
emake CXX="$(tc-getCXX)" CC="$(tc-getCC)" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" "${irbuild}" || die "emake irclient failed" emake CXX="$(tc-getCXX)" CC="$(tc-getCC)" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" "${irbuild}" || die "emake irclient failed"
emake CXX="$(tc-getCXX)" CC="$(tc-getCC)" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" "${ipbuild}" || die "emake ip_assign failed"
} }
src_install() { src_install() {
newbin "${WORKDIR}/${irclient}" irclient newbin "${WORKDIR}/${irclient}" irclient
newbin "${WORKDIR}/${ip_assign}" ip_assign
} }