My understanding of Pakistani and Afghanistani politics is that the border between these two countries is ill-defined, porous, and mostly a figment of British imagination moreso than any reality on the ground. The tribal areas such as the Swat Valley where Al-Qaeda held sway seem to be far more lawless than Pakistan in general, and a very "dangerous" area in particular.
So, how is then that this area became part of British India in the first place, and what are Pakistan's prospects of being able to incorporate these lawless areas into its mainstream altogether?
Also, I have heard that Afghanistan does not recognize Pakistan's claim to the Tribal areas demarcated by the Durand, and that if Afghanistan could ever become a fully functioning state, would lay claim to some Pakistan's territory. Is there any truth to this understanding?