From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mx1.emlix.com ([188.40.240.192]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jksnD-00072L-U1 for barebox@lists.infradead.org; Mon, 15 Jun 2020 17:21:15 +0000 From: =?UTF-8?q?Daniel=20Gl=C3=B6ckner?= Date: Mon, 15 Jun 2020 19:20:47 +0200 Message-Id: <03e16900dd984355d4da055473f635df819b851b.1592241105.git.dg@emlix.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v3 14/14] fastboot net: implement fastboot over UDP To: Barebox List Cc: Edmund Henniges , =?UTF-8?q?Daniel=20Gl=C3=B6ckner?= RnJvbTogRWRtdW5kIEhlbm5pZ2VzIDxlaEBlbWxpeC5jb20+CgpUaGlzIGltcGxlbWVudHMgdGhl IFVEUCB2YXJpYW50IG9mIHRoZSBmYXN0Ym9vdCBwcm90b2NvbC4gVGhlIG9ubHkgd2F5IHRvCnN0 YXJ0IHRoZSBzZXJ2aWNlIGZvciBub3cgaXMgdG8gY29tcGlsZSB3aXRoIENPTkZJR19GQVNUQk9P VF9ORVRfT05fQk9PVC4KVGhlIHNlcnZpY2Ugd2lsbCBiaW5kIHRvIHRoZSBuZXR3b3JrIGludGVy ZmFjZSB0aGF0IHByb3ZpZGVzIHRoZSBJUHY0CmdhdGV3YXkuCgpTZW5kaW5nIGFuIE9LQVkgcGFj a2V0IGJlZm9yZSBwZXJmb3JtaW5nIGEgcmVzdGFydCBpcyBuZWNlc3Nhcnkgc2luY2UKY29udHJh cnkgdG8gVVNCIHRoZSBob3N0IHdpbGwgbm90IG5vdGljZSB3aGVuIGEgVURQIHNlcnZlciBkaXNh cHBlYXJzLgoKU2ln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