• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

bmpStation is server of BGP monitoring protocol.


Commit MetaInfo

Revision5 (tree)
Zeit2015-01-18 14:02:58
Autoryuki0220

Log Message

making

Ändern Zusammenfassung

Diff

--- trunk/libbgp/bgp.h (revision 4)
+++ trunk/libbgp/bgp.h (revision 5)
@@ -85,6 +85,15 @@
8585 *| BGP Info |**
8686 *+==========================================================================+*/
8787 /*******************************************************************************
88+ * Union: AS Number area ********************************************************/
89+#ifndef UNION_AS_PathArea
90+# define UNION_AS_PathArea
91+union AS_PathArea {
92+ u_int16_t AS2;
93+ u_int32_t AS4;
94+};
95+#endif
96+/*******************************************************************************
8897 * Union: address area ********************************************************/
8998 #ifndef UNION_ADDRAREA
9099 # define UNION_ADDRAREA
@@ -117,6 +126,19 @@
117126
118127 /*****************************************************************************
119128 * pathAttribute ************************************************************/
129+ /* type: 1, Origin */
130+ u_int8_t PAOrigin;
131+ /* type: 2, AS PAth */
132+ int PAPathNum;
133+ union AS_PathArea *PAPathList;
134+ /* type: 4, MED */
135+ int PAMedBool;
136+ u_int32_t PAMed;
137+ /* type: 5, Local pref */
138+ int PALPBool;
139+ u_int32_t PALP;
140+
141+
120142 /* type: 14, MP_REACH_NLRI */
121143 u_int16_t PANLRIAFI; /* [IANA-AF] "Address Family Numbers" */
122144 u_int8_t PANLRIAFIsub;
@@ -213,7 +235,7 @@
213235 #if 0
214236 typedef u_int8_t BGPUpdatePathAttr_Origin_Unit;
215237 typedef u_int8_t BGPUpdatePathAttr_AsPath_Type;
216-typedef u_int16_t BGPUpdatePathAttr_AsPath_Unit;
238+ typedef u_int16_t BGPUpdatePathAttr_AsPath_Unit;
217239
218240 #define BGP_UPDATE_PATHATTR_TYPE_ORIGIN 1
219241 #define BGP_UPDATE_PATHATTR_TYPE_AS_PATH 2
@@ -227,6 +249,21 @@
227249 #define BGP_UPDATE_PATHATTR_TYPE_CLUSTER_LIST 10
228250 #endif
229251
252+
253+/* AS_PATH (Type Code 2):
254+ * 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
255+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
256+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
257+ * | Address Family Identifier | SubsequentAFI | Length |
258+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
259+ * | Network Address of Next Hop (variable) |
260+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
261+ * | Reserved | NLRI (variable) |
262+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
263+ * http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml
264+ * http://tools.ietf.org/html/rfc4760
265+ ******************************************************************************/
266+
230267 /* Multiprotocol Reachable NLRI - MP_REACH_NLRI (Type Code 14):
231268 * 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
232269 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
--- trunk/libbgp/getBGPmessages.c (revision 4)
+++ trunk/libbgp/getBGPmessages.c (revision 5)
@@ -39,6 +39,9 @@
3939 #endif
4040
4141
42+static int BGPUpdateAS_Path (u_int8_t *, ssize_t, BGPUpdateInfo *);
43+static int BGPUpdateMED (u_int8_t *, ssize_t, BGPUpdateInfo *);
44+static int BGPUpdateLP (u_int8_t *, ssize_t, BGPUpdateInfo *);
4245 static int BGPUpdatePathAttributeMPreachNLRI (u_int8_t *, ssize_t, BGPUpdateInfo *);
4346 static int BGPUpdatePathAttributeMPUnreachNLRI (u_int8_t *, ssize_t, BGPUpdateInfo *);
4447 /*%''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''%**
@@ -203,14 +206,23 @@
203206 case 0: /* reserved */
204207 return -1;
205208 break;
206-#if 0
207209 case 1: /* ORIGIN */
210+ bgpInfo->PAOrigin = *(pProc + PAHlen);
211+ ret = 1;
208212 break;
213+#if 0
209214 case 2: /* AS_PATH */
215+ ret = BGPUpdateAS_Path ((pProc + PAHlen), lenAttr, bgpInfo);
210216 break;
211217 case 3: /* NEXT_HOP */
212218 break;
213219 #endif
220+ case 4: /* MED */
221+ ret = BGPUpdateMED ((pProc + PAHlen), lenAttr, bgpInfo);
222+ break;
223+ case 5: /* LP */
224+ ret = BGPUpdateLP ((pProc + PAHlen), lenAttr, bgpInfo);
225+ break;
214226 case 14: /* MP_REACH_NLRI */
215227 ret = BGPUpdatePathAttributeMPreachNLRI ((pProc + PAHlen), lenAttr, bgpInfo);
216228 break;
@@ -235,6 +247,78 @@
235247 }
236248
237249 /*******************************************************************************
250+ * Path attribute type 2: *****************************************************
251+ *
252+ ******************************************************************************/
253+static int BGPUpdateAS_Path (u_int8_t *msg, ssize_t size, BGPUpdateInfo *bgpInfo)
254+{
255+ int ret, i;
256+ ssize_t areaSize;
257+ u_int8_t *psegType;
258+ u_int16_t *pAS;
259+ union AS_PathArea *pt;
260+
261+ if (size==0) {return 1;}
262+ psegType = msg;
263+ bgpInfo->PAPathNum = (int)(*(msg+1));
264+ areaSize = bgpInfo->PAPathNum * sizeof (union AS_PathArea);
265+
266+ pt = malloc (areaSize);
267+ if (pt==NULL) {return -1;}
268+ (void) memset (pt, 0, areaSize);
269+ pAS = (u_int16_t *)(msg+2);
270+
271+ for (i=0; i<bgpInfo->PAPathNum; i++) {
272+ (pt+i)->AS2 = be16toh (*(pAS+i));
273+ printf ("AS[%d]: %d\n", i, (pt+i)->AS2);
274+ }
275+
276+ return 1;
277+}
278+
279+/*******************************************************************************
280+ * Path attribute type 4: *****************************************************
281+ *
282+ ******************************************************************************/
283+static int BGPUpdateMED (u_int8_t *msg, ssize_t size, BGPUpdateInfo *bgpInfo)
284+{
285+ int ret, i;
286+ ssize_t areaSize;
287+ u_int8_t *psegType;
288+ u_int16_t *pAS;
289+ union AS_PathArea *pt;
290+
291+ bgpInfo->PAMedBool = 0;
292+ if (size!=4) {return 0;}
293+ bgpInfo->PAMedBool = 1;
294+ bgpInfo->PAMed = be32toh (*(u_int32_t *)msg);
295+ printf ("MED: %d\n", bgpInfo->PAMed);
296+
297+ return 1;
298+}
299+
300+/*******************************************************************************
301+ * Path attribute type 5: *****************************************************
302+ *
303+ ******************************************************************************/
304+static int BGPUpdateLP (u_int8_t *msg, ssize_t size, BGPUpdateInfo *bgpInfo)
305+{
306+ int ret, i;
307+ ssize_t areaSize;
308+ u_int8_t *psegType;
309+ u_int16_t *pAS;
310+ union AS_PathArea *pt;
311+
312+ bgpInfo->PALPBool = 0;
313+ if (size!=4) {return 0;}
314+ bgpInfo->PALPBool = 1;
315+ bgpInfo->PALP = be32toh (*(u_int32_t *)msg);
316+ printf ("LP: %d\n", bgpInfo->PALP);
317+
318+ return 1;
319+}
320+
321+/*******************************************************************************
238322 * Path attribute type 14: *****************************************************
239323 *
240324 ******************************************************************************/
@@ -285,6 +369,7 @@
285369 void freeBGPupdateInfo (BGPUpdateInfo *bgpInfo)
286370 {
287371 if (bgpInfo->withdrawnList !=NULL) {free (bgpInfo->withdrawnList );}
372+ if (bgpInfo->PAPathList !=NULL) {free (bgpInfo->PAPathList );}
288373 if (bgpInfo->PANLRIList !=NULL) {free (bgpInfo->PANLRIList );}
289374 if (bgpInfo->PAwithdrawnList!=NULL) {free (bgpInfo->PAwithdrawnList);}
290375 if (bgpInfo->NLRIList !=NULL) {free (bgpInfo->NLRIList );}